Creating Test Accounts | XRPL Development in JavaScript - Level 3
Creating the Script
Create a new file called createAccounts.js in your project directory.
Paste the following code into createAccounts.js.
Running the Script
Run the following command in the command line to execute the script.
If successful, the console will display the following.
Make a note of the above information.
Creating an Environment Variables File
Using an environment variables file (.env) allows for efficient source management.
In this test project, it will be used to manage the secret keys of the accounts.
By managing it in a .env file, you can call the common account information across various sources.
Remember, in production-level projects, it is essential knowledge.
Installing the Library
Install the dotenv library.
Creating the .env File
Create a file called .env in the root of the project and define it as follows.
Note: It will not be visible by default in Finder or other file managers.
Creating wallets.js
Create a file called wallets.js in the root of the project and write the following source.
Create a script that generates account information from the .env defined above and exports it as an object.
Usage
You can use it as follows.
By doing this, you can call common account information across files with little effort.
I believe this will help you progress efficiently with your learning, and you can also apply this to your own product ideas.