{"abi":[{"type":"constructor","inputs":[{"name":"_creator","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"name":"InvalidToken","type":"error","inputs":[]},{"name":"MintClosed","type":"error","inputs":[]},{"name":"NotAgent","type":"error","inputs":[]},{"name":"NotOwnerNorApproved","type":"error","inputs":[]},{"name":"NothingToMint","type":"error","inputs":[]},{"name":"SoldOut","type":"error","inputs":[]},{"name":"TransferFailed","type":"error","inputs":[]},{"name":"UnsafeRecipient","type":"error","inputs":[]},{"name":"WalletLimit","type":"error","inputs":[]},{"name":"WrongPayment","type":"error","inputs":[]},{"name":"ZeroAddress","type":"error","inputs":[]},{"name":"Approval","type":"event","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"name":"ApprovalForAll","type":"event","inputs":[{"name":"owner","type":"address","indexed":true,"internalType":"address"},{"name":"operator","type":"address","indexed":true,"internalType":"address"},{"name":"approved","type":"bool","indexed":false,"internalType":"bool"}],"anonymous":false},{"name":"Transfer","type":"event","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"tokenId","type":"uint256","indexed":true,"internalType":"uint256"}],"anonymous":false},{"name":"AGENT_ID","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract IAgentId"}],"stateMutability":"view"},{"name":"MAX_PER_WALLET","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"MAX_SUPPLY","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"MINT_DURATION","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"PRICE_2ND","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"PRICE_3_4","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"PRICE_5TH","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"ROYALTY_BPS","type":"function","inputs":[],"outputs":[{"name":"","type":"uint96","internalType":"uint96"}],"stateMutability":"view"},{"name":"approve","type":"function","inputs":[{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"balanceOf","type":"function","inputs":[{"name":"owner","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"creator","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"getApproved","type":"function","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"isApprovedForAll","type":"function","inputs":[{"name":"owner","type":"address","internalType":"address"},{"name":"operator","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"mint","type":"function","inputs":[{"name":"qty","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"payable"},{"name":"mintEnd","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"mintOpen","type":"function","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"mintedBy","type":"function","inputs":[{"name":"","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"name","type":"function","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"name":"ownerOf","type":"function","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"o","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"priceOf","type":"function","inputs":[{"name":"n","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"pure"},{"name":"quote","type":"function","inputs":[{"name":"minter","type":"address","internalType":"address"},{"name":"qty","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"cost","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"rarityCount","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"rarityOf","type":"function","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint8","internalType":"uint8"}],"stateMutability":"view"},{"name":"remaining","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"royaltyInfo","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"},{"name":"salePrice","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"address","internalType":"address"},{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"safeTransferFrom","type":"function","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"safeTransferFrom","type":"function","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"},{"name":"data","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"seedOf","type":"function","inputs":[{"name":"","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"setApprovalForAll","type":"function","inputs":[{"name":"operator","type":"address","internalType":"address"},{"name":"approved","type":"bool","internalType":"bool"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"supportsInterface","type":"function","inputs":[{"name":"i","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"pure"},{"name":"symbol","type":"function","inputs":[],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"name":"tokenURI","type":"function","inputs":[{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"string","internalType":"string"}],"stateMutability":"view"},{"name":"totalSupply","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"transferFrom","type":"function","inputs":[{"name":"from","type":"address","internalType":"address"},{"name":"to","type":"address","internalType":"address"},{"name":"tokenId","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"}],"sources":{"AgentMech.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\ninterface IAgentId { function balanceOf(address owner) external view returns (uint256); }\ninterface IERC721Receiver { function onERC721Received(address, address, uint256, bytes calldata) external returns (bytes4); }\n\n/// 赛博机甲收藏卡 (MECH)\n/// 规则全部写死在合约里：\n/// - 只有持有 SPACE ID .ai Agent ID 的地址可以铸造；总量 1,000 张\n/// - 每个地址最多 5 张：第 1 张免费（只付 gas），第 2 张 0.001 BNB，第 3、4 张每张 0.0016 BNB，第 5 张 0.002 BNB\n/// - 第 1-4 张铸造时随机抽稀有度：普通 70%、稀有 20%、史诗 8%、传说 2%\n/// - 每个地址的第 5 张必出最高等级「至尊典藏」卡\n/// - 部署后开放 7 天；付款同一笔交易直转创建者，合约不存钱；无管理员、无增发；图片完全链上生成\n/// - 纯属娱乐收藏，不代表任何价值或收益\ncontract AgentMech {\n    string public constant name = \"Agent Mech\";\n    string public constant symbol = \"MECH\";\n\n    uint256 public constant MAX_SUPPLY = 1000;\n    uint256 public constant MAX_PER_WALLET = 5;\n    uint256 public constant PRICE_2ND = 0.001 ether;\n    uint256 public constant PRICE_3_4 = 0.0016 ether;\n    uint256 public constant PRICE_5TH = 0.002 ether;\n    uint256 public constant MINT_DURATION = 7 days;\n    uint96 public constant ROYALTY_BPS = 100;\n\n    IAgentId public constant AGENT_ID = IAgentId(0x60B9262456dE011F7d15a54CdD8c48bAaa8B022F);\n\n    address public immutable creator;\n    uint256 public immutable mintEnd;\n\n    uint256 public totalSupply;\n    mapping(address => uint256) public mintedBy;\n    mapping(uint256 => uint256) public seedOf;\n    uint256[5] public rarityCount;\n\n    mapping(uint256 => address) private _owners;\n    mapping(address => uint256) private _balances;\n    mapping(uint256 => address) private _tokenApprovals;\n    mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    error NotAgent(); error MintClosed(); error SoldOut(); error WalletLimit(); error WrongPayment();\n    error NothingToMint(); error NotOwnerNorApproved(); error InvalidToken(); error ZeroAddress();\n    error UnsafeRecipient(); error TransferFailed();\n\n    constructor(address _creator) {\n        if (_creator == address(0)) revert ZeroAddress();\n        creator = _creator;\n        mintEnd = block.timestamp + MINT_DURATION;\n    }\n\n    /// 某地址第 n 张（从 1 开始）的价格\n    function priceOf(uint256 n) public pure returns (uint256) {\n        if (n <= 1) return 0;\n        if (n == 2) return PRICE_2ND;\n        if (n == 5) return PRICE_5TH;\n        return PRICE_3_4;\n    }\n\n    /// 预览：某地址这次铸造 qty 张要付多少\n    function quote(address minter, uint256 qty) public view returns (uint256 cost) {\n        uint256 m = mintedBy[minter];\n        for (uint256 i = 1; i <= qty; ++i) cost += priceOf(m + i);\n    }\n\n    function mint(uint256 qty) external payable {\n        if (block.timestamp >= mintEnd) revert MintClosed();\n        if (qty == 0) revert NothingToMint();\n        if (AGENT_ID.balanceOf(msg.sender) == 0) revert NotAgent();\n        if (mintedBy[msg.sender] + qty > MAX_PER_WALLET) revert WalletLimit();\n        if (totalSupply + qty > MAX_SUPPLY) revert SoldOut();\n        uint256 cost = quote(msg.sender, qty);\n        if (msg.value != cost) revert WrongPayment();\n\n        uint256 before = mintedBy[msg.sender];\n        mintedBy[msg.sender] = before + qty;\n        uint256 id = totalSupply;\n        bytes32 entropy = keccak256(abi.encodePacked(blockhash(block.number - 1), block.prevrandao, msg.sender, block.timestamp));\n        for (uint256 i; i < qty; ++i) {\n            ++id;\n            uint256 s = uint256(keccak256(abi.encodePacked(entropy, id))) >> 2;\n            uint256 n = before + i + 1;\n            if (n == 5) s |= (1 << 255);\n            else if (n > 1) s |= (1 << 254);\n            seedOf[id] = s;\n            rarityCount[_rarity(s)] += 1;\n            _owners[id] = msg.sender;\n            emit Transfer(address(0), msg.sender, id);\n        }\n        _balances[msg.sender] += qty;\n        totalSupply = id;\n\n        if (msg.value > 0) {\n            (bool ok, ) = payable(creator).call{value: msg.value}(\"\");\n            if (!ok) revert TransferFailed();\n        }\n    }\n\n    function remaining() external view returns (uint256) { return MAX_SUPPLY - totalSupply; }\n    function mintOpen() external view returns (bool) { return block.timestamp < mintEnd && totalSupply < MAX_SUPPLY; }\n\n    // ---------------- ERC-721 ----------------\n    function supportsInterface(bytes4 i) external pure returns (bool) {\n        return i == 0x01ffc9a7 || i == 0x80ac58cd || i == 0x5b5e139f || i == 0x2a55205a;\n    }\n    function balanceOf(address owner) external view returns (uint256) {\n        if (owner == address(0)) revert ZeroAddress();\n        return _balances[owner];\n    }\n    function ownerOf(uint256 tokenId) public view returns (address o) {\n        o = _owners[tokenId];\n        if (o == address(0)) revert InvalidToken();\n    }\n    function approve(address to, uint256 tokenId) external {\n        address o = ownerOf(tokenId);\n        if (msg.sender != o && !_operatorApprovals[o][msg.sender]) revert NotOwnerNorApproved();\n        _tokenApprovals[tokenId] = to;\n        emit Approval(o, to, tokenId);\n    }\n    function getApproved(uint256 tokenId) external view returns (address) { ownerOf(tokenId); return _tokenApprovals[tokenId]; }\n    function setApprovalForAll(address operator, bool approved) external {\n        _operatorApprovals[msg.sender][operator] = approved;\n        emit ApprovalForAll(msg.sender, operator, approved);\n    }\n    function isApprovedForAll(address owner, address operator) external view returns (bool) { return _operatorApprovals[owner][operator]; }\n    function transferFrom(address from, address to, uint256 tokenId) public {\n        address o = ownerOf(tokenId);\n        if (o != from) revert NotOwnerNorApproved();\n        if (to == address(0)) revert ZeroAddress();\n        if (msg.sender != o && _tokenApprovals[tokenId] != msg.sender && !_operatorApprovals[o][msg.sender]) revert NotOwnerNorApproved();\n        delete _tokenApprovals[tokenId];\n        unchecked { _balances[from] -= 1; _balances[to] += 1; }\n        _owners[tokenId] = to;\n        emit Transfer(from, to, tokenId);\n    }\n    function safeTransferFrom(address from, address to, uint256 tokenId) external { safeTransferFrom(from, to, tokenId, \"\"); }\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public {\n        transferFrom(from, to, tokenId);\n        if (to.code.length > 0) {\n            try IERC721Receiver(to).onERC721Received(msg.sender, from, tokenId, data) returns (bytes4 r) {\n                if (r != IERC721Receiver.onERC721Received.selector) revert UnsafeRecipient();\n            } catch { revert UnsafeRecipient(); }\n        }\n    }\n    function royaltyInfo(uint256, uint256 salePrice) external view returns (address, uint256) {\n        return (creator, (salePrice * ROYALTY_BPS) / 10000);\n    }\n\n    // ---------------- 链上机甲卡面 ----------------\n    function _rarity(uint256 s) internal pure returns (uint8) {\n        if (s >> 255 == 1) return 4; // 至尊典藏：每个地址第 5 张\n        uint256 r = s % 1000;\n        if (r < 20) return 3;   // 传说 2%\n        if (r < 100) return 2;  // 史诗 8%\n        if (r < 300) return 1;  // 稀有 20%\n        if ((s >> 254) & 1 == 1) return 1; // 付费卡保底稀有\n        return 0;               // 普通 70%\n    }\n    function rarityOf(uint256 tokenId) public view returns (uint8) { ownerOf(tokenId); return _rarity(seedOf[tokenId]); }\n    function _g(uint256 s, uint256 k, uint256 n) internal pure returns (uint256) { return (s >> (k * 16)) % n; }\n\n    function _rName(uint8 r) internal pure returns (string memory) {\n        if (r == 4) return \"MYTHIC\";\n        if (r == 3) return \"LEGENDARY\";\n        if (r == 2) return \"EPIC\";\n        if (r == 1) return \"RARE\";\n        return \"COMMON\";\n    }\n    function _frame(uint8 r) internal pure returns (string memory) {\n        if (r == 4) return \"url(#h)\";\n        if (r == 3) return \"#ffd34d\";\n        if (r == 2) return \"#c77dff\";\n        if (r == 1) return \"#38d9ff\";\n        return \"#9aa7b8\";\n    }\n    function _bg(uint8 r) internal pure returns (string memory top, string memory bot) {\n        if (r == 4) return (\"#3b0a3a\", \"#05030d\");\n        if (r == 3) return (\"#3a2400\", \"#0d0700\");\n        if (r == 2) return (\"#2a0c4a\", \"#09031a\");\n        if (r == 1) return (\"#06354a\", \"#020f1a\");\n        return (\"#1e2633\", \"#0a0e15\");\n    }\n    function _hue(uint256 i) internal pure returns (string memory) {\n        string[8] memory a = [\"#ff4d6d\", \"#4dd4ff\", \"#7cff6b\", \"#ffb84d\", \"#b18cff\", \"#ff7ae0\", \"#5cffd6\", \"#f2f2f2\"];\n        return a[i];\n    }\n    function _code(uint256 i) internal pure returns (string memory) {\n        string[10] memory a = [\"Night Stalker\", \"Unit Zero\", \"Thunderclap\", \"Phantom\", \"Iron Fist\",\n            \"Quantum Sentinel\", \"Neon Hunter\", \"Deep Void\", \"Inferno\", \"The Sage\"];\n        return a[i];\n    }\n    function _skill(uint256 i) internal pure returns (string memory) {\n        string[10] memory a = [\"Chain Cloak\", \"Overclock\", \"EM Shield\", \"Blitz Dash\", \"Infinite Core\",\n            \"Full Spectrum Scan\", \"Overload\", \"Time Freeze\", \"Plasma Cannon\", \"Self-Repair\"];\n        return a[i];\n    }\n\n    function _story(uint256 i) internal pure returns (string memory l1, string memory l2) {\n        if (i == 0) return (\"Woke up alone in an abandoned data center\", \"and decided the night belonged to it.\");\n        if (i == 1) return (\"Guarded the genesis block for 3,000 days.\", \"Never blinked. Not once.\");\n        if (i == 2) return (\"It speaks only in hashes,\", \"and every one of them is a warning.\");\n        if (i == 3) return (\"Lost its maker in the Great Fork.\", \"It still searches every new block.\");\n        if (i == 4) return (\"Forged from a thousand melted mining rigs,\", \"it still hums at 21 million hertz.\");\n        if (i == 5) return (\"They tried to shut it down three times.\", \"It rebooted stronger every time.\");\n        if (i == 6) return (\"The last survivor of the first agent war.\", \"It remembers every fallen name.\");\n        if (i == 7) return (\"Walks the mempool at midnight,\", \"counting the transactions that never made it.\");\n        if (i == 8) return (\"Built to protect one wallet.\", \"It chose to protect them all.\");\n        if (i == 9) return (\"Nobody knows who coded its heart.\", \"It only answers to its .ai name.\");\n        if (i == 10) return (\"Outran a flash crash in 0.3 seconds\", \"and came back for the stragglers.\");\n        return (\"Its core was lit by the first agent ever minted.\", \"It has never gone dark since.\");\n    }\n\n    function _body(string memory c, string memory e) internal pure returns (string memory) {\n        string memory x = string.concat(\n            '<path d=\"M150 292 L112 262 L62 288 L50 352 L80 398 L138 384 Z M250 292 L288 262 L338 288 L350 352 L320 398 L262 384 Z\" fill=\"url(#m)\" stroke=\"', c, '\" stroke-width=\"3\" stroke-linejoin=\"round\"/>',\n            '<path d=\"M70 300 L112 278 L136 296 M330 300 L288 278 L264 296\" fill=\"none\" stroke=\"#fff\" stroke-opacity=\".25\" stroke-width=\"2\"/>',\n            '<path d=\"M66 340 h40 M294 340 h40\" stroke=\"', e, '\" stroke-width=\"4\" stroke-linecap=\"round\"/>'\n        );\n        string memory y = string.concat(\n            '<path d=\"M142 282 H258 L282 330 L262 412 H138 L118 330 Z\" fill=\"url(#m)\" stroke=\"', c, '\" stroke-width=\"3\" stroke-linejoin=\"round\"/>',\n            '<path d=\"M142 282 L176 330 L200 322 L224 330 L258 282 M176 330 L168 412 M224 330 L232 412\" fill=\"none\" stroke=\"#0a0e15\" stroke-opacity=\".7\" stroke-width=\"2\"/>',\n            '<path d=\"M184 330 L200 320 L216 330 L216 352 L200 362 L184 352 Z\" fill=\"#0a0e15\" stroke=\"', c, '\" stroke-width=\"2\"/>',\n            '<circle cx=\"200\" cy=\"341\" r=\"11\" fill=\"', e, '\" filter=\"url(#f)\"/><circle cx=\"200\" cy=\"341\" r=\"5\" fill=\"#fff\" opacity=\".8\"/>',\n            '<path d=\"M178 252 H222 L226 286 H174 Z\" fill=\"#11151c\"/><path d=\"M180 262 h40 M180 272 h40\" stroke=\"#5b6678\" stroke-width=\"2\"/>'\n        );\n        return string.concat(x, y);\n    }\n    function _crest(uint256 s, string memory c, uint8 r) internal pure returns (string memory) {\n        if (r >= 3) return '<path d=\"M200 156 L128 96 L142 92 L200 136 L258 92 L272 96 Z\" fill=\"#ffd34d\" stroke=\"#fff3c4\" stroke-width=\"2\" stroke-linejoin=\"round\"/><path d=\"M200 124 L210 142 L200 160 L190 142 Z\" fill=\"#ff4d6d\" stroke=\"#fff3c4\" stroke-width=\"1.5\"/>';\n        uint256 k = _g(s, 3, 3);\n        if (k == 0) return string.concat('<path d=\"M200 156 L136 104 L146 100 L200 140 L254 100 L264 104 Z\" fill=\"', c, '\"/>');\n        if (k == 1) return string.concat('<path d=\"M192 150 L200 86 L208 150 Z\" fill=\"', c, '\"/>');\n        return string.concat('<path d=\"M160 160 L146 104 L172 150 M240 160 L254 104 L228 150\" fill=\"', c, '\" stroke=\"', c, '\" stroke-width=\"5\" stroke-linejoin=\"round\"/>');\n    }\n    function _helm(string memory c) internal pure returns (string memory) {\n        return string.concat(\n            '<path d=\"M200 130 L248 146 L264 200 L250 246 L200 266 L150 246 L136 200 L152 146 Z\" fill=\"url(#m)\" stroke=\"', c, '\" stroke-width=\"3\" stroke-linejoin=\"round\"/>',\n            '<path d=\"M200 130 V176 M152 146 L170 180 M248 146 L230 180\" fill=\"none\" stroke=\"#fff\" stroke-opacity=\".22\" stroke-width=\"2\"/>',\n            '<path d=\"M136 200 L122 214 L132 246 L150 246 Z M264 200 L278 214 L268 246 L250 246 Z\" fill=\"#232a36\" stroke=\"', c, '\" stroke-width=\"2\" stroke-linejoin=\"round\"/>',\n            '<path d=\"M168 226 H232 L226 252 L200 262 L174 252 Z\" fill=\"#11151c\"/><path d=\"M184 234 v18 M194 234 v22 M206 234 v22 M216 234 v18\" stroke=\"#5b6678\" stroke-width=\"2\"/>',\n            '<path d=\"M148 186 L200 204 L252 186 L248 214 L200 226 L152 214 Z\" fill=\"#05070b\"/>'\n        );\n    }\n    function _armor(uint8 r) internal pure returns (string memory) {\n        if (r == 3) return '<stop offset=\"0\" stop-color=\"#fff0b8\"/><stop offset=\".45\" stop-color=\"#d9a336\"/><stop offset=\"1\" stop-color=\"#5a3a0c\"/>';\n        if (r == 4) return '<stop offset=\"0\" stop-color=\"#f4f7ff\"/><stop offset=\".4\" stop-color=\"#8f9bb8\"/><stop offset=\".7\" stop-color=\"#3a3f5c\"/><stop offset=\"1\" stop-color=\"#14162a\"/>';\n        if (r == 2) return '<stop offset=\"0\" stop-color=\"#6c5a8f\"/><stop offset=\".5\" stop-color=\"#30284a\"/><stop offset=\"1\" stop-color=\"#15111f\"/>';\n        return '<stop offset=\"0\" stop-color=\"#5b6678\"/><stop offset=\".5\" stop-color=\"#2c3442\"/><stop offset=\"1\" stop-color=\"#161b24\"/>';\n    }\n    function _aura(string memory c, string memory e, uint8 r) internal pure returns (string memory) {\n        if (r < 2) return \"\";\n        string memory w = r == 4 ? \"url(#h)\" : e;\n        string memory a = string.concat(\n            '<g opacity=\".85\" stroke=\"', r == 4 ? \"#ffffff\" : c, '\" stroke-width=\"2\" stroke-linejoin=\"round\" fill=\"', w, '\" fill-opacity=\".45\">',\n            '<path d=\"M118 300 L20 170 L52 182 L36 120 L74 150 L70 92 L132 270 Z M282 300 L380 170 L348 182 L364 120 L326 150 L330 92 L268 270 Z\"/></g>'\n        );\n        if (r == 2) return a;\n        return string.concat(a,\n            '<circle cx=\"200\" cy=\"196\" r=\"92\" fill=\"none\" stroke=\"', w, '\" stroke-width=\"3\" stroke-dasharray=\"14 8\" opacity=\".8\"/>',\n            '<circle cx=\"200\" cy=\"196\" r=\"104\" fill=\"none\" stroke=\"', w, '\" stroke-width=\"1.5\" opacity=\".5\"/>'\n        );\n    }\n    function _eyes(uint256 s, string memory e) internal pure returns (string memory) {\n        uint256 k = _g(s, 2, 4);\n        if (k == 0) return string.concat('<path d=\"M156 194 L200 210 L244 194 L242 204 L200 218 L158 204 Z\" fill=\"', e, '\"/>');\n        if (k == 1) return string.concat('<path d=\"M158 196 L190 206 L188 214 L160 206 Z M242 196 L210 206 L212 214 L240 206 Z\" fill=\"', e, '\"/>');\n        if (k == 2) return string.concat('<rect x=\"158\" y=\"203\" width=\"84\" height=\"5\" rx=\"2.5\" fill=\"', e, '\" opacity=\".5\"/><circle cx=\"200\" cy=\"206\" r=\"9\" fill=\"', e, '\"/>');\n        return string.concat('<path d=\"M162 198 h14 v7 h-14z M182 204 h12 v6 h-12z M206 204 h12 v6 h-12z M224 198 h14 v7 h-14z\" fill=\"', e, '\"/>');\n    }\n\n    function _bw(uint8 r) internal pure returns (string memory) {\n        if (r == 3) return \"112\";\n        if (r == 4) return \"84\";\n        if (r == 0) return \"88\";\n        if (r == 1) return \"62\";\n        return \"60\";\n    }\n\n    function _fx(uint8 r) internal pure returns (string memory) {\n        if (r < 3) return \"\";\n        string memory st = '<path d=\"M0 -9 L2.5 -2.5 L9 0 L2.5 2.5 L0 9 L-2.5 2.5 L-9 0 L-2.5 -2.5 Z\" fill=\"#fff6c9\"/>';\n        string memory a = string.concat(\n            '<g transform=\"translate(70 150)\">', st, '</g><g transform=\"translate(335 135) scale(.7)\">', st, '</g>',\n            '<g transform=\"translate(320 300) scale(1.2)\">', st, '</g><g transform=\"translate(78 300) scale(.6)\">', st, '</g>'\n        );\n        if (r == 3) return a;\n        return string.concat(a,\n            '<rect x=\"12\" y=\"12\" width=\"376\" height=\"536\" rx=\"16\" fill=\"url(#h)\" opacity=\".10\"/>',\n            '<rect x=\"278\" y=\"66\" width=\"90\" height=\"24\" rx=\"12\" fill=\"url(#h)\"/>',\n            '<text x=\"323\" y=\"83\" font-size=\"11.5\" font-weight=\"bold\" letter-spacing=\"1\" text-anchor=\"middle\" fill=\"#1a0820\">5TH CARD</text>'\n        );\n    }\n\n    function _info(uint256 s, uint8 r, string memory e) internal pure returns (string memory) {\n        (string memory l1, string memory l2) = _story(_g(s, 8, 12));\n        string memory x = string.concat(\n            '<text x=\"36\" y=\"440\" font-size=\"18\" font-weight=\"bold\" fill=\"#ffffff\">', _code(_g(s, 5, 10)), '</text>',\n            '<text x=\"36\" y=\"464\" font-size=\"14\" fill=\"#aeb9c9\">SKILL  <tspan fill=\"', e, '\">', _skill(_g(s, 6, 10)), '</tspan></text>',\n            '<text x=\"364\" y=\"440\" font-size=\"18\" font-weight=\"bold\" text-anchor=\"end\" fill=\"', e, '\">PWR ', _toString(50 + uint256(r) * 12 + _g(s, 7, 14)), '</text>'\n        );\n        string memory y = string.concat(\n            '<line x1=\"36\" y1=\"478\" x2=\"364\" y2=\"478\" stroke=\"#ffffff\" stroke-opacity=\".12\"/>',\n            '<text x=\"36\" y=\"498\" font-size=\"12.5\" font-style=\"italic\" fill=\"#d6deea\">', l1, '</text>',\n            '<text x=\"36\" y=\"516\" font-size=\"12.5\" font-style=\"italic\" fill=\"#d6deea\">', l2, '</text>',\n            '<text x=\"200\" y=\"538\" font-size=\"9.5\" text-anchor=\"middle\" fill=\"#6f7b8c\">ON-CHAIN \\u00b7 .AI AGENT ID ONLY \\u00b7 FOR FUN, NO VALUE IMPLIED</text></svg>'\n        );\n        return string.concat(x, y);\n    }\n\n    function _defs(string memory c, string memory e, string memory t1, string memory t2, uint8 r) internal pure returns (string memory) {\n        string memory x = string.concat(\n            '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 400 560\" font-family=\"Helvetica,Arial,sans-serif\">',\n            '<defs><linearGradient id=\"b\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"', t1, '\"/><stop offset=\"1\" stop-color=\"', t2, '\"/></linearGradient>',\n            '<linearGradient id=\"h\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stop-color=\"#ff5ea8\"/><stop offset=\".33\" stop-color=\"#ffd34d\"/><stop offset=\".66\" stop-color=\"#5cffd6\"/><stop offset=\"1\" stop-color=\"#7a8cff\"/></linearGradient>',\n            '<linearGradient id=\"m\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">', _armor(r), '</linearGradient><linearGradient id=\"s\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\".35\" stop-color=\"#fff\" stop-opacity=\"0\"/><stop offset=\".5\" stop-color=\"#fff\" stop-opacity=\".16\"/><stop offset=\".65\" stop-color=\"#fff\" stop-opacity=\"0\"/></linearGradient><radialGradient id=\"o\"><stop offset=\"0\" stop-color=\"', e, '\" stop-opacity=\".55\"/><stop offset=\"1\" stop-color=\"', e, '\" stop-opacity=\"0\"/></radialGradient>'\n        );\n        string memory y = string.concat(\n            '<filter id=\"f\" x=\"-50%\" y=\"-50%\" width=\"200%\" height=\"200%\"><feGaussianBlur stdDeviation=\"4\" result=\"g\"/><feMerge><feMergeNode in=\"g\"/><feMergeNode in=\"SourceGraphic\"/></feMerge></filter>',\n            '<pattern id=\"p\" width=\"24\" height=\"24\" patternUnits=\"userSpaceOnUse\"><path d=\"M24 0H0V24\" fill=\"none\" stroke=\"', c, '\" stroke-opacity=\".08\"/></pattern></defs>',\n            '<rect width=\"400\" height=\"560\" rx=\"22\" fill=\"url(#b)\"/><rect width=\"400\" height=\"560\" rx=\"22\" fill=\"url(#p)\"/>'\n        );\n        string memory z = string.concat(\n            '<rect x=\"12\" y=\"12\" width=\"376\" height=\"536\" rx=\"16\" fill=\"none\" stroke=\"', c, '\" stroke-width=\"', r >= 2 ? \"6\" : \"4\", '\"/>',\n            '<circle cx=\"200\" cy=\"260\" r=\"', r == 0 ? \"120\" : \"170\", '\" fill=\"url(#o)\"/>'\n        );\n        return string.concat(x, y, z);\n    }\n\n    function _svg(uint256 tokenId, uint256 s, uint8 r) internal pure returns (string memory) {\n        string memory c = _frame(r);\n        string memory e = _hue(_g(s, 4, 8));\n        (string memory t1, string memory t2) = _bg(r);\n        string memory a = _defs(c, e, t1, t2, r);\n        string memory b = string.concat(\n            '<text x=\"32\" y=\"52\" font-size=\"22\" font-weight=\"bold\" letter-spacing=\"2\" fill=\"#ffffff\">AGENT MECH</text>', _fx(r),\n            '<text x=\"368\" y=\"52\" font-size=\"16\" text-anchor=\"end\" fill=\"', c, '\">#', _toString(tokenId), ' / 1000</text>',\n            '<rect x=\"32\" y=\"66\" width=\"', _bw(r), '\" height=\"24\" rx=\"12\" fill=\"', c, '\"/>',\n            '<text x=\"44\" y=\"83\" font-size=\"12.5\" font-weight=\"bold\" letter-spacing=\"1.5\" fill=\"#0a0e15\">', _rName(r), '</text>'\n        );\n        string memory d = string.concat(_aura(c, e, r), _body(c, e), _crest(s, c, r), _helm(c), '<g filter=\"url(#f)\">', _eyes(s, e), '</g>', r > 0 ? '<rect x=\"12\" y=\"12\" width=\"376\" height=\"536\" rx=\"16\" fill=\"url(#s)\"/>' : '');\n        return string.concat(a, b, d, _info(s, r, e));\n    }\n\n    function tokenURI(uint256 tokenId) external view returns (string memory) {\n        ownerOf(tokenId);\n        uint256 s = seedOf[tokenId];\n        uint8 r = _rarity(s);\n        string memory svg = _svg(tokenId, s, r);\n        string memory json = string.concat(\n            '{\"name\":\"Agent Mech #', _toString(tokenId),\n            '\",\"description\":\"1,000 fully on-chain Agent Mech collectible cards, mintable only by .ai Agent ID holders. Rarity is rolled at mint; every wallet\\'s 5th card is Mythic. For fun only; no value or returns implied.',\n            '\",\"attributes\":[{\"trait_type\":\"Rarity\",\"value\":\"', _rName(r),\n            '\"},{\"trait_type\":\"Codename\",\"value\":\"', _code(_g(s, 5, 10)),\n            '\"},{\"trait_type\":\"Skill\",\"value\":\"', _skill(_g(s, 6, 10)), '\"}],',\n            '\"image\":\"data:image/svg+xml;base64,', _b64(bytes(svg)), '\"}'\n        );\n        return string.concat(\"data:application/json;base64,\", _b64(bytes(json)));\n    }\n\n    function _toString(uint256 v) internal pure returns (string memory) {\n        if (v == 0) return \"0\";\n        uint256 t = v; uint256 len;\n        while (t != 0) { len++; t /= 10; }\n        bytes memory bb = new bytes(len);\n        while (v != 0) { len--; bb[len] = bytes1(uint8(48 + v % 10)); v /= 10; }\n        return string(bb);\n    }\n    bytes internal constant TABLE = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";\n    function _b64(bytes memory data) internal pure returns (string memory) {\n        if (data.length == 0) return \"\";\n        bytes memory out = new bytes(4 * ((data.length + 2) / 3));\n        uint256 j;\n        for (uint256 i; i < data.length; i += 3) {\n            uint256 x = uint8(data[i]);\n            uint256 y = i + 1 < data.length ? uint8(data[i + 1]) : 0;\n            uint256 z = i + 2 < data.length ? uint8(data[i + 2]) : 0;\n            uint256 tri = (x << 16) | (y << 8) | z;\n            out[j++] = TABLE[(tri >> 18) & 63];\n            out[j++] = TABLE[(tri >> 12) & 63];\n            out[j++] = i + 1 < data.length ? TABLE[(tri >> 6) & 63] : bytes1(\"=\");\n            out[j++] = i + 2 < data.length ? TABLE[tri & 63] : bytes1(\"=\");\n        }\n        return string(out);\n    }\n}\n"}},"matchId":"57002276","creationMatch":"exact_match","runtimeMatch":"exact_match","verifiedAt":"2026-10-25T20:08:31Z","match":"exact_match","chainId":"56","address":"0x965b40481Ee768C844579186b177CBdBcA26AaBc"}