FONSmartChain
English
Search
⌃K
🔑

Key management

This article is a guideline on client key management strategies for FON smart chain decentralized applications

FON setting Web3

web3.js is a JavaScript library that allows our client applications to talk to the blockchain. We configure web3 to communicate via Metamask.
web3.js doctor here​

Connect to the FSC network

// mainnet
const web3 = new Web3('https://fsc-dataseed1.fonscan.io:443');
​

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

If you backed up your account private key, you can use it to restore your account.
const account = web3.eth.accounts.privateKeyToAccount("$private-key")
​

Complete example

const Web3 = require('web3');
async function main() {
​
const web3 = new Web3('https://fsc-dataseed1.fonscan.io:443');
const loader = setupLoader({ provider: web3 }).web3;
​
const account = web3.eth.accounts.create();
console.log(account);
}