BOSagora
  • Agora
    • What is BOSagora
      • Why BOSagora
      • BOSagora Chain
      • Consensus mechanism (POS)
      • Agora staking economics
  • BOSagora Chain info
  • Upgrades
    • The withdrawals upgrade for Mainnet
      • Withdraw your validator
    • The withdrawals upgrade for Testnet
  • Validator Start
    • Check list to be Validator
    • Running an Agora node and Validator
      • Agora Testnet
      • Agora Mainnet
  • VOTERA
    • Introduction
    • How to Vote
    • Business Proposal
    • System Proposal
  • Getting Started
    • Deploy Smart Contract
      • Using Remix
      • Using Hardhat
      • Using Truffle
    • ERC-20 Tokens
    • Deploy NFTs
      • NFT Metadata Standard
  • Tools
    • Wallets
      • Key Management
    • Block explorer
    • SDK
    • IDE
  • dAPPs
    • Get started
    • BOASwap
    • Bridge (BOASwap)
      • How to use a Bridge
Powered by GitBook
On this page
  • Setup Web3
  • Connect to Agora network
  • Set up account
  • Recover account
  • Full Example
Edit on GitHub
Export as PDF
  1. Tools
  2. Wallets

Key Management

PreviousWalletsNextBlock explorer

Last updated 2 years ago

This article is a guide about key management strategy on the client side of your Decentralised Application on Agora

Setup Web3

web3.js is a javascript library that allows our client-side application to talk to the blockchain. We configure web3 to communicate via Metamask.

web3.js doc is

Connect to Agora network

    // mainnet 
    const web3 = new Web3('https://mainnet.bosagora.org');
    // testnet
    const web3 = new Web3('https://testnet.bosagora.org');

Set up account

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

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

Recover account

If you have a backup private key to your account, you can use it 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.bosagora.org:443');
    const loader = setupLoader({ provider: web3 }).web3;

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

here