# Key management

### FON setting Web3 <a href="#setup-web3" id="setup-web3"></a>

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](https://web3js.readthedocs.io/en/v1.2.2/getting-started.html#adding-web3-js)

### Connect to the FSC network <a href="#connect-to-bsc-network" id="connect-to-bsc-network"></a>

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

### Set up account <a href="#set-up-account" id="set-up-account"></a>

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 <a href="#recover-account" id="recover-account"></a>

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 <a href="#full-example" id="full-example"></a>

```
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);
}
```
