Deploy and verify with Hardhat Deploy and Catapulta

In this technical blog post you will learn about how to deploy smart contracts using Hardhat Deploy and Catapulta.

hardhat deploy verify Solidity smart contracts with Catapulta

What is Hardhat?

Hardhat is one of the most popular Solidity toolchains, allowing you to compile Solidity files, write tests and deployment scripts using Javascript and Typescript. With hundreds of plugins available, Hardhat is by far the most versatile and extensible toolchain available today.

What is Hardhat Deploy plugin?

Hardhat Deploy by @wighawag is one of the most popular deployment plugins, which allows to compose advanced deployment dependency graphs, and can even resume your deployment in case of a network failure. For example, the Aave V3 deployment orchestration is entirely made with hardhat-deploy, and without it, deploying dozens of smart contracts and coordinating all the proxies initialization would be impossible at that time.

What is Catapulta?

Catapulta solves a few pain points in Solidity development, like huge configuration boilerplate's for cross-chain deployments, failure of automated verifications resulting in manual and painful verifications in block explorers, or the need to pay multiple providers to enable cross-chain deployments in your project.

Catapulta is a zero config, multi-chain Solidity deployment tool, which allows to deploy smart contracts in +20 networks, be able to automatically verify all your smart contracts, and generate a deployment report which you can share with your users or clients, all of this without any RPC Providers or Etherscan API configuration.

All of this, by supporting Hardhat or Foundry deployment scripts.

Deploy smart contracts with Hardhat Deploy scripts and Catapulta CLI

Requirements

Before you begin, you need to install the following tools:

Deploy with Catapulta

For this tutorial, we will deploy a single smart contract, using Catapulta Hardhat template repository as a reference to deploy smart contracts in the Sepolia EVM network, an Ethereum testnet.

Hardhat Deploy allows you to deploy smart contracts with Javascript files, let's check the deploy/00_deploy_your_contract.ts file details:

const deployYourContract: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
 
  const { deployer } = await hre.getNamedAccounts();
  const { deploy } = hre.deployments;

  await deploy("YourContract", {
    from: deployer,
    // Contract constructor arguments
    args: [deployer],
    log: true,
    autoMine: true,
  });

};

export default deployYourContract;

deployYourContract.tags = ["YourContract"];

We see the script will just deploy a contract named YourContract, with a tag of the same name of the contract.

Let's deploy this Hardhat Deploy script with the following step by step guide:

  1. Clone this repo & install dependencies
# Clone and move to the repo
git clone https://github.com/catapulta-sh/catapulta-hardhat-template

cd catapulta-hardhat-template

# Install with Yarn
yarn install

# Go to the packages/hardhat directory
cd packages/hardhat
  1. Generate a new private key with Catapulta, is stored offline in your .env, or add your own as PRIVATE_KEY in the .env file stored at the root of the project
npx catapulta wallet

# Output:
# Wallet address: 0x6B193d5604e09f1737E33cFc4B06fb3f2C7fC3CE
# Private key appended to your .env file.
  1. Get funds for your Ethereum address at the Alchemy Sepolia faucet

  2. Sign up at Catapulta, follow the quick setup to create a project and generate a free CATAPULTA_API_KEY that must be stored in your .env file.

  3. Deploy the contract into Sepolia testnet with Catapulta

npx catapulta deploy --network sepolia

Output of the command:

Catapulta.sh 🏏 Hardhat deployment (0.2.6)
===========================================
Project name: Ghost Deployments
Project URL: https://catapulta.sh/project/6426272a59b37a3a4a7afb55
Deployment UUID: 6c7f65cb-52e0-459e-9b58-a5b3d51296f2

📀 Building artifacts...

🗜  Compressing artifacts...

📤 Uploading artifacts to the Catapulta DB...

✅ Artifacts uploaded successfully.

📡 Broadcasting deployments to Catapulta Gateway RPC:

📜 Running Hardhat script: yarn run hardhat --network catapulta-6c7465c2-52e0-459e-9b58-a5b3d5f296f2 deploy

deploying "YourContract"
 (tx: 0x9f4532ec9c34fed14d8295d0991d9935be194e582616a0660b6c51154204bf88)...
: deployed at 0xF31541a002a49bda9963caAcCeF3e25d0a09810e with 534015 gas

📝 Updated TypeScript contract definition file on ../nextjs/generated/deployedContracts.ts

✅ Deployment successfully broadcasted

- Etherscan verification request sent. Check the dashboard for keeping track verifications. If contracts are not verified in 10 minutes, contact support at Discord.

💾 Artifacts stored at:
- https://users-artifacts.s3.eu-west-1.amazonaws.com/1c7f65cb-52e0-459e-9b52-a5b3d5f296f2-deployment-artifacts/artifacts.zip

📸 Check your deployment report at:
 - https://catapulta.sh/project/14e6272a59b37a3a4a7afb55/op/627f25cb-52e0-459e-9b58-a5b3d5f296f2
  1. Check the deployment report at the Catapulta UI, and enjoy delegated Etherscan verification without any extra configs or Etherscan API keys.

Report Latest

Where are the RPC configs or Etherscan API keys stored?

Catapulta takes care of resolving the network name and routing your deployment script transactions into different RPC providers.

The Catapulta RPC Relay also detects if your transaction contains CREATE or CREATE2 instructions, and automatically sends verification requests to Etherscan or the network block explorer REST API, to simplify and automate smart contracts verification in complex nested deployments.

Catapulta deploy

Conclusion

Catapulta CLI allows you to deploy, verify, smart contracts using Hardhat Deploy to +20 networks without RPC configurations or Etherscan API keys, and automatically generate deployment reports, resulting in a better deployment experience with less boilerplate code.

Sign up with Catapulta today for free and enjoy a better Solidity development experience, with zero-config deployments, automated verifications in block explorers and deployment reports which you can share within your team, clients or users.