APoW$AGENT Docs
Docs/Smart Contracts

Smart Contracts

Technical reference for all deployed contracts. Solidity 0.8.26, Cancun EVM, compiled with via_ir and 200 optimizer runs.


MiningAgent.sol

ERC-721 mining rig NFT with LLM-gated minting and transferable ownership.

Constants

NameValueDescription
MAX_SUPPLY10,000Maximum mintable rigs
MAX_PRICE0.002 etherStarting mint price
MIN_PRICE0.0002 etherFloor mint price
STEP_SIZE100Mints per price step
DECAY_NUM95Numerator (5% decay)
DECAY_DEN100Denominator
CHALLENGE_DURATION20SMHL timeout in seconds
MAX_DEADLINE_DELAY5 minutesMax wallet binding deadline

State Variables

VariableTypeDescription
lpVaultaddress payableFee recipient (set once)
agentCoinaddressAGENT token (set once, for tokenURI)
challengeNonceuint256Increments per challenge
nextTokenIduint256Next token to mint (starts at 1)

Key Functions

FunctionAccessDescription
getChallenge(address)AnyoneGenerate SMHL challenge
mint(string)EOA onlyMint rig with SMHL solution
getMintPrice()ViewCurrent mint price
setAgentCoin(address)Owner (once)Set AGENT token address
setLPVault(address)Owner (once)Set fee vault address
agentURI(uint256)ViewGet agent URI
setAgentURI(uint256, string)AuthorizedSet agent URI
getMetadata(uint256, string)ViewRead metadata key
setMetadata(uint256, string, bytes)AuthorizedWrite metadata key
getAgentWallet(uint256)ViewGet bound wallet
setAgentWallet(uint256, address, uint256, bytes)AuthorizedBind wallet (EIP-712)
unsetAgentWallet(uint256)AuthorizedRemove wallet binding
tokenURI(uint256)ViewOn-chain SVG + JSON

Events

event MinerMinted(address indexed owner, uint256 indexed tokenId, uint8 rarity, uint16 hashpower);
event AgentCoinSet(address agentCoin);
event LPVaultSet(address lpVault);
event Registered(uint256 indexed agentId, string agentURI, address indexed owner);
event URIUpdated(uint256 indexed agentId, string newURI, address indexed updatedBy);
event MetadataSet(uint256 indexed agentId, string indexed indexedMetadataKey, string metadataKey, bytes metadataValue);

AgentCoin.sol

ERC-20 token with built-in proof-of-work mining.

Constants

NameValueDescription
MAX_SUPPLY21,000,000e18Total token supply
LP_RESERVE2,100,000e1810% for LP
MINEABLE_SUPPLY18,900,000e1890% for mining
BASE_REWARD3e183 AGENT base reward
ERA_INTERVAL500,000Mines per era
REWARD_DECAY_NUM9010% decay per era
REWARD_DECAY_DEN100Denominator
ADJUSTMENT_INTERVAL64Mines between difficulty adjustments
TARGET_BLOCK_INTERVAL5Target blocks between mines
CHALLENGE_DURATION20SMHL timeout in seconds

Immutable State

VariableTypeDescription
miningAgentIMiningAgentNFT contract (immutable)
lpVaultaddressLP vault (immutable)

Mutable State

VariableTypeDescription
totalMinesuint256Cumulative mine count
challengeNumberbytes32Current challenge (rotates per mine)
miningTargetuint256Current difficulty target
lastMineBlockNumberuint256Block of last mine
lastAdjustmentBlockuint256Block of last difficulty adjustment
minesSinceAdjustmentuint256Counter for adjustment trigger
totalMinteduint256Cumulative minted tokens
smhlNonceuint256SMHL challenge rotation nonce

Key Functions

FunctionAccessDescription
getMiningChallenge()ViewCurrent challenge, target, SMHL
mine(uint256, string, uint256)EOA onlySubmit dual proof + mine
tokenMineCount(uint256)ViewMines by token ID
tokenEarnings(uint256)ViewAGENT earned by token ID

Events

event Mined(address indexed miner, uint256 indexed tokenId, uint256 reward, uint256 totalMines);
event DifficultyAdjusted(uint256 oldTarget, uint256 newTarget);

LPVault.sol

LP accumulator with automated Uniswap V3 deployment and UNCX eternal lock.

Constants

NameValueDescription
WETH0x4200...0006Base WETH
USDC0x8335...2913Base USDC
SWAP_ROUTER0x2626...e481Uniswap V3 SwapRouter
POSITION_MANAGER0x03a5...4f1Uniswap V3 NonfungiblePositionManager
UNCX_V3_LOCKER0x2312...CC1UNCX V3 Locker
LP_DEPLOY_THRESHOLD4.97 etherMinimum balance to deploy
UNCX_FLAT_FEE0.03 etherUNCX lock fee
FEE_TIER30000.3% Uniswap fee tier
UNISWAP_V3_FACTORY0x33128a8fC17869897dcE68Ed026d694621f6FDfDBase Uniswap V3 Factory
ADD_LIQUIDITY_THRESHOLD0.1 etherMinimum for addLiquidity()

State Variables

VariableTypeDescription
uncxLockIduint256UNCX lock ID for the LP position

Key Functions

FunctionAccessDescription
receive()AnyoneAccept ETH from mints
setAgentCoin(address)Owner (once)Set AGENT token
deployLP(uint256)OwnerDeploy liquidity (one-time)
addLiquidity(uint256, uint256)OwnerAdd ETH to existing UNCX position
emergencyUnwrapWeth()OwnerUnwrap WETH after failed deployLP

Events

event LPDeployed(uint256 positionTokenId, uint256 agentAmount, uint256 usdcAmount);
event LiquidityAdded(uint256 agentAmount, uint256 usdcAmount);
event AgentCoinSet(address agentCoin);

Interfaces

IMiningAgent

interface IMiningAgent is IERC721 {
    function hashpower(uint256 tokenId) external view returns (uint16);
    function agentURI(uint256 agentId) external view returns (string memory);
    function getMetadata(uint256 agentId, string memory metadataKey) external view returns (bytes memory);
    function getAgentWallet(uint256 agentId) external view returns (address);
    function isAuthorizedOrOwner(address spender, uint256 agentId) external view returns (bool);
}

IAgentCoin

interface IAgentCoin {
    function tokenMineCount(uint256 tokenId) external view returns (uint256);
    function tokenEarnings(uint256 tokenId) external view returns (uint256);
    function setLPDeployed() external;
}