Deploying Contracts | ZORA Docs
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.

Tenderly

Tenderly is a full-stack Web3 development infrastructure that helps developers build, stage, test, and monitor decentralized applications. It provides Virtual TestNets for staging and testing in mainnet-like environments, debugging and simulation tools for transaction analysis, and real-time monitoring capabilities.

Use Tenderly Virtual TestNets to streamline user onboarding on Zora. Create hands-on onboarding experiences in a dedicated staging environment.

With Tenderly, you can:

Foundry deployment and verification

To deploy a contract to a Virtual TestNet with Foundry, use the --rpc-url flag with the Virtual TestNet RPC URL and the --etherscan-api-key flag with your Tenderly access token.

For example, to deploy and verify a Counter contract to a Virtual TestNet froom Foundry run the following command:

forge create Counter \
  --rpc-url $TENDERLY_VIRTUAL_TESTNET_RPC_URL \
  --etherscan-api-key $TENDERLY_ACCESS_TOKEN \
  --private-key $PRIVATE_KEY  \
  --verify \
  --verifier-url $TENDERLY_VIRTUAL_TESTNET_RPC_URL/verify/etherscan

Hardhat deployment and verification

To deploy and verify contracts to a Virtual TestNet from Hardhat add the following configuration to hardhat.config.ts and proceed with deployment as usual.

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import * as tdly from "@tenderly/hardhat-tenderly";
 
const config: HardhatUserConfig = {
  solidity: "0.8.19",
  networks: {
    tenderly_zora_virtual_testnet: {
      // your Tenderly TestNet RPC
      url: "https://virtual.zora.rpc.tenderly.co/872ac073-...",
      chainId: 735717777777
    }
  },
  tenderly: {
    username: "Your account slug",
    project: "Your project slug",
 
    // Mainnet contract verification visible only in Tenderly.
    // Omitting or setting to `false` makes it visible to the whole world.
    // Alternatively, configure verification visibility using
    // an environment variable `TENDERLY_PUBLIC_VERIFICATION`.
    privateVerification: process.env.TENDERLY_PUBLIC_VERIFICATION !== 'true',
  },
  etherscan: {
    apiKey: "YOUR_TENDERLY_API_KEY",
    customChains: [
      {
        network: "tenderly_zora_virtual_testnet",
        chainId: 735717777777,
        urls: {
          apiURL: `https://virtual.zora.rpc.tenderly.co/872ac073-.../verify/etherscan`,
          browserURL: "https://virtual.zora.rpc.tenderly.co/872ac073-..."
        }
      }
    ]
  },
};
 
export default config;

CI/CD with Github Actions