HollaEx®
⚙️ DashboardStart →
  • HollaEx® — The Crypto Exchange Solution
  • ☁️Cloud Operators
    • Launching the Exchange
    • Setting Domain for Cloud Exchanges
    • Easy SMTP for Cloud Exchanges
    • SEO Settings for Cloud Exchanges
      • SEO Advanced Settings
  • ⚙️Operating Your Exchange
    • Operator Control Panel
      • General
      • Users
      • User Profile
      • Assets
      • Markets
      • Stakes
      • Sessions
      • Plugins Apps
      • Trading Fees & Account Tiers
      • Roles
      • Chat
      • Billing
    • Customize Exchange
      • Browser Tools
        • Enter Edit Mode
        • Operator Controls (Visuals)
        • Console
      • Plugins
      • Forked Repo
    • Fiat Controls
      • Initial Setup
      • Setting Up Fiat On/ Off Ramp
      • Editing Deposit & Withdrawal Fees
      • Users Making Fiat Deposit
      • Users Trading With Fiat
      • User Making Fiat Withdrawal
    • Staking
    • OTC Broker
    • P2P
      • P2P Overview
      • P2P Setup
      • P2P Troubleshooting
      • P2P Vendor Flow
    • Smart Chain Trading
    • Assets & Trading Pairs
      • Add New Assets & Trading Pairs
      • Configure Pair Parameters
    • Set up the SMTP Email
      • Set up SMTP with AWS SES
      • Set up SMTP with Mailgun
      • Set up SMTP with SendGrid
      • Test the SMTP with Gmail
    • Enabling reCAPTCHA
    • Email Customization & Audit
    • DeFi Asset Staking Process
  • 🧩Plugins
    • HollaEx Plugins
      • Announcements
      • Bank
      • AWS SNS (Text Messages - SMS)
      • KYC
      • Automatic KYC
      • Messente
      • Advanced Referral
      • CoinMarketCap
      • Guardarian
    • Install Plugins
    • Developing Plugins
      • Development Walkthrough: Hello-Plugin
        • Initialization
        • Configuration
        • Scripting
        • Web View
        • The Final Product & Installation
      • Advanced
        • Initialization
        • Config
        • Server Script
        • Plugin Libraries
        • Web View
        • Final Plugin Product
        • Advanced Tutorial: Using the user meta field
        • Advanced Tutorial: Adding a new database table column
        • Advanced Tutorial: Creating a new database table
      • Simple Wallet Example
      • Web View Development
        • Overview
        • External dependencies
        • Getting started
        • Basic Tutorial: Hello Exchange Plugin web view
        • Advanced Tutorial: KYC Plugin web views
    • Bank Integration
      • Handling Deposits
      • Handling Withdrawals
  • 👷Developers
    • API Guide
      • API Example Scripts
    • Run Dev Mode
    • Build a New Front-end Interface
  • 🧰On-Premise Operators (Advanced Only)
    • On-Premise Exchange Setup
      • Getting Started — Requirements
      • Installation
      • Server Setup
      • Web Setup
      • Production
    • CLI How-Tos
      • Start Exchange
      • Stop Exchange
      • Upgrade Exchange
        • Build and Apply the Code Changes
      • Get Exchange Logs
      • Get a Backup and Restore
      • Exchange Migration
      • Command List
    • Run Exchange on Kubernetes
    • Troubleshooting Guide
  • 🚀Advanced
    • SEO Optimization
    • Nginx
    • Rate Limits
    • Database
      • Upgrade Database
    • Dependencies
    • Contents Delivery Network
      • Cloudflare CDN for HollaEx
      • CloudFront CDN for HollaEx
    • Load Balancer
      • AWS ELB
      • DigitalOcean LB
    • Customize Kubenretes Ingress
    • Exchange Keys
      • Exchange API Keys Troubleshoot
    • HollaEx on non-Linux
      • HollaEx on Windows
      • HollaEx on macOS
    • The Network Tool Library
      • Accessing the Network Tool Library
      • Functions
        • WebSocket
      • Simple Example: Creating a User and Wallet
      • Getting More Interesting: Orders with the Tools
        • Setup: Using the transferAsset function
        • Creating and Monitoring a Sell Order
        • Settling Fees
      • Private HollaEx Network
    • Docker Content Trust (DCT)
    • Revenue Sharing
  • 📦Releases
    • Release Notes
    • Side Notes
  • ➡️External Links
  • Blogs
  • Forum
  • Videos
  • Twitter X
  • Telegram
  • Interactive Demo
  • Discord Community
  • API Documentation
  • Tools Library Documentation
  • Node Library Documentation
  • Plugins Documentation
