@pwrjs/core-beta
v0.8.30
Published
PWRJS is a javasrcipt library for interacting with the PWR network.
Readme
PWRJS
PWRJS is a JavaScript library for interacting with the PWR blobkchain. It provides an interface for wallet management and sending transactions on PWR.
Installation
# latest official release (main branch)
$ npm install @pwrjs/core
# or for latest pre-release version (develop branch)
$ npm install @pwrjs/core@next
# or for latest beta release version (beta branch)
$ npm install @pwrjs/core@beta🌐 Documentation
Play with Code Examples 🎮
💫 Getting Started
Import the library:
import { PWRJS, PWRWallet } from '@pwrjs/core';
// or
const { PWRJS, PWRWallet } = require('@pwrjs/core');Create a new instance
const pwrjs = new PWRJS('https://pwrrpc.pwrlabs.io/');Generate a new wallet:
const privateKey = "0xac0974bec...f80";
const wallet = new PWRWallet(privateKey);Get wallet address:
const address = await wallet.getAddress();Get wallet balance:
const balance = await wallet.getBalance();Get private key:
const privateKey = await wallet.getPrivateKey();Transfer PWR tokens:
await wallet.transferPWR('recipientAddress', '100');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.
try {
const r = await wallet.transferPWR('recipientAddress', 1000);
if (r.status == true) {
console.log('Transcation Hash: ' + r.data);
}
} catch (e) {
console.log(e);
}Send data to a VM:
const vmId = 123;
const dataBytes = Buffer.from('Hello World!');
try {
const r = await wallet.sendVMDataTxn(vmId, dataBytes);
if (r.status == true) {
console.log('Transcation Hash: ' + r.data);
}
} catch (e) {
console.log(e);
}Other Static Calls
Get RPC Node Url:
Returns currently set RPC node URL.
const url = await PWRJS.getRpcNodeUrl();**Get Fee Per Byte: **
Gets the latest fee-per-byte rate.
const fee = await PWRJS.getFeePerByte();Get Balance Of Address:
Gets the balance of a specific address.
const balance = await PWRJS.getBalanceOfAddress('0x...');Get Nonce Of Address:
Gets the nonce/transaction count of a specific address.
const nonce = await PWRJS.getNonceOfAddress('0x...');Broadcast Txn:
Broadcasts a signed transaction to the network.
const signedTransaction = "...";
const broadcast = await PWRJS.broadcastTxn(signedTransaction);✏️ Contributing
If you consider to contribute to this project please read CONTRIBUTING.md first.
You can also join our dedicated channel for pwrjs on the PWR Chain Discord
📜 License
Copyright (c) 2025 PWR Labs
Licensed under the MIT license.
