Deployment overview
Hardhat’s flexibility allows you to deploy your smart contracts in multiple ways. We also provide an official deployment solution: Hardhat Ignition, which we strongly recommend.
In this section we’ll prepare the common setup and config to deploy and initialize a contract to Sepolia in the next two guides:
- First, using Hardhat Ignition
- Then, using a script
Required setup
Section titled “Required setup”Both guides assume you initialized a project based on viem or ethers using hardhat --init. If you didn’t, follow the Getting started guide first.
You’ll need access to a Sepolia RPC URL and an account with Sepolia ETH. We’ll set them up next.
Sepolia Network Config
Section titled “Sepolia Network Config”If you followed the Getting started guide, your config should look something like this:
// ... some imports ...
export default defineConfig({ // ... other config ... networks: { // ... other network config ... sepolia: { type: "http", chainType: "l1", url: configVariable("SEPOLIA_RPC_URL"), accounts: [configVariable("SEPOLIA_PRIVATE_KEY")], }, },});Make sure you have the sepolia section, highlighted above.
Storing the required secrets in the Hardhat Keystore
Section titled “Storing the required secrets in the Hardhat Keystore”If you haven’t done this while following another guide, store the values for SEPOLIA_RPC_URL and SEPOLIA_PRIVATE_KEY using the hardhat-keystore plugin to save them in an encrypted vault.
To do it, run:
npx hardhat keystore set SEPOLIA_RPC_URLpnpm hardhat keystore set SEPOLIA_RPC_URLyarn hardhat keystore set SEPOLIA_RPC_URLAfter entering your keystore password, you’ll be able to set the RPC URL.
Then run:
npx hardhat keystore set SEPOLIA_PRIVATE_KEYpnpm hardhat keystore set SEPOLIA_PRIVATE_KEYyarn hardhat keystore set SEPOLIA_PRIVATE_KEYto set a private key.
Next steps
Section titled “Next steps”With the setup in place, you can now:
-
Read Using Hardhat Ignition for a brief introduction to Ignition.
-
Read Using scripts to learn how to deploy using a script.