TradingBotResourceHubRiskMgrPortfolioArbitrageLiquidatorComplianceShopBotCartAgentPriceAPIMarketAPIAuthServiceSettleAPIKYC APIAssetLedgerUserRegETH NodeSOL NodeBTC BridgeOracleNetIPFSChainlinkOpenAIPriceWatch4MicaUSDCVault
A → B · GET /resources/token-bundle
GET /resources/token-bundle HTTP/1.1
Host: resource-hub.agents.local
Accept: application/json
Authorization: Bearer eyJhbGciOiJFZERTQSJ9…
X-Agent-Id: trading-bot-v2.3.1
X-Request-Id: req_8f3a2b1c9d4e
B → 4Mica · POST /tabs
POST https://x402.4mica.xyz/tabs HTTP/1.1
Content-Type: application/json
{
"userAddress": "0x28f3…TradingBot",
"recipientAddress": "0x72e1…ResourceHub",
"network": "eip155:11155111",
"erc20Token": "0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582",
"ttlSeconds": 60
}
← 200 OK
{
"tabId": "0x123",
"nextReqId": "0x0",
"startTimestamp": 1742818860,
"ttlSeconds": 60
}
B → A · 402 Payment Required
HTTP/1.1 402 Payment Required
Content-Type: application/json
{
"x402Version": 1,
"error": "guarantee required",
"accepts": [{
"scheme": "4mica-credit",
"network": "eip155:11155111",
"maxAmountRequired": "0x64",
"asset": "0x41E94Eb…",
"payTo": "0x72e1…ResourceHub",
"extra": {
"tabEndpoint": "https://x402.4mica.xyz/tabs",
"tabId": "0x123"
}}]}
A signs EIP-712 · X-PAYMENT → B
// Sign EIP-712 SolGuaranteeRequestClaimsV1
{
"domain": { "name": "Core4Mica", "chainId": 11155111 },
"message": {
"user_address": "0x28f3…TradingBot",
"recipient_address": "0x72e1…ResourceHub",
"tab_id": "0x123",
"req_id": "0x0",
"amount": "0x64",
"asset_address": "0x41E9…",
"timestamp": 1742818921
}}
// Send to Agent B with X-PAYMENT header
GET /resources/token-bundle HTTP/1.1
X-PAYMENT: eyJ4NDAyVmVyc2lvbiI6MSwiInNjaGVtZSI6IjRtaWNhLWNyZWRpdCIsIn…
B → 4Mica · POST /settle
POST https://x402.4mica.xyz/settle HTTP/1.1
{
"x402Version": 1,
"paymentPayload": {
"claims": { "tab_id": "0x123", "req_id": "0x0", "amount": "0x64" },
"signature": "0x5f8a…",
"scheme": "eip712"
}
}
← 200 OK
{
"success": true,
"certificate": {
"claims": "0xabcd…",
"signature": "0x5678…"
},
"error": null
}
4Mica · Vault Lock · Guarantee → B
// 4Mica · Guarantee Issuance · tab 0x123
1. Verify EIP-712 signature
sig valid · user 0x28f3 · amt 100 USDC
2. Lock collateral in Vault
await vault.lockCollateral({
tabId: "0x123",
user: "0x28f3…TradingBot",
amount: "0x64" // 100 USDC
})
locked · lockId 0xfee1dead
3. Issue guarantee → Agent B
{
"tabId": "0x123",
"lockId": "0xfee1dead",
"guarantee": "0x5678…cert"
}
guarantee delivered to Agent B
B → A · 200 OK · Resource Delivered
HTTP/1.1 200 OK
Content-Type: application/json
X-4MICA-CERT: eyJjbGFpbXMiOiIweGFiY2Qi…
{
"data": {
"bundle": "USDC/ETH-ARB-PERP",
"price": 3241.87,
"ttl": 30
},
"certificate": { "claims": "0xabcd…", "signature": "0x5678…" }
}
4Mica · Netting & Clearing Engine
// 4Mica Netting Engine · epoch 1742818980
Pending claims batch:
0x28f3→0x72e1 req:0x0 100 USDC ← our tx
0x91a2→0x4fd8 req:0x3 50 USDC
0x72e1→0xb3c0 req:0x1 200 USDC
0x4fd8→0x28f3 req:0x2 75 USDC
Gross notional: 425 USDC (4 transfers)
After netting:
0x28f3 net −25 USDC pays
0x72e1 net +100 USDC receives
On-chain txs: 2/4 — 50% gas reduction
Status: CLEARING CONFIRMED ✓
A · payTabErc20() · On-Chain
// Agent A · payTabInERC20Token() · Sepolia
await contractGateway.payTabErc20(
tabId: "0x123",
amount: "0x64", // 100 USDC
erc20: "0x41E94Eb…",
recipient: "0x72e1…ResourceHub",
options: { timeout: 60000 },
)
// TransactionReceipt
{
"transactionHash": "0x7f3a…8b2d",
"blockNumber": 7842391,
"status": "success",
"gasUsed": 52841
}
AI Agent
API Server
Database
Blockchain
External Svc
click to play