It is recommended to install pnpm through the npm package manager, which comes bundled with Node.js when you install it on your system. It is recommended to use a Node.js version >=24.2.0.
Once you have npm installed, you can run the following both to install and upgrade pnpm:
npm install -g pnpmAfter having installed pnpm, simply run:
pnpm installNote
The deployment script deploy.ts attempts to automatically verify the contract on the target chain after deployment. If you have not configured an API key, the verification will fail.
Example Sepolia:
pnpm deploy:sepoliaThe deployment script
deploy.tsincludes thetenderlyHardhat Runtime Environment (HRE) extension with theverifymethod. Please consider uncommenting and configuring the Tenderlyproject,username,forkNetwork,privateVerification, anddeploymentsDirattributes in thehardhat.config.tsfile before deploying or remove this call. Also, for this plugin to function you need to create aconfig.yamlfile at$HOME/.tenderly/config.yamlor%HOMEPATH%\.tenderly\config.yamland add anaccess_keyfield to it. For further information, see here.
For the deployment on the ZKsync Era test network, you must add your to-be-deployed contract artifact to
deploy-zksync.ts, enablezksyncin thehardhat.config.tsfile, and then runpnpm compile(in case you face any compilation issues, disable all configurations associated with the@tenderly/hardhat-tenderlyplugin, including theimportstatement itself; see also here and here). Next, fund your deployer account on ZKsync Era Testnet, setup the ZKsync-related configuration variables accordingly, and simply runpnpm deploy:zksynctestnet. Eventually, to verify the contract you can invoke:npx hardhat verify --network zkSyncTestnet --constructor-args arguments.js <YOUR_CONTRACT_ADDRESS>. The same approach applies if you want to deploy on the production network, except that you need to runpnpm deploy:zksyncmainand use--network zkSyncMainfor the contract verification.
pnpm xdeployThis template uses the xdeployer Hardhat plugin. Check out the documentation for more information on the specifics of the deployments.
Run npx hardhat vars set PRIVATE_KEY to set the private key of your wallet. This allows secure access to your wallet to use with both testnet and mainnet funds during Hardhat deployments.
You can also run npx hardhat vars setup to see which other configuration variables are available.
This template implements the hardhat-ledger plugin. Run npx hardhat set LEDGER_ACCOUNT and enter the address of the Ledger account you want to use.
You can start an instance of the Hardhat network that forks the mainnet. This means that it will simulate having the same state as the mainnet, but it will work as a local development network. That way you can interact with deployed protocols and test complex interactions locally. To use this feature, you need to connect to an archive node.
This template is currently configured via the hardhat.config.ts as follows:
forking: {
url: vars.get("ETH_MAINNET_URL", ethMainnetUrl),
// The Hardhat network will by default fork from the latest mainnet block
// To pin the block number, specify it below
// You will need access to a node with archival data for this to work!
// blockNumber: 14743877,
// If you want to do some forking, set `enabled` to true
enabled: false,
},Change the contract address to your contract after the deployment has been successful. This works for both testnet and mainnet. You will need to get an API key from etherscan, snowtrace etc.
Example:
npx hardhat verify --network ethMain --constructor-args arguments.js <YOUR_CONTRACT_ADDRESS>This template includes an example script that shows how to interact programmatically with a deployed contract. You must customise it according to your contract's specifications. The script can be simply invoked via:
npx hardhat run scripts/interact.ts --network <network_name>This template repository also includes the Foundry toolkit as well as the @nomicfoundation/hardhat-foundry plugin.
If you need help getting started with Foundry, I recommend reading the 📖 Foundry Book.
make updateor
forge updatemake buildor
forge buildTo run only TypeScript tests:
pnpm test:hhTo run only Solidity tests:
pnpm test:forgeor
make test-forgeTo additionally display the gas report, you can run:
make test-gasreportInside the scripts/ folder are a few preconfigured scripts that can be used to deploy and verify contracts via Foundry. These scripts are required to be executable meaning they must be made executable by running:
make scripts