# Deploy and verify an ERC-20 token

### Step 1

First we’re going to create a new folder and install hardhat:

```bash
$ mkdir mock-token$ cd mock-token
$ npm init
$ npm install --save-dev hardhat
```

Now let’s bootstrap a hardhat project. Select the option "Create an empty hardhat.config.js":

```bash
$ npx hardhat 
```

Let’s also create a couple of folders for our files:

```
$ mkdir scripts contracts
```

Now install some dependencies to our project:

```bash
$ npm install --save-dev @nomiclabs/hardhat-ethers ethers @nomiclabs/hardhat-waffle ethereum-waffle chai
$ npm install --save-dev @nomiclabs/hardhat-etherscan
```

### &#x20;Step 2

Let’s now create a first Solidity contract at *contracts/Token.sol*:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.2;
 
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
 
contract MockToken is ERC20 {
    constructor() ERC20("Mock Token", "Mock") {
        _mint(msg.sender, 1000000 * 10**decimals());
    }
}
```

We need to install *openzeppelin* library to our file:

```bash
$ npm install @openzeppelin/contracts
```

Try to compile the contract with:

```bash
$ npx hardhat compile
```

### Step 3

We should prepare our *hardhat.config.js* file as:

```javascript
require("@nomiclabs/hardhat-etherscan");
require("@nomiclabs/hardhat-waffle");
 
const PRIVATE_KEY = "PRIVATEKEY";
 
module.exports = {
    solidity: "0.8.2",
    defaultNetwork: "fuji",
    networks: {
      mainnet: {
        url: `https://api.avax.network/ext/bc/C/rpc`,
        accounts: [PRIVATE_KEY]
      },
      fuji: {
        url: `https://api.avax-test.network/ext/bc/C/rpc`,
        accounts: [PRIVATE_KEY]
      }
    },
    etherscan: {
      apiKey: {
        fuji: "avascan" // apiKey is not required, just set a placeholder
      },
      customChains: [
        {
          network: "fuji",
          chainId: 43113,
          urls: {
            apiURL: "https://api.avascan.info/v2/network/testnet/evm/43113/etherscan",
            browserURL: "https://testnet.avascan.info/blockchain/c"
          }
        }
      ]
    },
};
```

### Step 4

Now let’s add the deploy script. To keep it simple we’ll simply reuse the deploy script from the Hardhat tutorial, so let’s create the file *scripts/deploy.js*:<br>

```javascript
const { ethers } = require("hardhat");
 
async function main() {
    const [deployer] = await ethers.getSigners();
 
    const Token = await ethers.getContractFactory("MockToken");
    const token = await Token.deploy();
    console.log("Contract address:", token.address);
}
 
main()
    .then(() => process.exit(0))
    .catch((error) => {
        console.error(error);
        process.exit(1);
    });
```

After wrote our script, we can call deploy file:

<pre class="language-bash"><code class="lang-bash"><strong>$ npx hardhat run scripts/deploy.js --network fuji
</strong><strong>$ npx hardhat verify --contract contracts/Token.sol:MockToken --network fuji &#x3C;contractaddress>
</strong></code></pre>

<figure><img src="https://lh6.googleusercontent.com/6AtMTs6deCbDhbM_nX65Q6VpEa3xxmcETKT3Rd8KsYumC7m83XrLLEuMLmd3BzF9zlZf3SxHpVs0Y76Sp5ozUhdSXG-157cHvkk3yAOUckRcbTOeep4qPsRy-t6beor5rleKfjyTb01wM2f4FKTLt8UrR8d0aZiHB2WESFAZagIhIu3z04DrHgf1w9qO5A" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.avascan.info/tutorial/deploy-and-verify-an-erc-20-token.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
