FONSmartChain
English
English
  • ๐ŸงฟIntroduce
  • ๐ŸงถTutorial
  • ๐Ÿ›ก๏ธSecurity Audit Report
  • ๐Ÿ’ซCross-chain bridges and wallets
    • โšกCross-chain bridge
    • ๐Ÿ’ฐWallet
    • ๐Ÿ”‘Key management
    • ๐Ÿ’ฐThird-Party Wallet Tutorial
      • 1๏ธโƒฃMetamask
      • 2๏ธโƒฃTokenPocket
      • 3๏ธโƒฃBitkeep
      • 4๏ธโƒฃAve.ai
  • ๐Ÿ†Core idea
    • ๐ŸŽ†Consensus engine
  • โ›ฑ๏ธDevelop
    • ๐ŸŸขRPC
    • ๐Ÿ”—FSC Browser
    • ๐ŸงŠRun full node
    • ๐Ÿ’ŽValidator
      • Create a validator
      • Run validator
    • ๐Ÿ“‘Validate contracts at FONSCAN
    • ๐ŸŒพLogos
  • โ˜”ScanApi
    • RPC API Endpoints
      • Account
      • Block
      • Contract
      • Logs
      • Stats
      • Token
      • Transaction
    • ETH RPC API
    • ๐Ÿ“”White Paper
      • Background overview
        • Introduction to FON smart chain
        • Design Principles
        • Application target
        • Advantages of implementation
      • Ecological sector overview
        • RosSwap
        • Time Farm
        • HieSwap
        • Myth NFT
      • Token economy
        • Economic model
        • Staking and governance
        • Circulation example
      • FSC technology systemFSC will
        • Proof of Stake
        • Cross-chain mechanism
        • Repeater
        • Hard forks, specifications and dispute resolution
      • Risk assessment and decision-making
      • Disclaimer
Powered by GitBook
On this page
  • FON setting Web3
  • Connect to the FSC network
  • Set up account
  • Recover account
  • Complete example
  1. Cross-chain bridges and wallets

Key management

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

PreviousWalletNextThird-Party Wallet Tutorial

Last updated 2 years ago

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

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);
}
๐Ÿ’ซ
๐Ÿ”‘
here