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 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.0.tar.gz (40.4 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.0-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: polkadot_gateway-0.1.0.tar.gz
  • Upload date:
  • Size: 40.4 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.0.tar.gz
Algorithm Hash digest
SHA256 6944caf7075ec865ec98bf7e81bd1423241ca711487e242caa4d9066914d38f4
MD5 f6e09a94fc33fb48713b8e259ab2f825
BLAKE2b-256 ec00c209cf15589012514e6a26e6051414e1fe2a675b4ebda36c397614395622

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polkadot_gateway-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 818293e6f2624de6c68c07149fe7ecf6386c62f02daff00952a364c47593746c
MD5 e71a766e3b6ec68edc24fd48ebf2a5c6
BLAKE2b-256 8e862368091eadaf4f3ca1e329a650975160b058fcce89eb8426490a8fd3de1f

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