Build with xrpl.js· 2 of 4

Connect and make a wallet

Open a connection, then get a test wallet. Keep every real secret out of code.

4 minMedium

Key points

  • One Client connects to one server over a WebSocket.
  • fundWallet gives a throwaway Testnet wallet with test XRP.
  • Never paste a real secret into code. Load test seeds from outside.

The lesson

  1. A program talks to the ledger through a server. In , a Client holds that connection. It stays open, like a phone call, so answers and news can flow both ways.

  2. Next you need a wallet: a and its . On , the can make one for you and fill it with test XRP. Use it, then throw it away.

  3. A wallet comes from a , a secret string that starts with "s". Anyone with the seed controls the account.

  4. So never paste a real seed into code. Code gets shared, copied and pushed online. Bots scan public code for secrets all day.

  5. For practice, use faucet wallets. If a program must reuse a test wallet, load its seed from outside the code. For real money, let a wallet app like Xaman or Joey do the signing.

Check yourself2 questions
1. Where should a program get its seed from?
2. What does client.fundWallet() do on Testnet?
Next lessonAutofill, sign, submit