Using Hardhat

Follow until step 6 of the Hardhat tutorial

Write script deploy ./script/deploy.ts

import {task} from "hardhat/config";


task("deploy", "Deploy the contract", async (args, hre) => {
    const helloHyperasChain = await hre.ethers.getContractFactory("helloHyperasChain");
    const helloHyperasChainContract = await helloHyperasChain.deploy();
    await helloHyperasChainContract.deployed();
    console.log("helloHyperasChain deployed to:", helloHyperasChainContract.address);
})

Add Hyperas Chain testnet entries to hardhat.config.js file.


import { HardhatUserConfig, task } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "./scripts/deploy"; // import script verify


const privateKey = '<ADD_YOUR_PRIVATE_KEY_HERE>'
const apiKeyEthereum = '<YOUR_API_KEY>' // you can get api key from etherscan.io or bscscan.com
const config: HardhatUserConfig = {
  solidity: "0.8.9",
  networks: {
    hyperaschain_testnet: {
      url: "https://vayne.hyperaschain.com/",
      chainId: 140,
      accounts: [privateKey]
    }
  }
};

export default config;

Run deploy contract: Before deploy, you must sure your contracts already compile by run

npx hardhat compile

Finally run:

npx hardhat <YOUR_TASK> --network <YOUR_NETWORK>

Example

npx hardhat deploy --network hyperaschain_testnet // for testnet

Last updated