Skip to main content

Abstractions for the Polkadot ecosystem

Project description

polkadot-gateway

Abstractions for the Polkadot ecosystem.

This package is a very opinionated wrapper around py-substrate-interface. It provides a simple synchronous interface for interacting with the Polkadot ecosystem. The polkadot-gateway package can automatically detect when the metadata is outdated and refresh it behind the scenes. This ensures that developers don’t have to manually handle metadata updates.

Note: Light client functionality is not yet supported.

Installation

pip install polkadot-gateway

Usage

Basic usage

from polkadot_gateway import Polkadot

# Initialize Polkadot instance
polka = Polkadot()  # Defaults to the mainnet relay chain

# Optionally, specify a custom RPC endpoint or use a testnet
polka = Polkadot(endpoint="wss://rpc.polkadot.io")

# Get account balance
balance = polka.get_balance("12pDATAH2rCakrYjo6UoYFtmTEUpSyePTum8U5x9QdySZuqn")
print(f"Balance: {balance} DOT")

Advanced usage

Advanced functions

from polkadot import Polkadot

# Staking
polka.nominate(nominator_keypair, ["Validator1", "Validator2"])

# Governance
polka.vote(proposal_hash, True, keypair)

Parachain usage

Parachains can extend the functionality for their own chain very easily.

Acala Defi

from polkadot.parachains import Acala

# Initialize Acala parachain interface
acala = Acala()

# Get balance in Acala (native token)
balance = acala.get_balance("account_address")
print(f"Balance: {balance} ACA")

# Swap tokens using Acala's DEX
acala.swap_tokens(sender_keypair, "DOT", "ACA", 10)

Moonbeam Contract calling

from polkadot.parachains import Moonbeam

# Initialize Moonbeam parachain interface
moonbeam = Moonbeam()

# Interact with Moonbeam smart contracts
contract = moonbeam.get_contract("contract_address")
result = contract.call_method("methodName", params)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polkadot_gateway-0.1.2.tar.gz (41.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

polkadot_gateway-0.1.2-py3-none-any.whl (28.5 kB view details)

Uploaded Python 3

File details

Details for the file polkadot_gateway-0.1.2.tar.gz.

File metadata

  • Download URL: polkadot_gateway-0.1.2.tar.gz
  • Upload date:
  • Size: 41.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for polkadot_gateway-0.1.2.tar.gz
Algorithm Hash digest
SHA256 cf148e1b120a8506e8fd8b2cbcb638886789031c23172f3a15a7d65278a68d04
MD5 668c6b1681482faa235f65e9ee8b625d
BLAKE2b-256 cd76d1277a0c4eed7f7a784a11bf2cd4a33bb5c74e3e811226d048abb05d7cde

See more details on using hashes here.

File details

Details for the file polkadot_gateway-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for polkadot_gateway-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ae8a668cb9db417206ad33c5885a4e8189dda8afd21e797914f11ca9bd479f52
MD5 0edd30d8cb38680dd5f3af42256787c6
BLAKE2b-256 9ffa7a3ff9ce40cac1a6adce95a4b10d9ad3ed0398b2064956676f74292cd7ef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page