钱包能力
Anon 实现 EIP-5792 的 wallet_getCapabilities,让 DApp 探测指定链和来源下支持的高级能力。
调用 wallet_getCapabilities
const capabilities = await window.ethereum.request({
method: "wallet_getCapabilities",
params: [accounts[0]],
});
响应将链 ID 映射至能力对象。
能力响应格式
{
"0x1": {
"auxiliaryFunds": {
"supported": true,
"assets": [
{
"chainId": "0x1",
"address": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
}
]
},
"paymasterService": {
"supported": true,
"url": "https://paymaster.anon.inc/v1"
},
"atomicBatch": {
"supported": true
}
}
}
auxiliaryFunds(ERC-7682)
auxiliaryFunds 表示可用标准公开余额以外的资金,具体是 Railgun 屏蔽余额,完成 wallet_sendCalls 请求。
仅对连接隐身地址的来源启用,向 DApp 表示:
此钱包有私密池内的额外资金可用于交易,不必仅依赖可见链上余额是否足够。
行为
符合 auxiliaryFunds 条件的来源发送 wallet_sendCalls 时:
- Anon 检查屏蔽余额中所需资产
- 若足够,解除屏蔽所需金额为调用注资,公开的目标和金额可见
- DApp 收到确认,无需自行处理底层解除屏蔽
资产列表
assets 列出屏蔽池可用代币,包括:
- WETH,ETH 计价操作的主要资产
- 用户在该链屏蔽余额中持有的其他代币
paymasterService
报告支持 paymasterService 时,DApp 可在 wallet_sendCalls 中使用 gas 赞助:
{
"version": "1.0",
"capabilities": {
"paymasterService": {
"url": "https://paymaster.anon.inc/v1"
}
}
}
Paymaster URL 接受 ERC-4337 兼容请求。
atomicBatch
atomicBatch: { supported: true } 表示 wallet_sendCalls 原子执行,全部成功或全部回滚。Anon 使用智能合约批处理实现。
Uniswap 等 DApp 在进入智能钱包流程前检查 atomicBatch。
运行时检查能力
const caps = await window.ethereum.request({
method: "wallet_getCapabilities",
params: [accounts[0]],
});
const chainCaps = caps[chainId];
if (chainCaps?.auxiliaryFunds?.supported) {
// Can use private funds in wallet_sendCalls
}
if (chainCaps?.atomicBatch?.supported) {
// Can use wallet_sendCalls with atomic execution
}