PWRPY is a Python library for interacting with the PWR network. It provides an easy interface for wallet management and sending transactions on PWR.
# latest official release (main branch)
pip3 install pwrpy
Play with Code Examples 🎮
Import the library:
from pwrpy.pwrsdk import PWRPY
from pwrpy.pwrwallet import PWRWallet
Set your rpc and wallet:
private_key = "0xac0974bec...f80"
pwr = PWRPY("https://pwrrpc.pwrlabs.io/")
wallet = PWRWallet(private_key)
Get wallet address:
address = wallet.get_address()
Get wallet balance:
balance = wallet.get_balance()
Get private key:
pk = wallet.get_private_key()
Transfer PWR tokens:
transfer = wallet.transfer_pwr("recipientAddress", 100000)
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.
transfer = wallet.transfer_pwr("recipientAddress", 100000)
if transfer.success:
print("Transfer:", transfer.__dict__)
else:
print("FAILED!")
Send data to a VM:
data = "Hello World!"
sendVmData = wallet.send_vm_data_transaction(123, data.encode())
if sendVmData.success:
print("SendVmData:", sendVmData.__dict__)
else:
print("FAILED!")
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 VM Data:
start_block = 843500
end_block = 843750
vm_id = 123
transactions = pwr.get_vm_data_txns(start_block, end_block, vm_id)
for txs in transactions:
print("Data:", txs.data)
Broadcast Txn:
Broadcasts a signed transaction to the network.
signedTransaction = "..."
broadcast = pwr.broadcast_transaction(signedTransaction)
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
Copyright (c) 2025 PWR Labs
Licensed under the MIT license.