PWRJS is a JavaScript library for interacting with the PWR blobkchain. It provides an interface for wallet management and sending transactions on PWR.
install the package according to your environment. (nodejs or browser)
# latest official release (main branch)
$ npm install @pwrjs/core
# for latest pre-release version (develop branch)
$ npm install @pwrjs/core@next
# for latest beta release version (beta branch)
$ npm install @pwrjs/core@betaPlay with Code Examples 🎮
Import the library:
import PWRJS from "@pwrjs/core";
import Wallet from "@pwrjs/core/wallet";
// or
const PWRJS = require('@pwrjs/core');
const Wallet = require('@pwrjs/core/wallet');Create a new instance
const pwrjs = new PWRJS('https://pwrrpc.pwrlabs.io');Generate a new random wallet:
const wallet = Wallet.newRandom(12);Import wallet by Seed Phrase:
const seedPhrase = "your seed phrase here";
const wallet = Wallet.fromSeedPhrase(seedPhrase);Get wallet address:
const address = wallet.getAddress();Get wallet seed phrase:
const seedPhrase = wallet.getSeedPhrase();Get wallet balance:
const balance = await wallet.getBalance();Transfer PWR tokens:
const recipientAddress = '0x...';
const pwrAmount = '1000000000'; // 1 PWR = 10^9
await wallet.transferPWR(recipientAddress, BigInt(pwrAmount));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 response = await wallet.transferPWR(recipientAddress, BigInt(pwrAmount));
if (response.sucess) {
console.log('Transcation Hash: ' + response.hash);
}
} catch (e) {
console.log(e);
}Send data to a vida:
const vidaId = BigInt('123');
const data = new TextEncoder().encode('Hello world');
try {
const response = await wallet.sendVidaData(vidaId, data);
if (response.sucess) {
console.log('Transcation Hash: ' + response.hash);
}
} catch (e) {
console.log(e);
}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);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
Copyright (c) 2025 PWR Labs
Licensed under the MIT license.