PWR Chain Rust SDK
PWR Rust is a Rust 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)
🌐 Documentation
Play with Code Examples 🎮
💫 Getting Started
Import the library:
use ;
Set your RPC node:
let rpc = RPCnew.await.unwrap;
Generate a new wallet:
let private_key = "0xac0974bec...f80";
let wallet = from_hex.unwrap;
Get wallet address:
let address = wallet.address;
Get wallet balance:
let balance = wallet.get_balance.await;
Transfer PWR tokens:
/// recipientAddress: 20 bytes address without `0x`
wallet.transfer_pwr.await;
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.
use Wallet;
async
Send data to a VM:
use Wallet;
async
Other Static Calls
Get RPC Node Url:
Returns currently set RPC node URL.
let url = rpc.node_url;
**Get Fee Per Byte: **
Gets the latest fee-per-byte rate.
let fee = rpc.fee_per_byte;
Get Balance Of Address:
Gets the balance of a specific address.
let balance = rpc.balance_of_address.await.unwrap;
Get Nonce Of Address:
Gets the nonce/transaction count of a specific address.
let nonce = rpc.nonce_of_address.await.unwrap;
✏️ Contributing
If you consider to contribute to this project please read CONTRIBUTING.md first.
You can also join our dedicated channel for pwr-rs on the PWR Chain Discord
📜 License
Copyright (c) 2024 PWR Labs
Licensed under the MIT license.