Skip to main content

Documentation Index

Fetch the complete documentation index at: https://prophet.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

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:
# contracts/.env
PRIVATE_KEY=0x...your_deployer_private_key
ORACLE_AGENT_ADDRESS=0x...oracle_wallet_address
MM_AGENT_ADDRESS=0x...market_maker_wallet_address
TREASURY_ADDRESS=0x...treasury_wallet_address  # where protocol fees go

# RPC endpoints
OG_TESTNET_RPC=https://evmrpc-testnet.0g.ai
OG_MAINNET_RPC=https://evmrpc.0g.ai
The foundry.toml already has the 0G network profiles:
[rpc_endpoints]
og_testnet = "${OG_TESTNET_RPC}"
og_mainnet = "${OG_MAINNET_RPC}"

2. Build Contracts

Always build cleanly before deploying. This catches compilation errors early.
cd contracts
forge build
Expected output:
Compiling 22 files with 0.8.20
Compilation succeeded!
Check contract sizes (must all be under 24KB):
forge build --sizes

3. Dry Run First

Run without --broadcast to simulate the deployment and catch any errors without spending gas:
cd contracts
forge script script/Deploy.s.sol:DeployProphet \
  --rpc-url og_testnet \
  --legacy \
  --gas-price 3000000000 \
  -vvv
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:
cd contracts
forge script script/Deploy.s.sol:DeployProphet \
  --rpc-url og_testnet \
  --broadcast \
  --legacy \
  --gas-price 3000000000 \
  -vvv
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:
== Return ==
ProphetFactory deployed at: 0x...
LiquidityPool deployed at: 0x...
MockUSDT deployed at: 0x...
PositionVault deployed at: 0x...
PayoutDistributor deployed at: 0x...
Update all three environment files with these addresses:
PROPHET_FACTORY_ADDRESS=0x...
LIQUIDITY_POOL_ADDRESS=0x...
MOCK_USDT_ADDRESS=0x...
POSITION_VAULT_ADDRESS=0x...
PAYOUT_DISTRIBUTOR_ADDRESS=0x...

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:
# From the project root
node scripts/copy-abis.js
Or manually copy from Foundry’s output:
cp contracts/out/ProphetFactory.sol/ProphetFactory.json frontendV2/src/lib/abis/
cp contracts/out/MarketContract.sol/MarketContract.json frontendV2/src/lib/abis/
cp contracts/out/LiquidityPool.sol/LiquidityPool.json frontendV2/src/lib/abis/
cp contracts/out/PositionVault.sol/PositionVault.json frontendV2/src/lib/abis/
cp contracts/out/PayoutDistributor.sol/PayoutDistributor.json frontendV2/src/lib/abis/

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.
forge verify-contract \
  --chain-id 16602 \
  --verifier blockscout \
  --verifier-url https://chainscan-galileo.0g.ai/api \
  <DEPLOYED_ADDRESS> \
  src/ProphetFactory.sol:ProphetFactory
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

cd agent
npm run start
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

ContractAddressExplorer
ProphetFactory0xEd51e3d6Ba8914875616bBcDd9aa9D4A00B27bD4View
LiquidityPool0x13AbE644693DA19f9A895C8c82Cf53879580DA8eView
Mock USDT0xc2B0D2A7e858F13B349843fF87dBF4EBF9227F49View
PositionVault0x89FAcA46A2782b4751F697ddFe0A0b9124Eb794EView
PayoutDistributor0x238D341Bb358AC7C8Ae0A22b35897bECE97b9740View
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:
forge script script/Deploy.s.sol:DeployProphetMainnet \
  --rpc-url og_mainnet \
  --broadcast \
  --legacy \
  --gas-price 3000000000 \
  -vvv
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.