Skip to main content

PWRPY is a Python library for interacting with the PWR network.

Project description

PWRPY

PWRPY is a Python library for interacting with the PWR network. It provides an easy interface for wallet management and sending transactions on PWR.

Installation

# latest official release (main branch)
pip3 install pwrpy

🌐 Documentation

How to Guides 🔜 & API 💻

Play with Code Examples 🎮

💫 Getting Started

Import the library:

from pwrpy.pwrsdk import PWRPY
from pwrpy.pwrwallet import Wallet

Set your RPC node:

pwr = PWRPY("https://pwrrpc.pwrlabs.io/")

Generate a new random wallet:

wallet = Wallet.new_random(12)

Import wallet by Seed Phrase:

seed_phrase = "your seed phrase here"
wallet = Wallet.new(seed_phrase)

Get wallet address:

address = wallet.get_address()

Get wallet seed phrase:

seed_phrase = wallet.get_seed_phrase()

Get wallet balance:

balance = wallet.get_balance()

Get private key:

pk = wallet.get_private_key()

Transfer PWR tokens:

response = wallet.transfer_pwr("recipientAddress", "amount", "fee_per_byte")

Sending a transcation to the PWR Chain returns a Response object, which specified if the transaction was a success, and returns relevant data. If the transaction was a success, you can retrieive the transaction hash, if it failed, you can fetch the error.

from pwrpy.pwrwallet import Wallet
seed_phrase = "your seed phrase here"
wallet = Wallet.new(seed_phrase)
amount = 1000
fee_per_byte = wallet.get_rpc().get_fee_per_byte()

response = wallet.transfer_pwr("recipientAddress", amount, fee_per_byte)
if response.success:
    print("Transfer:", response.__dict__)
else:
    print("FAILED!")

Send data to a VIDA:

from pwrpy.pwrwallet import Wallet
seed_phrase = "your seed phrase here"
wallet = Wallet.new(seed_phrase)

vida_id = 123
data = "Hello World!"
fee_per_byte = wallet.get_rpc().get_fee_per_byte()

response = wallet.send_vida_data(vida_id, data.encode(), fee_per_byte)
if response.success:
    print("SendVidaData:", response.__dict__)
else:
    print("FAILED!")

Other Static Calls

Get RPC Node Url:

Returns currently set RPC node URL.

url = pwr.get_rpc_node_url()

**Get Fee Per Byte: **

Gets the latest fee-per-byte rate.

fee = pwr.get_fee_per_byte()

Get Balance Of Address:

Gets the balance of a specific address.

balance = pwr.get_balance_of_address('0x...')

Get Nonce Of Address:

Gets the nonce/transaction count of a specific address.

nonce = pwr.get_nonce_of_address('0x...')

Get VIDA Data:

start_block = 843500
end_block = 843750
vida_id = 123

transactions = pwr.get_vida_data_txns(start_block, end_block, vida_id)
for txs in transactions:
    print("Data:", txs.data)

✏️ Contributing

If you consider to contribute to this project please read CONTRIBUTING.md first.

You can also join our dedicated channel for pwrpy on the PWR Chain Discord

📜 License

Copyright (c) 2025 PWR Labs

Licensed under the MIT license.

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

pwrpy-6.0.7.tar.gz (109.0 kB view details)

Uploaded Source

Built Distribution

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

pwrpy-6.0.7-py3-none-any.whl (110.2 kB view details)

Uploaded Python 3

File details

Details for the file pwrpy-6.0.7.tar.gz.

File metadata

  • Download URL: pwrpy-6.0.7.tar.gz
  • Upload date:
  • Size: 109.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Darwin/24.4.0

File hashes

Hashes for pwrpy-6.0.7.tar.gz
Algorithm Hash digest
SHA256 962984972320639fae29548b18f72e53bd8110392573bc8aa15f4155e5768f3a
MD5 c4ad5163a05c7a677e61f5a0b644aa13
BLAKE2b-256 e99b2302cf01434a5979a59223b83cd443c32a3137e8eaa98c84e886355011a2

See more details on using hashes here.

File details

Details for the file pwrpy-6.0.7-py3-none-any.whl.

File metadata

  • Download URL: pwrpy-6.0.7-py3-none-any.whl
  • Upload date:
  • Size: 110.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.14 Darwin/24.4.0

File hashes

Hashes for pwrpy-6.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e87de64257d62c708ab2c9192948a23b64b9330e045d29ea0fc10433684c6559
MD5 8318e8657e37c3a525604325015b86e6
BLAKE2b-256 d51df56a8d98471cb5cfc474bc49bb78884091f3b03b8b03c7a820732f1a0046

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