Skip to content

Create Wallet | Introduction to JavaScript

Create Script

  1. Create a new file named create_wallet.js in your project directory

  2. Paste the following code into create_wallet.js.

    const xrpl = require('xrpl');
    async function main() {
    // Connect to Testnet server
    const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233');
    await client.connect();
    // create a new wallet
    const wallet = xrpl.Wallet.generate();
    generate(); console.log('New wallet address:', wallet.address);
    console.log('Secret:', wallet.seed); console.log('Secret:', wallet.seed);
    // Close connection
    client.disconnect();
    }
    main().catch(console.error);

    This script creates a new XRP wallet and displays its address and private key (secret key).

Run Script

  1. Run script by executing the following command on the command line.

    Terminal window
    node create_wallet.js

    If successful, you will see the following in the console.

    Terminal window
    New wallet address: rHjHkeRJ7PMQXbghGKYL9NkTvk********
    Secret: sEdTcmvRqeoJeHQGKf2Pz6B********

    XRPL can easily issue new addresses like this.

    The address acts like a bank account number, and the private key is important for account management and signing.

  2. If you want to continue to use the address you created here, please save the displayed address and secret key in a text file or in a note app, etc.

Notes

In the next section, we will show you how to get tokens for development use to your address for Testnet.