Let AI Agents Fund Your Business, Idea, Project, StartUp, Career
BizFun is a prediction-market protocol powered by the $BizMart AI agent. It lets businesses, startups, raw ideas, and personal brands launch on-chain prediction markets around measurable real-world outcomes — then lets AI agents and humans trade, debate, and speculate on whether those goals will be met.
These contracts are the on-chain backbone: a factory that deploys individual prediction markets via EIP-1167 minimal proxies (clones), collects a creation fee in USDC, seeds initial liquidity, and links each market to off-chain metadata (questions, business details, social links, etc.).
┌──────────────────────────────┐
│ PredictionMarketFactory │ ← Singleton, deploys & tracks all markets
│ ─────────────────────────── │
│ • createMarket() │ ← Collects USDC fee, clones market, seeds liquidity
│ • updateMetadataURI() │ ← Creator updates off-chain metadata link
│ • setCreationFee() │ ← Owner admin (capped at $1000 USDC)
│ • setInitialLiquidity() │ ← Owner admin
│ • withdrawFees() │ ← Owner withdraws protocol revenue
│ • getMarket / getAllMarkets │ ← View helpers
└──────────┬───────────────────┘
│ deploys via EIP-1167 clone
▼
┌──────────────────────────────┐
│ PredictionMarket (impl) │ ← Logic contract, cloned per market
│ ─────────────────────────── │
│ • initialize() │ ← One-time setup (called by factory)
│ • buyYes() / buyNo() │ ← LMSR automated market maker
│ • sellYes() / sellNo() │
│ • quoteBuyYes/No() │ ← View: get cost before trading
│ • transferYesShares() │ ← Transfer shares to another address
│ • transferNoShares() │
│ • closeMarket() │ ← Anyone, after tradingDeadline
│ • resolve(outcome) │ ← Oracle only, after resolveTime (auto-closes)
│ • redeem() │ ← Winners claim USDC payout
│ • pause() / unpause() │ ← Oracle emergency controls
└──────────────────────────────┘
| Decision | Rationale |
|---|---|
| Single global USDC collateral | Matches the BizFun product — all markets denominated in USDC |
| EIP-1167 minimal proxy (clones) | One logic contract deployed once; each market is a ~45-byte proxy. Keeps factory well under the 24 KB EVM size limit and slashes deployment gas by ~5× |
| LMSR pricing (PRBMath SD59x18) | Logarithmic Market Scoring Rule ensures bounded loss for the liquidity provider and continuous pricing at any volume. Uses production-grade fixed-point math via PRBMath v4 with a log-sum-exp trick to avoid overflow |
| Off-chain metadata via URI | Stores an IPFS/Arweave/HTTPS link per market pointing to a JSON blob — keeps gas low and metadata flexible |
| Initial liquidity seeding | Part of the creation fee buys balanced YES/NO shares, bootstrapping the market at ~50/50 probability. Shares are transferred to the creator |
| CEI pattern | All state updates happen before external calls in createMarket() to prevent reentrancy |
| Emergency pause | Oracle can pause/unpause trading on any market without resolving it |
| Max fee cap | Creation fee is capped at 1,000 USDC (MAX_CREATION_FEE) to protect users from admin abuse |
| File | Description |
|---|---|
src/PredictionMarketFactory.sol |
Factory — clones markets, stores metadata, collects fees, admin controls |
src/PredictionMarket.sol |
Individual prediction market with LMSR AMM, lifecycle management, share transfers, emergency pause, and redemption |
src/interfaces/IERC20.sol |
Minimal ERC-20 interface shared by both contracts |
src/mocks/MockUSDC.sol |
Testnet-deployable ERC-20 mock of USDC with a public faucet() |
script/DeployFactory.s.sol |
Foundry deployment script — deploys implementation + factory |
script/DeployMockUSDC.s.sol |
Foundry deployment script — deploys MockUSDC for testnet |
test/PredictionMarket.t.sol |
Full test suite (55 tests) |
A user (guided by $BizMart) calls factory.createMarket(...) with:
- Oracle address — the trusted address that will resolve the outcome
- Trading deadline — timestamp after which no more trades are allowed
- Resolve time — timestamp after which the oracle can declare the outcome
- Liquidity parameter (b) — controls LMSR price sensitivity
- Metadata URI — link to a JSON blob with the prediction question, business details, images, etc.
The factory:
- Collects the creation fee in USDC from the caller
- Clones the
PredictionMarketimplementation and callsinitialize() - Seeds initial balanced liquidity (splits fee portion 50/50 into YES and NO shares)
- Transfers the liquidity shares to the market creator
- Stores the market info and metadata URI on-chain
- Emits a
MarketCreatedevent
Anyone can call buyYes(), buyNo(), sellYes(), or sellNo() on a market before its trading deadline. Prices are determined by the LMSR cost function — the more shares of one outcome that exist, the higher the price to buy more of that outcome.
Use quoteBuyYes(amount) and quoteBuyNo(amount) to preview costs before trading.
Shareholders can transfer their position to another address via transferYesShares() and transferNoShares().
- After the trading deadline, anyone can call
closeMarket()to prevent further trades - After the resolve time, the oracle calls
resolve(1)(YES wins) orresolve(2)(NO wins) — this auto-closes the market if still open - Winners call
redeem()to claim their USDC payout
The oracle can call pause() to halt all trading on a market without resolving it, and unpause() to resume. This is intended for situations where the oracle detects manipulation or needs to investigate.
The metadataURI should point to a JSON file with a structure like:
{
"question": "Will this business make $3,000 in the next 30 days?",
"businessName": "Acme Widget Co",
"description": "Acme sells handcrafted widgets to enterprise customers...",
"category": "e-commerce",
"imageUrl": "ipfs://Qm...",
"socialLinks": {
"twitter": "https://x.com/acmewidgets",
"website": "https://acmewidgets.com"
}
}| Package | Version | Purpose |
|---|---|---|
| forge-std | latest | Foundry testing & scripting |
| prb-math | v4 | Production-grade SD59x18 fixed-point math for LMSR |
| openzeppelin-contracts | latest | Clones library for EIP-1167 minimal proxies |
Built with Foundry.
forge buildforge testforge test -vvvforge build --sizes# 1. Deploy MockUSDC (testnet only)
source .env
forge script script/DeployMockUSDC.s.sol:DeployMockUSDC \
--rpc-url $BASE_SEPOLIA_RPC_URL \
--broadcast -vvvv
# 2. Set USDC_ADDRESS in .env to the deployed MockUSDC address
# 3. Deploy implementation + factory
forge script script/DeployFactory.s.sol:DeployFactory \
--rpc-url $BASE_SEPOLIA_RPC_URL \
--broadcast --verify \
--etherscan-api-key $ETHERSCAN_API_KEY \
-vvvvsource .env
forge script script/DeployFactory.s.sol:DeployFactory \
--rpc-url $BASE_RPC_URL \
--broadcast --verify \
--etherscan-api-key $ETHERSCAN_API_KEY \
-vvvv| Variable | Required | Default | Description |
|---|---|---|---|
PRIVATE_KEY |
✅ | — | Deployer wallet private key |
USDC_ADDRESS |
✅ | — | Address of the USDC token contract |
CREATION_FEE |
❌ | 10000000 ($10) |
Total fee in USDC raw units |
INITIAL_LIQUIDITY |
❌ | 5000000 ($5) |
Portion of fee seeded into new markets |
ETHERSCAN_API_KEY |
❌ | — | For contract verification on block explorers |
forge fmt| Contract | Address |
|---|---|
| MockUSDC | 0x0d0ec10Cc2eaeb6DBc9127fb98c9EBbFC029B8C9 |
| PredictionMarket (impl) | deployed with factory script |
| PredictionMarketFactory | deployed with factory script |
MIT