xrpl-go is a Go SDK for interacting with the XRP Ledger. It provides address codecs, key management, binary serialization, typed transaction models, RPC and WebSocket clients, wallet helpers, local transaction signing, and multisigning.
See the xrpl-go documentation for guides and package docs, or browse the Go API reference.
xrpl-go requires Go 1.24.3 or later.
go get github.com/Peersyst/xrpl-goThis example creates and funds a Testnet wallet, builds a payment, autofills the network fields, signs it locally, and submits it to a validated ledger.
package main
import (
"fmt"
"log"
"strconv"
"github.com/Peersyst/xrpl-go/pkg/crypto"
"github.com/Peersyst/xrpl-go/xrpl/currency"
"github.com/Peersyst/xrpl-go/xrpl/faucet"
"github.com/Peersyst/xrpl-go/xrpl/rpc"
"github.com/Peersyst/xrpl-go/xrpl/transaction"
"github.com/Peersyst/xrpl-go/xrpl/transaction/types"
"github.com/Peersyst/xrpl-go/xrpl/wallet"
)
func main() {
cfg, err := rpc.NewClientConfig(
"https://s.altnet.rippletest.net:51234/",
rpc.WithFaucetProvider(faucet.NewTestnetFaucetProvider()),
)
if err != nil {
log.Fatal(err)
}
client := rpc.NewClient(cfg)
sender, err := wallet.New(crypto.ED25519())
if err != nil {
log.Fatal(err)
}
if err := client.FundWallet(&sender); err != nil {
log.Fatal(err)
}
drops, err := currency.XrpToDrops("1")
if err != nil {
log.Fatal(err)
}
amount, err := strconv.ParseUint(drops, 10, 64)
if err != nil {
log.Fatal(err)
}
payment := transaction.Payment{
BaseTx: transaction.BaseTx{
Account: sender.ClassicAddress,
},
Destination: types.Address("rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe"),
Amount: types.XRPCurrencyAmount(amount),
DeliverMax: types.XRPCurrencyAmount(amount),
}
flatTx := payment.Flatten()
if err := client.Autofill(&flatTx); err != nil {
log.Fatal(err)
}
txBlob, txHash, err := sender.Sign(flatTx)
if err != nil {
log.Fatal(err)
}
res, err := client.SubmitTxBlobAndWait(txBlob, false)
if err != nil {
log.Fatal(err)
}
fmt.Printf("submitted hash: %s\n", txHash)
fmt.Printf("validated: %t, ledger: %d\n", res.Validated, res.LedgerIndex)
}Never print, log, commit, or send real seeds, private keys, or mnemonics to telemetry. Anyone with those values can control the account.
The usual write path is:
- Build a typed transaction, such as
transaction.Payment. - Call
Flatten()to get atransaction.FlatTransaction. - Call
client.Autofill()to add network fields likeFee,Sequence, andLastLedgerSequence. - Sign locally with
wallet.Sign(). - Submit with
client.SubmitTxBlobAndWait(), or useclient.SubmitTxAndWait()to autofill, sign, submit, and wait in one call.
A transaction is a command you submit. Ledger entries are durable state you query after validation. The validated transaction response includes metadata that explains which ledger entries were created, modified, or deleted.
For offline signing, keep the Autofill() and Sign() boundary explicit: autofill needs network access, signing only needs the transaction data and wallet credentials.
See examples/send-xrp/rpc for a longer payment example.
| Package | Use it for |
|---|---|
address-codec |
Encode and decode XRPL classic addresses and X-addresses |
binary-codec |
Encode and decode XRPL objects and transactions in canonical binary format |
keypairs |
Generate seeds, derive keypairs, sign payloads, and verify signatures |
xrpl/rpc |
Send JSON-RPC requests, autofill transactions, submit transactions, and fund Testnet or Devnet wallets |
xrpl/websocket |
Connect to WebSocket servers, make requests, submit transactions, and subscribe to ledger streams |
xrpl/transaction |
Build typed XRPL transaction models |
xrpl/wallet |
Create wallets, derive wallets from seeds or mnemonics, sign transactions, multisign transactions, and authorize payment channels |
- Create wallets and sign transactions
- Use the RPC client
- Use the WebSocket client
- Build transactions
- Learn XRPL concepts and protocol rules
The signing functionality in this repository has not been independently audited. Treat local signing as security-sensitive code: protect wallet secrets, test on Testnet or Devnet first, and review signing behavior before using it to control production funds.
Development setup, test commands, docs-site commands, and pull request guidance are in CONTRIBUTING.md.
If you find a bug or documentation gap, please open an issue in the XRPL-GO GitHub repository.
The xrpl-go library is licensed under the MIT License.