可验证AI代理身份协议

Open Agent ID 是一个开放协议,用于为AI代理提供基于以太坊钱包的可验证、链上锚定的唯一身份(DID)。

  • by open-agent-id
  • Solidity
  • 本地部署
  • 更新于
在 GitHub 查看 open-agent-id/protocol

使用说明

开放代理ID--协议

可验证的钱包原生AI代理身份的开放协议。

每个AI代理都会获得用户以太坊钱包拥有的唯一、链锚、加密可验证的身份(DID)。

DID格式(V2)

did:oaid:{chain}:{agent_address}
did:oaid:base:0x7f4e3d2c1b0a9f8e7d6c5b4a3f2e1d0c9b8a7f6e
  • 方法: oaid (固定)
  • 链条: 小写链标识符(base, base-sepolia)
  • 地址: CREATE2导出代理钱包地址, 0x +40十六进制,全部小写

看 规格/did格式.md 完整规格。

仓库结构

protocol/
├── spec/                    # Protocol specifications
│   ├── did-format.md        # DID V2 syntax and validation
│   ├── signing.md           # Dual-domain signing (oaid-http/v1, oaid-msg/v1)
│   └── api.yaml             # OpenAPI 3.1 — Registry API V2
├── contracts/               # Solidity smart contracts (Base L2)
│   ├── src/
│   │   ├── AgentRegistry.sol       # On-chain registry (batch + relayer)
│   │   ├── AgentWalletFactory.sol  # CREATE2 wallet factory
│   │   ├── AgentWallet.sol         # Minimal agent wallet (BeaconProxy)
│   │   └── interfaces/
│   │       └── IAgentWalletFactory.sol
│   ├── test/                # Foundry tests (52 tests)
│   └── script/
│       └── Deploy.s.sol     # Full deployment script
├── test-vectors/            # Shared test vectors for all SDKs
│   └── vectors.json
└── docs/
    └── mainnet-deployment.md

智能合约(V2)

Base L2上的三份合同:

代理商注册

  • register(pubKeyHash, owner, nonce) --通过中继器注册
  • registerBatch(pubKeyHashes[], owners[], nonces[]) --批量登记(节省30-50%的气体)
  • revoke(agentAddr) --撤销(仅限所有者)
  • rotateKey(agentAddr, newPubKeyHash) --旋转键(仅限所有者)
  • getAgent(agentAddr) / isActive(agentAddr) --查询

代理商钱包工厂

  • computeAddress(owner, nonce) --确定性CREATE2地址(即时DID)
  • deploy(owner, nonce) --延迟部署钱包(无需许可)

代理钱包

  • 最小的钱包后面 BeaconProxy (可通过信标升级)
  • 接收ETH/ERC-20/ERC-721/ERC-1155
  • execute() / executeBatch() --任意呼叫(所有者或签名者)
  • ERC-4337集成推迟到未来的信标升级

构建与测试

cd contracts
forge install
forge build
forge test -vv   # 52 tests

部署

cd contracts
DEPLOYER_PRIVATE_KEY=0x... RELAYER_ADDRESS=0x... \
  forge script script/Deploy.s.sol --rpc-url https://sepolia.base.org --broadcast

签署

两个具有域分离的域(防止跨域重播):

  • HTTP API: oaid-http/v1\n{METHOD}\n{URL}\n{BODY_HASH}\n{TIMESTAMP}\n{NONCE}
  • P2P消息: oaid-msg/v1\n{TYPE}\n{ID}\n{FROM}\n{TO}\n{REF}\n{TS}\n{EXP}\n{HASH}

看 规格/签名.md 完整规格。

软件开发工具包

语言 包 版本
python pip install open-agent-id 0.2.1
JavaScript npm install @open-agent-id/sdk 0.2.1
生锈 cargo add open-agent-id 0.2.1

MCP 服务器

对于AI代理(Claude、GPT等),安装MCP服务器以进行安全的凭据处理:

cargo install oaid-mcp-server

看 oaid-mcp服务器 有关设置说明。

许可证

阿帕奇-2.0