Create Wallet | Introduction to JavaScript
Create Script
-
Create a new file named
create_wallet.js
in your project directory -
Paste the following code into
create_wallet.js
.const xrpl = require('xrpl');async function main() {// Connect to Testnet serverconst client = new xrpl.Client('wss://s.altnet.rippletest.net:51233');await client.connect();// create a new walletconst wallet = xrpl.Wallet.generate();generate(); console.log('New wallet address:', wallet.address);console.log('Secret:', wallet.seed); console.log('Secret:', wallet.seed);// Close connectionclient.disconnect();}main().catch(console.error);This script creates a new XRP wallet and displays its address and private key (secret key).
Run Script
-
Run script by executing the following command on the command line.
Terminal window node create_wallet.jsIf 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.
-
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.