Skip to main content

Overview

Prophet’s smart contracts are already live on 0G Galileo. Use this guide if you need to deploy a fresh instance — for your own fork, a new environment, or mainnet deployment.
Current live deployment (0G Galileo, chain ID 16602):
  • ProphetFactory: 0xEd51e3d6Ba8914875616bBcDd9aa9D4A00B27bD4
  • LiquidityPool: 0x13AbE644693DA19f9A895C8c82Cf53879580DA8e
  • Mock USDT: 0xc2B0D2A7e858F13B349843fF87dBF4EBF9227F49
  • PositionVault: 0x89FAcA46A2782b4751F697ddFe0A0b9124Eb794E
  • PayoutDistributor: 0x238D341Bb358AC7C8Ae0A22b35897bECE97b9740

Prerequisites

  • Foundry installed (forge --version)
  • Deployer wallet funded with 0G gas (get from faucet.0g.ai)
  • Oracle agent wallet address (can be the same as deployer for testing)
  • Market-maker agent wallet address

1. Configure the Deploy Script

The deploy script lives at contracts/script/Deploy.s.sol. It reads from environment variables. Set up your contracts/.env:
The foundry.toml already has the 0G network profiles:

2. Build Contracts

Always build cleanly before deploying. This catches compilation errors early.
Expected output:
Check contract sizes (must all be under 24KB):

3. Dry Run First

Run without --broadcast to simulate the deployment and catch any errors without spending gas:
Inspect the simulation output. You should see 5 contract deployments in sequence with their constructor arguments.

4. Deploy to 0G Galileo Testnet

When the dry run looks correct, add --broadcast to execute:
The --legacy flag is required for 0G Chain — it does not support EIP-1559 transactions. Omitting it will cause deployment to fail with a transaction type error.
The script deploys in this order (the order matters due to contract dependencies):
1

Deploy MockUSDT

Mints 10,000,000 USDT to the deployer. Only used on testnet — on mainnet, point to real USDT.
2

Deploy ProphetFactory

Constructor arguments: USDT address, oracle agent address, market-maker agent address, treasury address.
3

Deploy LiquidityPool

Constructor arguments: ProphetFactory address, USDT address, market-maker agent address.
4

Deploy PositionVault

Constructor arguments: ProphetFactory address, oracle agent address, USDT address, PayoutDistributor address (set to zero address initially — updated in step 6).
5

Deploy PayoutDistributor

Constructor arguments: ProphetFactory address, PositionVault address, oracle agent address, market-maker agent address, treasury address, USDT address.
6

Wire contracts together

Calls factory.setVaultAndDistributor(vaultAddress, distributorAddress) and positionVault.setPayoutDistributor(distributorAddress) to complete the dependency cycle.

5. Copy Deployed Addresses

After deployment succeeds, Foundry prints all deployed addresses. Copy them from the terminal output:
Update all three environment files with these addresses:

6. Regenerate Frontend ABIs

The frontend reads contract ABIs from JSON files in frontendV2/src/lib/abis/. After deploying new contracts, regenerate them from the compiled artifacts:
Or manually copy from Foundry’s output:

7. Verify Contracts on 0G Explorer

Verifying source code lets anyone read the contract on the block explorer. 0G Galileo uses a Blockscout-compatible explorer.
Repeat for each contract. Verified contracts show a green checkmark on chainscan-galileo.0g.ai.

8. Fund Agent Wallets

Both agents need 0G gas to submit transactions. Get tokens from faucet.0g.ai for both wallet addresses. The market-maker agent also needs USDT in the LiquidityPool to seed markets. Transfer USDT to the LiquidityPool contract address, or call deposit() on LiquidityPool from the deployer wallet.

9. Start Agents

On startup, both agents:
  1. Verify they can connect to 0G Chain (reads current block)
  2. Verify 0G Storage connectivity (test upload/download)
  3. Scan for existing markets to catch up on missed events
  4. Begin listening for new events

Live Deployment Reference

Network details:
  • Chain ID: 16602
  • RPC: https://evmrpc-testnet.0g.ai
  • Explorer: https://chainscan-galileo.0g.ai
  • Native token: 0G (for gas)
  • Collateral: Mock USDT at address above (6 decimals)

Deploying to 0G Mainnet

For mainnet deployment, change the RPC and use real USDT:
On mainnet, do not deploy MockUSDT. Point contracts to the official USDT address on 0G Chain. Ensure USDT addresses use 6 decimal places throughout.
The mainnet compute provider for DeepSeek V3 is at 0x1B3AAe... — update COMPUTE_PROVIDER_ADDRESS in agent/.env accordingly.