Key Management
This article is a guide about key management strategy on client side of your Decentralized Application on DND
web3.js
is a javascript library that allows our client-side application to talk to the blockchain. We configure web3 to communicate via Metamask. // mainnet
const web3 = new Web3('https://mainnet-rpc.dynoscan.io');
// testnet
const web3 = new Web3('https://testnet-rpc.dynoscan.io');
If the installation and instantiation of web3 was successful, the following should successfully return a random account:
const account = web3.eth.accounts.create();
If you have backup the private key of your account, you can use it to restore your account.
const account = web3.eth.accounts.privateKeyToAccount("$private-key")
const Web3 = require('web3');
async function main() {
const web3 = new Web3('https://mainnet-rpc.dynoscan.io');
const loader = setupLoader({ provider: web3 }).web3;
const account = web3.eth.accounts.create();
console.log(account);
Last modified 11mo ago