---
eip: 1186
label: EIP-1186
title: RPC-Method to get Merkle Proofs - eth_getProof
status: Stagnant
type: Standards Track
category: Interface
created: 2018-06-24
requires: 1474
official: https://eips.ethereum.org/EIPS/eip-1186
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1186.md
canonical: https://eips.huatuo.xyz/ko/eip-1186/
lang: ko
tldr: 계정의 상태와 Merkle 증명을 반환하는 eth_getProof JSON-RPC 메서드를 정의해, 신뢰할 수 있는 state root를 가진 누구나 노드를 믿지 않고도 검증할 수 있게 한다.
tags: [json-rpc, merkle, proof, light-client, state]
---

# EIP-1186: RPC-Method to get Merkle Proofs - eth_getProof

> One of the great features of Ethereum is the fact, that you can verify all data of the state. But in order to allow verification of accounts outside the client, we need an additional function delivering us the required proof. These proofs are important to secure Layer2-Technologies.

**TL;DR:** 계정의 상태와 Merkle 증명을 반환하는 eth_getProof JSON-RPC 메서드를 정의해, 신뢰할 수 있는 state root를 가진 누구나 노드를 믿지 않고도 검증할 수 있게 한다.

## 어떤 문제를 해결하나요?

`eth_getBalance`나 `eth_getStorageAt` 같은 일반 RPC 호출은 값을 반환하면서 노드를 믿으라고 요구합니다. 이더리움의 상태는 Merkle Patricia trie에 저장되므로 모든 값은 블록 헤더의 `stateRoot`에 대해 *증명할 수 있*지만, 표준 RPC에는 그 증명을 얻을 방법이 없었습니다.

EIP-1186은 `eth_getProof`를 추가합니다. 이를 쓰면 모바일 앱, IoT 기기, 브리지, 레이어 2는 신뢰할 수 있는 블록 헤더만 알고 있다면 신뢰할 수 없는 노드에 데이터를 요청하고 그 답을 스스로 검증할 수 있습니다.

## 어떻게 동작하나요?

**매개변수**

1. 계정 주소(20바이트).
2. 증명할 스토리지 키(각 32바이트)의 배열.
3. 블록 번호 또는 `"latest"` 같은 태그.

**결과**

| 필드 | 의미 |
| --- | --- |
| `balance`, `nonce` | 계정 값 |
| `codeHash` | 계정 코드의 해시 |
| `storageHash` | 계정 스토리지 trie의 루트 |
| `accountProof` | `keccak256(address)`를 따라 `stateRoot`에서 계정까지 내려가는 RLP 인코딩된 trie 노드 |
| `storageProof` | 요청한 각 키에 대해 `key`, `value`, 그리고 `keccak256(key)`를 따라 `storageHash`에서 내려가는 `proof` 노드 |

검증하려면 블록의 `stateRoot`를 가져와 `accountProof`를 따라가며 계정 레코드 `[nonce, balance, storageHash, codeHash]`를 복원한 다음, 그 `storageHash`에서 시작해 각 스토리지 증명을 따라갑니다.

증명은 **존재하지 않는** 값에도 적용됩니다. 증명이 경로를 갈 수 있는 곳까지 따라가, 그것이 빈 브랜치 슬롯이나 다른 경로의 리프에서 끝남을 보여 줍니다.

## 샘플 코드

ethers v6로 증명 요청하기:

```ts
import { JsonRpcProvider, zeroPadValue } from "ethers";

const provider = new JsonRpcProvider(process.env.RPC_URL);

const slot0 = zeroPadValue("0x00", 32);
const proof = await provider.send("eth_getProof", [
  "0x7F0d15C7FAae65896648C8273B6d7E43f58Fa842", // account
  [slot0],                                       // storage keys
  "latest",
]);

console.log(proof.balance, proof.nonce, proof.storageHash);
console.log("account proof nodes:", proof.accountProof.length);
console.log("slot 0 =", proof.storageProof[0].value);
```

원시 JSON-RPC 요청:

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getProof",
  "params": ["0x7F0d15C7FAae65896648C8273B6d7E43f58Fa842", ["0x0000000000000000000000000000000000000000000000000000000000000000"], "latest"]
}
```

실제로 검증하려면 `accountProof`와 헤더의 `stateRoot`를 Merkle Patricia trie 증명 검증기(예: 사용하는 언어의 trie 라이브러리에 있는 것)에 넣으세요.

## 알아둘 점

- **상태: EIP로서는 Stagnant**이지만, `eth_getProof`는 실행 클라이언트에 널리 구현되어 있으며 브리지, 라이트 클라이언트, 스토리지 증명 도구에서 쓰입니다.
- 증명의 신뢰도는 그것을 대조하는 블록 헤더만큼입니다. `stateRoot`는 같은 노드가 아니라 신뢰할 수 있는 출처에서 가져오세요.
- 코드가 없는 계정의 경우 `codeHash`는 빈 바이트의 해시인 `0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470`입니다.
- 많은 노드가 최근 상태만 보관하므로, 오래된 블록의 증명에는 아카이브 노드가 필요할 수 있습니다.
- 명세는 블록 해시 매개변수를 개선 가능성으로 제안했습니다. [EIP-1898](/eip-1898/)이 상태를 읽는 RPC 메서드 전반에 그런 방식의 블록 식별자를 추가했습니다.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-1186
