Key Management

In this article we will guide you through the key management strategy on the client side of your dApp on the PulseNet chain

Setup Web3

web3.js is a collection of JavaScript libraries that allow our client-side application to communicate with the blockchain. web3 has been configured to communicate via Metamask.

web3.js doc is here

Connect to PULSE network

				
					
    // mainnet 
     const web3 = new Web3(‘https://mainnet-rpcpulsenet.com’);
    // testnet
    const web3 = new Web3(‘https://testnet-rpcpulsenet.com’);

				
			

Set up account

If the installation and instantiation of web3 was successful, the following should successfully return a random account:

				
					    const account = web3.eth.accounts.create();

				
			

Recover account

Assuming you have created a copy of the private key for your account, this can later be used to restore your account.

				
					    const account = web3.eth.accounts.privateKeyToAccount("$private-key")

				
			

Full Example

				
					const Web3 = require('web3');
async function main() {

    const web3 = new Web3(‘https://mainnet-rpcpulsenet.com’);
    const loader = setupLoader({ provider: web3 }).web3;

    const account = web3.eth.accounts.create();
    console.log(account);
}
				
			

Table of contents