Deploying the Smart Contract
After successfully compiling your contract, you can proceed to deploy it to the ICB Testnet.
To do so, update the ignition/modules/Counter.js
file in your project with the necessary deployment logic:
const { buildModule } = require("@nomicfoundation/hardhat-ignition/modules");
module.exports = buildModule("CounterModule", (m) => {
const initialNumber = m.getParameter("initialNumber", 0);
const counter = m.contract("Counter", []);
if (initialNumber !== 0) {
m.call(counter, "setNumber", [initialNumber]);
}
return { counter };
});
You'll also need to have testnet ICBT or ICBX tokens in your wallet. If you haven't obtained them yet, refer to the Prerequisites section. Without sufficient funds, the deployment will not succeed!
Once ready, execute the following command to deploy your Counter contract:
ICB Mainnet
npx hardhat ignition deploy ./ignition/modules/Counter.js --network ICBMainnet

ICB Testnet

The contract will be deployed to either the ICB Mainnet or ICB Testnet, depending on the network specified in your deployment command.
Once deployed, you can check the status and details of the contract using the appropriate block explorer β ICBScan Mainnet or ICBScan Testnet. Simply search for the contract address returned by your deploy script.
To interact with your contract via the block explorer, it must first be verified β either by you or someone else. Since the contract provided above is already verified, you should be able to view and interact with your deployed version right away.
Last updated