Deploy Contract to 0G Chain

Deploy Solidity contracts to 0G Chain with cancun compiler settings and ethers v6.

1|Updated Apr 1, 2026
One-click install
npx skills add https://github.com/Vocaid/vocaid-hub --skill deploy-contract-to-0g-chain
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Deploy Contract to 0G Chain
Source: https://github.com/Vocaid/vocaid-hub/tree/main/agents/.agents/shield/skills/chain/deploy-contract
Command: npx skills add https://github.com/Vocaid/vocaid-hub --skill deploy-contract-to-0g-chain

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Delivers hardened workflows for deploying Solidity contracts to 0G Chain so mismatched evmVersion settings, legacy ethers syntax, and missing verification steps no longer block releases.

Core Features & Use Cases

  • Cancun compiler enforcement: configure Hardhat or Foundry to compile every contract with evmVersion "cancun" and avoid invalid opcode errors.
  • Multi-framework deployment: run Hardhat scripts, Foundry commands, or raw ethers v6 factories with funded wallets, waitForDeployment checks, and balance logging before sending to mainnet.
  • Use Case: Ship a new OpenClaw agent contract by compiling, deploying to the 0G testnet, verifying the on-chain hash, and then promoting the verified address to production.

Quick Start

Compile your Solidity contract with evmVersion cancun, run a Hardhat or ethers v6 deployment using your funded wallet and RPC_URL, and confirm the verified address after waitForDeployment completes.

Frequently Asked Questions about Deploy Contract to 0G Chain

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I deploy a Solidity contract to 0G Chain without getting invalid opcode errors?

To deploy a Solidity contract to 0G Chain without invalid opcode errors, configure your Hardhat or Foundry compiler settings to enforce the evmVersion "cancun" before compilation. This ensures the bytecode matches the 0G Chain environment.

Does 0G Chain support contract deployment using Foundry and Hardhat?

Yes, 0G Chain supports contract deployment using both Foundry and Hardhat. The deployment workflow accommodates Foundry commands and Hardhat scripts, alongside raw ethers v6 factories, ensuring proper compilation and deployment execution.

Why does my ethers v6 contract deployment fail on the 0G testnet?

Your ethers v6 contract deployment on the 0G testnet may fail if you omit the waitForDeployment check, use legacy ethers syntax, or lack a funded wallet. Ensure PRIVATE_KEY and RPC_URL environment variables are correctly configured.

What environment variables do I need to verify a contract on 0G Chain?

To verify a contract on 0G Chain, you need the PRIVATE_KEY and RPC_URL environment variables configured for your funded wallet. You must also execute block explorer verification after the waitForDeployment method completes successfully.

What is the best way to configure a Hardhat project for 0G mainnet deployment?

The best way to configure a Hardhat project for 0G mainnet deployment is to set evmVersion to "cancun", use modern ethers v6 syntax, log wallet balances before sending transactions, and verify the on-chain hash post-deployment.