TheRPC 시작하기

Block Confirmations Guide

Block confirmations are crucial for ensuring transaction finality in Ethereum. This guide explains how confirmations work and how to implement them in your applications.

Understanding Confirmations

  • What are block confirmations
  • Why confirmations matter
  • Recommended confirmation counts
  • Finality in different networks (mainnet vs testnets)

Implementation Examples

// Check number of confirmations
const getConfirmations = async (txHash) => {
	const tx = await web3.eth.getTransaction(txHash);
	const currentBlock = await web3.eth.getBlockNumber();
	return tx.blockNumber ? currentBlock - tx.blockNumber : 0;
};

// Wait for specific number of confirmations
const waitForConfirmations = async (txHash, confirmations = 6) => {
	while ((await getConfirmations(txHash)) < confirmations) {
		await new Promise((resolve) => setTimeout(resolve, 1000));
	}
	return true;
};

Security Considerations

  1. Different confirmation requirements for different transaction values
  2. Handling chain reorganizations
  3. Network-specific considerations
  4. Monitoring confirmation progress

See also

더 나아지도록 도와주세요!
이 페이지를 공유하고 더 나은 제품을 만들 수 있도록 도와주세요.