Hardhat with Nahmii
To compile the correct bytecode to work with the Nahmii virtual machine, the hardhat-ovm dependency is required due to the differences between certain opcodes in the EVM and the NVM.
    1.
    Install the OVM hardhat plugin.
    1
    yarn add @eth-optimism/hardhat-ovm
    Copied!
    2.
    Edit hardhat.config.js to use the OVM package.
    1
    // hardhat.config.js
    2
    require("@nomiclabs/hardhat-waffle");
    3
    require('@eth-optimism/hardhat-ovm')
    4
    5
    ...
    Copied!
    3.
    In the same file, add nahmii to the list of networks. Note: Update the accounts fields to fit your personal setup.
    1
    ...
    2
    3
    module.exports = {
    4
    solidity: "0.7.6",
    5
    networks: {
    6
    nahmii: {
    7
    url: 'https://l2.testnet.nahmii.io/',
    8
    accounts: { mnemonic: 'test test test test test test test test test test test junk' },
    9
    gasPrice: 15000000,
    10
    ovm: true
    11
    }
    12
    }
    13
    };
    Copied!
    4.
    To test contracts on the live Nahmii L2, compile it with hardhat.
    1
    npx hardhat --network nahmii test
    Copied!
    5.
    To interact with the smart contracts manually, use the console. The JavaScript console can be ran with the following command.
    1
    npx hardhat --network nahmii console
    Copied!
    6.
    To deploy to Nahmii, write a deploy script for Hardhat (https://hardhat.org/guides/deploying.html) and run the following command.
    1
    npx hardhat --network nahmii scripts/deploy.js
    Copied!
Last modified 8h ago
Copy link