Using Hardhat

Deploying a Smart Contract using Hardhat

INFO

If you'd like to deploy to mainnet, you'll modify the command like so:

npx hardhat run scripts/deploy.ts --network race-mainnet

Regardless of the network you're deploying to, if you're deploying a new or modified contract, you'll need to verify it first.


Verifying the Smart Contract

If you want to interact with your contract on the block explorer, you, or someone, need to verify it first. The above contract has already been verified, so you should be able to view your version on a block explorer already. For the remainder of this guide, we'll walk through how to verify your contract on the RACE™ Goerli testnet.

In hardhat.config.ts, configure RACE™ Goerli as a custom network. Add the following to your HardhatUserConfig:

  • RACEscan

etherscan: {
   apiKey: {
    "race-sepolia": "PLACEHOLDER_STRING"
   },
   customChains: [
     {
       network: "race-sepolia",
       chainId: 8900,
       urls: {
        apiURL: "https://testnet.racescan.io/api",
        browserURL: "
        https://testnet.racescan.io/"
       }
     }
   ]
 },

INFO

When verifying a contract with RACEscan on testnet (Sepolia), an API key is not required. You can leave the value as PLACEHOLDER_STRING.

npx hardhat verify --network race-sepolia <deployed address>

Interacting with the Smart Contract

If you verified on RACEscan, you can use the Read Contract and Write Contract tabs to interact with the deployed contract. You'll need to connect your wallet first, by clicking the Connect button.

Last updated