Compiling the Smart Contract

Here’s a basic Counter smart contract implemented using the Solidity programming language:

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

contract Counter {
    uint256 public number;

    function setNumber(uint256 newNumber) public {
        number = newNumber;
    }

    function increment() public {
        number++;
    }
}

The Solidity code shown above declares a smart contract called Counter.

To compile the contract with Hardhat, execute the following command:

npx hardhat compile

Last updated