본문으로 건너뛰기

트랜잭션 단건 조회

GET /transactions/:transactionId

경로 파라미터

파라미터설명
transactionId조회할 트랜잭션 ID

응답 예시

{
"success": true,
"data": {
"id": "673a5d1e-f92b-4a61-9094-8eee1387bbea",
"type": "issue",
"status": "confirmed",
"txHash": "0xd97fc363002574ea3b7b3edb8cf4966620a487ab3c0ee9fbe844407df5ef7d48",
"from": "0x592C4D1b...",
"to": "0xd2D53c7b...",
"contractAddress": "0xd2D53c7b...",
"createdAt": "2024-01-01T00:00:00.000Z",
"confirmedAt": "2024-01-01T00:00:08.000Z"
}
}
const tx = await api('GET', `/transactions/${transactionId}`);

// 트랜잭션 완료 대기 (폴링 예시)
async function waitForConfirm(txId: string, maxRetries = 10) {
for (let i = 0; i < maxRetries; i++) {
const tx = await api('GET', `/transactions/${txId}`);
if (tx.data.status === 'confirmed') return tx.data;
if (tx.data.status === 'failed') throw new Error(tx.data.errorMessage);
await new Promise(r => setTimeout(r, 2000));
}
throw new Error('Timeout');
}

:::tip 웹훅 활용 권장 폴링 대신 웹훅을 등록하면 트랜잭션 완료 즉시 알림을 받을 수 있습니다. :::