Powered by GitBook
On this page
  • The Code
  • The Output
  • Summary
  1. Advanced
  2. The Network Tool Library

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

To begin, we need to lay the groundwork that all our scripts using the Network Tools will have in common as discussed on the 'Accessing the Network Tool Library' page previously. Following this, the meat of our code is all performed in a single asynchronous function. Check the comments for an explanation of what each line does.

When using the createUser function, the newly added user will only exist on the HollaEx Network, and not the Exchange Kit itself. Check the note at the bottom of the list on the 'Functions' page for more details.

Some of the lines in the following code are not strictly necessary and have been addded just used to monitor the output of what we have done.

//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('hello4@gmail.com')
		
		//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

Running the above script through the terminal, in the scripts directory with node add-user-wallet.js gives the following output. Some unessential lines have been omitted for readability.

Check the comments for information on what this output is, and where it came from

//from the initial getUsers command (line 22), the following object is obtained 
//giving the IDs and all emails of the exchange's users
{ count: 22,
  data:
   [ { id: 161537, email: 'hello2@gmail.com' }, 
     { id: 161535, email: 'hello1@gmail.com' },
     //~~
     { id: 161045, email: 'test1@email.com' },
     { id: 161044, email: 'test@email.com' },
     
//following the createUser command (line 25) the string we input as a parameter 
//has now been used to add a new user, we can inspect our list by again getting 
//using getUsers (line 28)
{ count: 23,
  data:
   [ { id: 161582, email: 'hello4@gmail.com' }, //<-- The newely added user
     { id: 161537, email: 'hello2@gmail.com' },
     //~~
     { id: 161045, email: 'test1@email.com' },
     { id: 161044, email: 'test@email.com' },
     
//Using the getUser command (line 37) and supplying the newest user's ID, we can 
//inspect the deatails of this new user, before the btc address is added
{ id: 161582,
  email: 'hello4@gmail.com',
  balance:
   { btc_balance: 0,
     btc_available: 0,
     //~~
     xht_balance: 0,
     xht_available: 0 },
  wallet: [] } //<-- This user currently has no addresses
  
//following the createUserCryptoAddress and requesting it for btc and for this
//newest user (line 40) and then again using getUser (line 43) we can now see 
//the new address created
{ id: 161582,
  email: 'hello4@gmail.com',
  balance:
   { btc_balance: 0,
     btc_available: 0,
     //~~
     xht_balance: 0,
     xht_available: 0 },
  wallet:
   [ { currency: 'btc',
       address: '3FR4Ab7Gc1LgDWsELSvsgwYVp8AzaMtUsJ', //<-- newly created address
       network: 'btc',
       standard: null,
       is_valid: true,
       created_at: '2022-05-30T15:26:46.439Z' } ] }

Summary

This very simple example shows how with only two necessary functions, createUser and createUserCryptoAddress, we have been able to access the HollaEx crypto infrastructure with ease. This of course is only the start of what is possible with the Network Tools, and you are encouraged to try them out yourself and see what is possible!

PreviousWebSocketNextGetting More Interesting: Orders with the Tools

Last updated 2 years ago

🚀