xrpl-go

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2026 License: MIT

README

XRPL-GO

Go Reference Go Report Card Release Card

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.

Reference documentation

See the xrpl-go documentation for guides and package docs, or browse the Go API reference.

Installation

xrpl-go requires Go 1.25.12 or later.

go get github.com/Peersyst/xrpl-go

Quickstart

This 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.

Transaction lifecycle

The usual write path is:

  1. Build a typed transaction, such as transaction.Payment.
  2. Call Flatten() to get a transaction.FlatTransaction.
  3. Call client.Autofill() to add network fields like Fee, Sequence, and LastLedgerSequence.
  4. Sign locally with wallet.Sign().
  5. Submit with client.SubmitTxBlobAndWait(), or use client.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.

Packages

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

Guides and resources

Security and audits

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.

Contributing

Development setup, test commands, docs-site commands, and pull request guidance are in CONTRIBUTING.md.

Report an issue

If you find a bug or documentation gap, please open an issue in the XRPL-GO GitHub repository.

License

The xrpl-go library is licensed under the MIT License.

Directories

Path Synopsis
Package addresscodec provides base58 encoding and decoding functionality for XRPL addresses and keys.
Package addresscodec provides base58 encoding and decoding functionality for XRPL addresses and keys.
Package binarycodec provides encoding and decoding functionality for XRPL binary format.
Package binarycodec provides encoding and decoding functionality for XRPL binary format.
definitions
Package definitions contains XRPL binary codec field and type definitions.
Package definitions contains XRPL binary codec field and type definitions.
serdes
Package serdes provides utilities to parse and serialize XRPL binary data fields.
Package serdes provides utilities to parse and serialize XRPL binary data fields.
serdes/interfaces
Package interfaces defines interfaces for binary serialization and deserialization of XRPL fields.
Package interfaces defines interfaces for binary serialization and deserialization of XRPL fields.
serdes/testutil
Package testutil is a generated GoMock package.
Package testutil is a generated GoMock package.
types
Package types contains data structures for binary codec operations.
Package types contains data structures for binary codec operations.
types/interfaces
Package interfaces defines the BinaryParser interface for binary codec parsing operations.
Package interfaces defines the BinaryParser interface for binary codec parsing operations.
types/testutil
Package testutil is a generated GoMock package.
Package testutil is a generated GoMock package.
examples
autofill/rpc command
autofill/ws command
batch/rpc command
batch/ws command
checks/rpc command
checks/ws command
clawback/rpc command
clawback/ws command
credential/rpc command
credential/ws command
deep-freeze/rpc command
deep-freeze/ws command
delegate-set/ws command
faucet/rpc command
faucet/ws command
ledger/rpc command
ledger/ws command
mptoken/rpc command
mptoken/ws command
multisigning/ws command
nft/nft-burn/ws command
oracle/rpc command
oracle/ws command
paths/rpc command
paths/ws command
send-payment/ws command
send-xrp/rpc command
send-xrp/ws command
subscription/ws command
token-escrow/ws command
use-tickets/rpc command
use-tickets/ws command
vault/rpc command
vault/ws command
wallet command
Package keypairs provides cryptographic key pair generation and management for XRPL.
Package keypairs provides cryptographic key pair generation and management for XRPL.
testutil
Package interfaces is a generated GoMock package.
Package interfaces is a generated GoMock package.
pkg
big-decimal
Package bigdecimal provides arbitrary-precision decimal arithmetic operations for financial calculations.
Package bigdecimal provides arbitrary-precision decimal arithmetic operations for financial calculations.
crypto
Package crypto provides cryptographic utilities for XRPL key management, including Ed25519 and secp256k1 key derivation, signing, and verification.
Package crypto provides cryptographic utilities for XRPL key management, including Ed25519 and secp256k1 key derivation, signing, and verification.
decodehook
Package decodehook provides shared decode hooks for mapstructure.
Package decodehook provides shared decode hooks for mapstructure.
hexutil
Package hexutil provides utility functions for hexadecimal encoding.
Package hexutil provides utility functions for hexadecimal encoding.
map_utils
Package maputils provides utility functions for working with maps.
Package maputils provides utility functions for working with maps.
random
Package random provides cryptographically secure random number generation utilities.
Package random provides cryptographically secure random number generation utilities.
typecheck
Package typecheck provides functions for runtime type assertions and numeric string validation.
Package typecheck provides functions for runtime type assertions and numeric string validation.
Package xrpl provides utilities for working with the XRP Ledger.
Package xrpl provides utilities for working with the XRP Ledger.
currency
Package currency provides utilities for working with XRP native currency conversions and calculations.
Package currency provides utilities for working with XRP native currency conversions and calculations.
faucet
Package faucet provides utilities to interact with an XRP testnet faucet.
Package faucet provides utilities to interact with an XRP testnet faucet.
flag
Package flag provides utility functions for working with bitwise flags.
Package flag provides utility functions for working with bitwise flags.
hash
Package hash provides constants for prefixes used in hashing XRPL objects.
Package hash provides constants for prefixes used in hashing XRPL objects.
internal/client
Package client contains transport-independent client autofill policy.
Package client contains transport-independent client autofill policy.
internal/clientconfig
Package clientconfig contains shared helpers for XRPL client configuration.
Package clientconfig contains shared helpers for XRPL client configuration.
internal/clientconfig/testutil
Package testutil exposes helpers for tests that exercise clientconfig.
Package testutil exposes helpers for tests that exercise clientconfig.
ledger-entry-types
Package ledger defines types for ledger entries in the XRP Ledger.
Package ledger defines types for ledger entries in the XRP Ledger.
queries/account/types
Package types contains data structures for account query types.
Package types contains data structures for account query types.
queries/account/v1
Package v1 contains version 1 account queries for XRPL.
Package v1 contains version 1 account queries for XRPL.
queries/amm
Package amm contains amm-related queries for XRPL.
Package amm contains amm-related queries for XRPL.
queries/channel
Package channel provides commands to query XRPL payment channel methods.
Package channel provides commands to query XRPL payment channel methods.
queries/channel/v1
Package v1 contains version 1 payment channel queries for XRPL.
Package v1 contains version 1 payment channel queries for XRPL.
queries/clio
Package clio provides types and requests for CLIO-specific XRPL queries.
Package clio provides types and requests for CLIO-specific XRPL queries.
queries/clio/types
Package types contains data structures for CLIO server query types.
Package types contains data structures for CLIO server query types.
queries/clio/v1
Package v1 contains version 1 CLIO server queries for XRPL.
Package v1 contains version 1 CLIO server queries for XRPL.
queries/common
Package common provides shared types for XRPL ledger specifiers and parsing utilities.
Package common provides shared types for XRPL ledger specifiers and parsing utilities.
queries/ledger
Package ledger contains ledger-related queries for XRPL.
Package ledger contains ledger-related queries for XRPL.
queries/ledger/types
Package types contains types for ledger query responses.
Package types contains types for ledger query responses.
queries/ledger/v1
Package v1 contains version 1 ledger queries for XRPL.
Package v1 contains version 1 ledger queries for XRPL.
queries/nft
Package nft provides commands to query XRPL NFT-related methods.
Package nft provides commands to query XRPL NFT-related methods.
queries/nft/v1
Package v1 provides version 1 types and methods for NFT buy offers queries.
Package v1 provides version 1 types and methods for NFT buy offers queries.
queries/oracle
Package oracle contains oracle-related queries for XRPL.
Package oracle contains oracle-related queries for XRPL.
queries/oracle/types
Package types contains data structures for oracle query types.
Package types contains data structures for oracle query types.
queries/path
Package path contains path finding and order book queries for XRPL.
Package path contains path finding and order book queries for XRPL.
queries/path/types
Package types contains data structures for path finding query types.
Package types contains data structures for path finding query types.
queries/path/v1
Package v1 contains version 1 path finding queries for XRPL.
Package v1 contains version 1 path finding queries for XRPL.
queries/server
Package server contains server-related queries for XRPL.
Package server contains server-related queries for XRPL.
queries/server/types
Package types provides data structures for server query responses.
Package types provides data structures for server query responses.
queries/subscription
Package subscribe contains subscription functionality for XRPL streams.
Package subscribe contains subscription functionality for XRPL streams.
queries/subscription/types
Package types provides types for the subscription streams, including book changes events.
Package types provides types for the subscription streams, including book changes events.
queries/subscription/v1
Package v1 contains version 1 subscription functionality for XRPL streams.
Package v1 contains version 1 subscription functionality for XRPL streams.
queries/subscription/v1/types
Package types contains data structures for v1 subscription stream types.
Package types contains data structures for v1 subscription stream types.
queries/transactions
Package transactions contains transaction-related queries for XRPL.
Package transactions contains transaction-related queries for XRPL.
queries/transactions/v1
Package v1 contains version 1 transaction queries for XRPL.
Package v1 contains version 1 transaction queries for XRPL.
queries/utility
Package utility provides commands to query XRPL utility methods.
Package utility provides commands to query XRPL utility methods.
queries/utility/v1
Package v1 contains version 1 utility queries for XRPL.
Package v1 contains version 1 utility queries for XRPL.
queries/vault
Package vault contains vault-related queries for XRPL.
Package vault contains vault-related queries for XRPL.
queries/version
Package version defines API versions and version-related utilities for XRPL queries.
Package version defines API versions and version-related utilities for XRPL queries.
rpc
Package rpc provides RPC client functionality for interacting with XRPL servers.
Package rpc provides RPC client functionality for interacting with XRPL servers.
rpc/testutil
Package testutil provides utilities for mocking JSON-RPC HTTP clients in tests.
Package testutil provides utilities for mocking JSON-RPC HTTP clients in tests.
rpc/types
Package types contains data structures for RPC client configuration and options.
Package types contains data structures for RPC client configuration and options.
testutil
Package testutil provides utilities for testing JSON flattening and serialization.
Package testutil provides utilities for testing JSON flattening and serialization.
testutil/integration
Package integration provides configuration and utilities for running XRP Ledger integration tests.
Package integration provides configuration and utilities for running XRP Ledger integration tests.
time
Package time provides time conversion utilities for XRPL timestamps.
Package time provides time conversion utilities for XRPL timestamps.
transaction
Package transaction contains XRPL transaction types and related functionality.
Package transaction contains XRPL transaction types and related functionality.
transaction/integration
Package integration provides constants and utilities for transaction integration tests.
Package integration provides constants and utilities for transaction integration tests.
transaction/types
Package types provides core transaction types and helpers for the XRPL Go library.
Package types provides core transaction types and helpers for the XRPL Go library.
wallet
Package wallet provides utilities for deriving and managing XRPL wallets, including keypair generation, address derivation, and offline transaction signing.
Package wallet provides utilities for deriving and managing XRPL wallets, including keypair generation, address derivation, and offline transaction signing.
wallet/types
Package types contains data structures for wallet operations and batch signing.
Package types contains data structures for wallet operations and batch signing.
websocket
Package websocket provides a client for connecting to an XRPL WebSocket server.
Package websocket provides a client for connecting to an XRPL WebSocket server.
websocket/interfaces
Package interfaces defines common interfaces for XRPL WebSocket.
Package interfaces defines common interfaces for XRPL WebSocket.
websocket/testutil
Package testutil provides testing utilities for websocket functionality.
Package testutil provides testing utilities for websocket functionality.
websocket/types
Package types contains data structures for websocket message types.
Package types contains data structures for websocket message types.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL