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.2.tar.gz (40.6 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.2-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pypolkadot-0.1.2.tar.gz
  • Upload date:
  • Size: 40.6 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.2.tar.gz
Algorithm Hash digest
SHA256 e30f24b6e3dc7197775d31c924083d0ca80ba04a228fdeb66d34a67092633e44
MD5 b7fc5edd835a0573f5c6e8a2955354af
BLAKE2b-256 59697425b4556b8605746d2a229740839cfbb2dd7a29c78846b836a8fbf4b2da

See more details on using hashes here.

File details

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

File metadata

  • Download URL: PyPolkadot-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 28.7 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 55b8ba6da4d4c931458e3e93d55626bc5043d4b84f7b9df44c8cb6106dfec585
MD5 706878846395d6c2c4e56d1e4e53f302
BLAKE2b-256 f8384b136b2ed0a5985868cd9e8a0db2c61b2f53b7d30989583560d258058b41

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