Skip to content

Deploying Contracts

Deploying contracts can be done with familiar EVM tools like Hardhat and Foundry. Make sure to configure these tools with the correct chain ID and RPC URL to deploy smart contracts to Zora Network Goerli and Zora Network Mainnet. See the Network section for more information.

Foundry

Setup

See the Foundry documentation to initialize your project with Foundry.

Deploying

To deploy smart contracts to Zora Network with Foundry, remember to use the --rpc-url and --chain-id flags with the correct values for the Zora network you are deploying to. For example, to deploy to Zora Goerli:

forge create src/MyContract.sol:MyContract --chain-id 999 --rpc-url https://testnet.rpc.zora.energy/ --private-key $PRIVATE_KEY 

You can use the same flags for more complicated deploy commands, such as with constructor arguments or a deploy script.

Verifying

To deploy and verify your contract in one command, use Foundry's verification flags configured with Blockscout and Zora Network's Blockscout API:

forge create src/MyContract.sol:MyContract --chain-id 999 --rpc-url https://testnet.rpc.zora.energy/ --private-key $PRIVATE_KEY --verify --verifier blockscout --verifier-url https://testnet.explorer.zora.energy/api\?

You can also verify a pre-existing contract with the forge verify-contract command using the same flags (--verifier and --verifier-url).

Note: Zora uses Blockscout which requires appending \? to the end of the API url like in the example above. More details here.

Alternatively, use Standard JSON Input to verify a pre-existing contract by appending the --show-standard-json-input option to forge verify-contract, creating a JSON file from the output and uploading that file to the Blockscout UI.

Hardhat

Setup

Refer to Hardhat's Quick Start guide to install Hardhat and initialize your project. To configure your project, add the Zora Network information in hardhat.config.js:

import { HardhatUserConfig } from 'hardhat/config';
import '@nomicfoundation/hardhat-toolbox';
 
require('dotenv').config();
 
const config: HardhatUserConfig = {
  solidity: {
    version: '0.8.17',
  },
  networks: {
    // for testnet
    'zora-goerli': {
      url: 'https://testnet.rpc.zora.energy/',
      accounts: [process.env.WALLET_KEY as string],
    },
    // for mainnet
    'zora-mainnet': {
      url: 'https://rpc.zora.energy/',
      accounts: [process.env.WALLET_KEY as string],
    },
  },
  defaultNetwork: 'hardhat',
};
 
export default config;

Deploying

Once you've configured your Hardhat project to work with Zora Network, you can proceed with the Hardhat guide to compile, test, and deploy your contracts.

Verifying

Zora Network uses Blockscout for chain exploration and contract verification. See Blockscout's Hardhat plugin guide to verify contracts with Hardhat and Blockscout.