

Autofill, sign, submit
The library fills the fields. You sign on your device, then wait.
Key points
- autofill adds Fee, Sequence and LastLedgerSequence for you.
- wallet.sign works on your device. Only the signed blob is sent.
- submitAndWait returns once a validated ledger holds the result.
The lesson
Sending a transaction in code takes three steps.
- . You write the parts you care about: who, to whom, how much. The library fills in the rest. It asks a server for your next and the going fee. It also sets a deadline.
- Sign. Your wallet signs the finished form on your own device. The secret key never leaves it. Out comes a signed blob, a long string of letters and numbers.
- Submit and wait. The library sends the blob, then checks each new ledger. It stops when a holds the result, or the deadline passes.
Then read the .
tesSUCCESSmeans it worked. A code starting withtecmeans it failed, but the fee was still spent.Amounts in XRP go in . One XRP is a million drops. A helper does the math.
import { xrpToDrops } from "xrpl" const tx = await client.autofill({ TransactionType: "Payment", Account: wallet.address, Destination: destination, // an r-address you choose Amount: xrpToDrops("1"), // "1000000" }) const signed = wallet.sign(tx) // local: { tx_blob, hash } const res = await client.submitAndWait(signed.tx_blob) console.log(res.result.meta.TransactionResult) // "tesSUCCESS"signreturnstx_blobandhash. Keep the hash: it finds the transaction later.submitAndWaitsubmits, then checkstxabout once a second. It resolves when the result is in a validated ledger, withvalidated: true. It also resolves on ateccode, so always readmeta.TransactionResult. If the ledger passesLastLedgerSequencefirst, it throws. Only then is a new signature safe.client.submit()sends without waiting. Itsengine_resultis only preliminary.Related: From signed to final, Sending XRP.

