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.1.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.1-py3-none-any.whl (28.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: polkadot_gateway-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b1573fe76f239a44c46d5beaaa97eabb0130ba5e62d1605b4ecda9210582771a
MD5 8a937b06630cb9b929b0668988da006d
BLAKE2b-256 2e60f334524021afa2af8ee7762d9901e3724424e8e280c72f4cafc0bb287149

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for polkadot_gateway-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa54466a0c04c95b90ea35d433524c3790ca54c98b94b2de5e86c5f7d8cfcf31
MD5 28fb2ecf4c8ad2eb3a64e9a31f07d362
BLAKE2b-256 22b6d410bbc439660ad8e9ee8e0c6ee25b3397addb20283e7ef6a9694eee01cb

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