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 PWRWallet

Set your rpc and wallet:

private_key = "0xac0974bec...f80"
pwr = PWRPY()
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!")

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

✏️ 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) 2024 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.6.tar.gz (23.6 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.6-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pwrpy-6.0.6.tar.gz
Algorithm Hash digest
SHA256 7e9928d399a51ed540d579dc03bf56829ac4ec5ca9441c05f83baba4ac753f11
MD5 1d764299c9208149265b9ba7a2039d63
BLAKE2b-256 9e5556f48b514dc164e5b8723d8e64ca7b74f95986a65502112def18fa62d9bd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pwrpy-6.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ee77c4d7690125c581cc12313aa29688148345eb38148cc733349fb7e74b9078
MD5 a7637f9cc053f89bf3848467189966bf
BLAKE2b-256 62be4ef6f91d49b8dde971dc2a650cf0cc4b8c4a78c833edadbabf2a8031e70a

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