Skip to main content

Deploy with Hardhat

Use Hardhat 3 with a supported Node.js release and a Tanenbaum account funded with tSYS. The example uses Ignition for deployment and Hardhat's encrypted keystore for signing credentials.

Create the project​

mkdir hello-nevm-hardhat
cd hello-nevm-hardhat
npm init -y
npm pkg set type=module
npm install --save-dev 'hardhat@^3' '@nomicfoundation/hardhat-ignition@^3' \
'@nomicfoundation/hardhat-keystore@^3'
mkdir -p contracts ignition/modules

Create hardhat.config.ts. The HTTP network specifies chain ID 5700 and reads its signer from the keystore. Hardhat network configuration · Hardhat keystore

import hardhatIgnition from "@nomicfoundation/hardhat-ignition";
import hardhatKeystore from "@nomicfoundation/hardhat-keystore";
import { configVariable, defineConfig } from "hardhat/config";

const compiler = { version: "0.8.28", settings: { evmVersion: "paris" } };

export default defineConfig({
plugins: [hardhatIgnition, hardhatKeystore],
solidity: { profiles: { default: compiler, production: compiler } },
networks: {
nevmTestnet: {
type: "http",
chainType: "l1",
chainId: 5700,
url: "https://rpc.tanenbaum.io",
accounts: [configVariable("NEVM_TESTNET_PRIVATE_KEY")],
},
},
chainDescriptors: {
5700: {
name: "Syscoin NEVM Tanenbaum",
blockExplorers: {
blockscout: {
name: "Syscoin NEVM Tanenbaum Explorer",
url: "https://explorer.tanenbaum.io",
apiUrl: "https://explorer.tanenbaum.io/api",
},
},
},
},
});

Save this contract as contracts/HelloNEVM.sol.

// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;

contract HelloNEVM {
function sayHello() external pure returns (string memory) {
return "Hello NEVM!";
}
}

Create ignition/modules/HelloNEVM.ts to declare the deployment. Ignition module guide

import { buildModule } from "@nomicfoundation/hardhat-ignition/modules";

export default buildModule("HelloNEVMModule", (m) => {
const hello = m.contract("HelloNEVM");
return { hello };
});

Build and deploy on Tanenbaum​

Build with the production profile and confirm your RPC reports 0x1644 using the NEVM chain-ID check. The explicit Paris bytecode target applies to both profiles. Add the private key for your disposable test account when the keystore prompts you. Hardhat build profiles

npx hardhat build --build-profile production
npx hardhat keystore set NEVM_TESTNET_PRIVATE_KEY

The following command submits the deployment and spends tSYS for gas. Save the address printed by Ignition.

npx hardhat ignition deploy ignition/modules/HelloNEVM.ts \
--network nevmTestnet --build-profile production

Verify on Blockscout​

Set contract to the deployed address. Verification publishes the source code and compiler settings through the explorer's API. Use the same build profile as the deployment. Hardhat Blockscout verification

npx hardhat verify blockscout "$contract" --network nevmTestnet \
--build-profile production

Open the address in the Syscoin NEVM testnet explorer, where the verified contract's read interface can call sayHello().