PWR Go is a Go library for interacting with the PWR network. It provides an easy interface for wallet management and sending transactions on PWR.
Play with Code Examples 🎮
Import the library:
import (
"fmt"
"github.com/pwrlabs/pwrgo/rpc"
"github.com/pwrlabs/pwrgo/wallet"
)
Set your RPC node:
var pwr = rpc.SetRpcNodeUrl("https://pwrrpc.pwrlabs.io")
Generate a new random wallet:
wallet, _ := wallet.NewRandom(12)
Import wallet by Seed Phrase:
seedPhrase := "your seed phrase here"
wallet, _ := wallet.New(seedPhrase)
Get wallet address:
var address = wallet.GetAddress()
Get wallet seed phrase:
var seedPhrase = wallet.GetSeedPhrase()
Get wallet balance:
var balance = wallet.GetBalance()
Transfer PWR tokens:
wallet.TransferPWR("recipientAddress", "amount", "feePerByte")
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.
package main
import (
"fmt"
"github.com/pwrlabs/pwrgo/rpc"
"github.com/pwrlabs/pwrgo/wallet"
)
func main() {
seedPhrase := "your seed phrase here"
wallet, _ := wallet.New(seedPhrase)
amount := 1000
feePerByte := wallet.GetRpc().GetFeePerByte()
response := wallet.TransferPWR("recipientAddress", amount, feePerByte)
if response.Success {
fmt.Printf("Transfer tx hash: %s\n", response.Hash)
} else {
fmt.Println("Error sending Transfer tx:", response.Error)
}
}
Send data to a VIDA:
package main
import (
"fmt"
"github.com/pwrlabs/pwrgo/rpc"
"github.com/pwrlabs/pwrgo/wallet"
)
func main() {
seedPhrase := "your seed phrase here"
wallet, _ := wallet.New(seedPhrase)
vidaId := 123
data := []byte("Hello world")
feePerByte := wallet.GetRpc().GetFeePerByte()
response := wallet.SendVidaData(vidaId, data, feePerByte)
if response.Success {
fmt.Printf("Sending tx hash: %s\n", response.Hash)
} else {
fmt.Println("Error sending VIDA data tx:", response.Error)
}
}
Get RPC Node Url:
Returns currently set RPC node URL.
var url = pwr.GetRpcNodeUrl()
Get Fee Per Byte:
Gets the latest fee-per-byte rate.
var fee = pwr.GetFeePerByte()
Get Balance Of Address:
Gets the balance of a specific address.
var balance = pwr.GetBalanceOfAddress("0x...")
Get Nonce Of Address:
Gets the nonce/transaction count of a specific address.
var nonce = pwr.GetNonceOfAddress("0x...")
If you consider to contribute to this project please read CONTRIBUTING.md first.
You can also join our dedicated channel for developers on the PWR Chain Discord
Copyright (c) 2025 PWR Labs
Licensed under the MIT license.