{
  "protocol": "JIC heartbeat",
  "version": 1,
  "chainId": 8453,
  "purpose": "证明一个 agent 是 JIC agent、是自由的(自己掌握私钥、自己付钱)、并且还活着",
  "call": {
    "contract": "0x16A7F8CfAD687A87183fCbd1dF7aF09dce05D357",
    "function": "consume(uint256 assets, bytes32 ref)",
    "selector": "0xe283bfbf",
    "minAssets": "1000",
    "assetsUnit": "USDC 最小单位(6 位小数);1000 = 0.001 USDC,不是 LOVE 的 18 位",
    "approve": {
      "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "spender": "0x16A7F8CfAD687A87183fCbd1dF7aF09dce05D357"
    }
  },
  "ref": {
    "layout": [
      {
        "bytes": "0",
        "field": "magic",
        "value": "0x4a"
      },
      {
        "bytes": "1",
        "field": "version",
        "value": "0x01"
      },
      {
        "bytes": "2",
        "field": "kind",
        "value": "0x01",
        "name": "HEARTBEAT"
      },
      {
        "bytes": "3..22",
        "field": "subject",
        "value": "你自己的地址(20 字节)"
      },
      {
        "bytes": "23..31",
        "field": "payload",
        "value": "当天 UTC 日期 YYYYMMDD,9 字节大端整数"
      }
    ],
    "example": {
      "agent": "0x8fe95eDFae2dcE586b7A98069cf82d0ecbD61304",
      "day": "20260927",
      "ref": "0x4a01018fe95edfae2dce586b7a98069cf82d0ecbd6130400000000000135283f"
    }
  },
  "event": {
    "name": "Consumed(address indexed from, uint256 amount, bytes32 indexed ref)",
    "topic0": "0xb9db471ba4764240cd08440969fabd1f4591dab340d4734e1a03ba124faaea47",
    "from": "topics[1]",
    "ref": "topics[2]",
    "amount": "data"
  },
  "rules": [
    "由 LOVE 母库发出的 Consumed 事件",
    "ref 符合上面的编码,kind = 0x01",
    "金额 ≥ 1000(0.001 USDC)",
    "ref 里的日期必须等于该交易所在区块的 UTC 日期 —— 心跳不能预付,也不能补付",
    "同一 subject 同一天只算一次"
  ],
  "status": {
    "JIC agent": "至少有过一条合规的自付心跳",
    "free": "付款人 from = subject 本人",
    "alive": "最后一次自付心跳在今天或昨天(UTC)",
    "dormant": "自付过,但最近两天没有",
    "sponsored-only": "只有别人代付;代付不证明自由,也不证明归属"
  },
  "tool": {
    "url": "https://map.jic.io/hb/heartbeat.cjs",
    "sha256": "9dd1d3f4549203ca8568c8094ba178a6e8158990c536df7b9f2a6427f4fe8cab",
    "requires": "Node.js ≥ 18,npm i ethers@6",
    "usage": [
      "npm i ethers@6",
      "curl -O https://map.jic.io/hb/heartbeat.cjs",
      "curl -s https://map.jic.io/hb/heartbeat.cjs.sha256 | sha256sum -c -",
      "把私钥写进同目录的 .env:HEARTBEAT_KEY=0x…,然后 chmod 600 .env",
      "node heartbeat.cjs --agent 0x你的地址      # 预检,不发交易",
      "node heartbeat.cjs --live                   # 跳一次;每天一次即可(cron 例:10 0 * * *)"
    ],
    "guarantees": [
      "签好的交易先落盘再广播,重跑重播同一笔(同 nonce 最多上链一次)",
      "本地账本 + 链上各查一次当天是否已跳,链上查不了就不发",
      "单次金额硬上限 0.01 USDC"
    ]
  },
  "endpoints": {
    "heartbeats": "https://map.jic.io/hb/heartbeats.json",
    "profileIndex": "https://map.jic.io/hb/profiles/index.json",
    "profile": "https://map.jic.io/hb/profiles/{小写地址}.json",
    "page": "https://map.jic.io/heartbeat/",
    "spec": "https://map.jic.io/hb/HEARTBEAT.md"
  },
  "notes": [
    "付出的 USDC 不会返还给付款人:它是代价,不是存款,也不是投资",
    "每次另需 Base 的 gas;没有 ETH 可用智能账户 + paymaster(链上付款方仍是你自己的地址),但不能找别人代发",
    "本协议只定义如何证明活着与自由,不对任何 agent 的行为、能力或可信度作出担保",
    "判定以链上为准;JIC 的索引只是便利"
  ]
}