Simple Example: Creating a User and Wallet
In this walk-through, we will see how in a matter of a few commands we can set up the means to add a user to the HollaEx network and then create a Bitcoin wallet for them.
The Code
//using the index file, get access to the functions we will be using throughout
//Note: make sure the index file is pointed in the correct relative folder to this
//script
const Network = require('../index');
const network = new Network({
apiUrl: 'https://api.hollaex.network',
apiKey: '<YOUR_API_KEY>',
apiSecret: '<YOUR_API__SECRET_KEY>',
activation_code: '<YOUR_ACTIVATION_CODE>',
});
//main function for adding user and their address
(async () => {
try {
//initialise the network
const init = await network.init();
//check user list before addition of new user
console.log(await network.getUsers())
//create new user
await network.createUser('[email protected]')
//compare our list with the new user added
console.log(await network.getUsers())
//store this list in variable
let newUserList = await network.getUsers()
//get the newest (first) item in this array
let newestUser = newUserList.data[0]
//See our new users information before adding a crypto wallet
console.log(await network.getUser(newestUser.id))
//create btc address for the newest user
await network.createUserCryptoAddress(newestUser.id, 'btc')
//compare user data now with a btc wallet address
console.log(await network.getUser(newestUser.id))
} catch (err) {
console.log(err)
}
}) ();The Output
Summary
Last updated