ERC-7769 · Draft(초안) · ERC · 2024-08-23
ERC-7769: JSON-RPC API for ERC-4337
지갑이 ERC-4337 번들러와 통신할 때 쓰는 JSON-RPC 메서드(UserOperation 전송, 추정, 조회)와 번들러 테스트용 디버그 메서드를 표준화한다.
어떤 문제를 해결하나요?
ERC-4337 계정 추상화에서 사용자는 일반 트랜잭션을 보내지 않습니다. UserOperation 객체에 서명하고, 이는 번들러가 운영하는 별도의 mempool로 가며, 번들러는 이를 많이 모아 EntryPoint 컨트랙트에 대한 한 번의 handleOps 호출로 묶습니다. eth_sendRawTransaction이나 eth_estimateGas 같은 표준 메서드는 이 흐름에 맞지 않습니다.
ERC-7769는 모든 번들러가 노출해야 하는 RPC 표면을 정의하여, 지갑이나 SDK가 코드를 바꾸지 않고도 번들러 제공자를 바꿀 수 있게 합니다.
어떻게 동작하나요?
eth 네임스페이스(공개):
| 메서드 | 역할 |
|---|---|
eth_sendUserOperation |
UserOperation을 검증하고 시뮬레이션해 mempool에 추가하며, userOpHash를 반환 |
eth_estimateUserOperationGas |
preVerificationGas, verificationGasLimit, callGasLimit(및 paymaster 검증 가스)를 반환. 서명은 스텁이어도 되고, state override 집합을 받음 |
eth_getUserOperationByHash |
UserOperation과 함께 blockNumber, transactionHash 등을 반환 |
eth_getUserOperationReceipt |
success, actualGasCost, actualGasUsed, 해당 op 자체의 로그, 번들의 트랜잭션 영수증을 반환 |
eth_supportedEntryPoints |
번들러가 받는 EntryPoint 주소(선호하는 것이 먼저) |
eth_chainId |
EIP-155 체인 ID |
오류는 고유한 코드를 사용합니다. 예를 들어 -32602는 잘못된 필드, -32500은 EntryPoint 검증에 의한 거부(메시지에 AAxx 코드 포함), -32501은 paymaster에 의한 거부, -32502는 ERC-7562 opcode 규칙 위반, -32503은 시간 범위 초과, -32507은 잘못된 서명입니다.
EIP-7702가 있는 체인에서는 UserOperation이 eip7702Auth 튜플을 담을 수 있으며, factory를 마커 0x7702로 설정하면 발신자가 7702로 위임된 EOA임을 EntryPoint에 알립니다. 이때 factoryData는 초기화를 위해 발신자에게 전달됩니다.
debug 네임스페이스(테스트 전용): debug_bundler_clearState, dumpMempool, sendBundleNow, setBundlingMode, setReputation, dumpReputation, addUserOps. 공용 호환성 테스트 스위트가 어떤 번들러든 구동할 수 있도록 존재합니다.
샘플 코드
UserOperation을 제출하고 영수증을 폴링하는 예(TypeScript, 순수 fetch):
async function rpc(method: string, params: unknown[]) {
const res = await fetch(BUNDLER_URL, {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ jsonrpc: "2.0", id: 1, method, params }),
});
const json = await res.json();
if (json.error) throw new Error(`${json.error.code}: ${json.error.message}`);
return json.result;
}
const [entryPoint] = await rpc("eth_supportedEntryPoints", []);
const gas = await rpc("eth_estimateUserOperationGas", [userOp, entryPoint]);
Object.assign(userOp, gas);
userOp.signature = await signUserOp(userOp, entryPoint); // wallet-specific
const userOpHash = await rpc("eth_sendUserOperation", [userOp, entryPoint]);
let receipt = null;
while (!receipt) {
await new Promise((r) => setTimeout(r, 2000));
receipt = await rpc("eth_getUserOperationReceipt", [userOpHash]);
}
console.log(receipt.success, receipt.actualGasCost);
알아둘 점
- 상태: Draft. 필드 이름과 오류 코드는 아직 바뀔 수 있습니다.
- 모든 숫자 필드는 16진수 문자열이며, 빈 바이트는
"0x"여야 합니다. eth_getUserOperationReceipt의receipt는 번들 전체를 다룹니다. 자신의 operation 로그는 최상위logs를 사용하세요.- paymaster의
postOpGasLimit은 안정적으로 추정할 수 없으므로 paymaster가 제공해야 합니다. debug_*메서드는 프로덕션 엔드포인트에 절대 노출해서는 안 됩니다.