This tutorial takes you through the basics of sending your first operation on the XRP Ledger with simpleXRPL.
By the end of this tutorial, you will be able to:
- Construct a connector.
- Initialize a client.
- Discover your accounts.
- Transfer XRP between accounts.
To complete this tutorial, you should:
- Have some familiarity with writing code in TypeScript.
- Have Node.js version 20.19 or later.
You can find the complete source code for this tutorial's examples in the code samples section of this website's repository
npm install simplexrplA connector is a signing backend that determines how operations are executed and signed. This guide uses local signing with a LocalSigner constructor. This self-custody connector manages accounts and signs locally, making it ideal for testing and development.
// This Get Started sample walks through the basics of using simpleXRPL.
import { LocalSigner, SimpleXRPL } from 'simplexrpl'
// --- Construct a connector ---
// The LocalSigner constructor is a self-custody option that signs locally.
// Intended for testing and development.
const signer = LocalSigner.fromEnv()For production you'd construct a custodian connector instead and pass it to init in place of (or alongside) the local one. See Connectors for how to build each one; every vertical operation then works the same regardless of which connector owns the account.
Initializing an account binds connectors to a network and builds the account index.
// --- Initialize the client ---
const client = await SimpleXRPL.init({
xrpldUrl: 'wss://s.altnet.rippletest.net:51233',
faucetUrl: 'https://faucet.altnet.rippletest.net/accounts',
signers: [signer],
})signers[0]is the default primary account used for operations if not specified.- If you don't set a
signer, the client is read-only and you will receive aNoSignerErrorwhen attempting write operations.
Connectors discover their accounts at initialization, and the client merges them into a single index keyed by XRPL account address. List them, resolve the primary, and read on-chain state.
// --- Discover your accounts ---
// Connectors discover their accounts at init; the client merges them into one
// index keyed by XRPL address.
for (const [address, account] of client.accounts) {
console.log(`${address}: ${account.signer.kind}`)
}
// Get the primary account used to submit vertical operations.
// No args returns the primary account.
const primary = client.resolveAccount()
console.log(`primary: ${primary.address}`)
// Read an account's on-chain state. No args retrieves the primary account.
const state = await client.account.retrieve()
console.log(`balance (XRP): ${state.data.xrpBalance} | sequence: ${state.data.sequence}`)Operations are grouped into domain-specific verticals reached off the client. This guide sends XRP from the primary address to another. For a full list of vertical operations, see: Verticals.
// --- Send an XRP transfer ---
const result = await client.xrp.transfer({
to: 'rDestination00000000000000000000000',
amount: '10',
})
console.log(`submitted: ${result.txHash}`)
await client.disconnect()