Skip to main content

Abstractions for the Polkadot ecosystem

Project description

PyPolkadot

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 PyPolkadot 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 PyPolkadot

Usage

Basic usage

from polkadot import *

# 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://polkadot-rpc-tn.dwellir.com")

# Get account balance
balance = polka.get_balance("12pDATAH2rCakrYjo6UoYFtmTEUpSyePTum8U5x9QdySZuqn")
print(f"Balance: {balance} DOT")
# Create a Polkadot instance (testnet, defaults to Polkadot Westend)
polka = Polkadot(testnet=True)

# Create a new wallet
wallet1 = Wallet.create(polka)
address = wallet1.default_address

# Request tokens from the faucet (only on testnet)
faucet_tx = wallet1.faucet()

# Get balance
balance = wallet1.get_balance()

# Send tokens
receiver_address = "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty"
tx_receipt = wallet1.send(1, receiver_address)

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

pypolkadot-0.1.3.tar.gz (41.1 kB view details)

Uploaded Source

Built Distribution

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

PyPolkadot-0.1.3-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file pypolkadot-0.1.3.tar.gz.

File metadata

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

File hashes

Hashes for pypolkadot-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4401252bf2e0af8ff62e62ab3840b560fec24f35fa686346173f9998839b9ede
MD5 161342fddd9346f432c0b03b15687b24
BLAKE2b-256 04b17a198dd84a1e2f8f27cd7384c888639c1654ff860284e803fda6373c9550

See more details on using hashes here.

File details

Details for the file PyPolkadot-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: PyPolkadot-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 29.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.6

File hashes

Hashes for PyPolkadot-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 5cb8960f2af59b82cd9663cf416aaab686aa2a666686c42ee2ed1ccea28cb85b
MD5 df5ca6a7a1dd8c960e95fe50fed5e62e
BLAKE2b-256 e4b17614aae04d3f48f242d63712e1a45154f76341e590a785d0242517bd6b20

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