Build with xrpl.js· 3 of 4

Autofill, sign, submit

The library fills the fields. You sign on your device, then wait.

5 minMedium

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

  1. Sending a transaction in code takes three steps.

    1. . 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.
    2. 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.
    3. Submit and wait. The library sends the blob, then checks each new ledger. It stops when a holds the result, or the deadline passes.
  2. Then read the . tesSUCCESS means it worked. A code starting with tec means it failed, but the fee was still spent.

  3. Amounts in XRP go in . One XRP is a million drops. A helper does the math.

Check yourself3 questions
1. Which step needs the secret key?
2. submitAndWait returns tecUNFUNDED_PAYMENT. What happened?
3. How much XRP is xrpToDrops("1")?
Next lessonRead and listen