eth_getTransactionReceipt
eth_getTransactionReceipt(txHash) → receipt | null 트랜잭션이 블록에 포함된 후 영수증을 반환합니다. 트랜잭션이 아직 대기 중이면 null을 반환하므로 비-null이 될 때까지 폴링하거나 ethers.js의 tx.wait()를 사용하세요. 영수증에는 최종 상태(성공/되돌림), 사용된 가스, 방출된 로그, 계약 주소(배포인 경우)가 포함됩니다.
파라미터
| 이름 | 타입 | 필수 | 설명 |
|---|---|---|---|
txHash | string | ✓ | 트랜잭션 해시(32바이트, 0x 접두사가 있는 16진수 인코딩) |
반환값
타입:
object | null status(0x1 = 성공, 0x0 = 되돌림), blockNumber, gasUsed, logs, contractAddress(배포 시), effectiveGasPrice를 포함한 영수증 객체. 트랜잭션이 대기 중이거나 알 수 없는 경우 null을 반환합니다.
예제
ethers.js v6 — 컨펌 대기
`sendTransaction`에서 반환된 `tx` 객체가 있다면 `await tx.wait()`를 선호하세요. 자동으로 폴링하여 채굴 즉시 영수증을 반환합니다.
import { JsonRpcProvider } from "ethers";
const provider = new JsonRpcProvider("https://rpc-testnet.maroo.io");
const receipt = await provider.getTransactionReceipt("0xYourTxHash");
if (receipt === null) {
console.log("Still pending");
} else {
console.log("Status:", receipt.status === 1 ? "success" : "reverted");
console.log("Block:", receipt.blockNumber, "Gas used:", receipt.gasUsed.toString());
} cURL로 직접 호출
전체 영수증 객체를 JSON으로 반환합니다. `result`가 비-null이 될 때까지 폴링하세요.
curl -X POST https://rpc-testnet.maroo.io \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": ["0xYourTxHash"],
"id": 1
}'