TheRPCを始める
APIリファレンス
イーサリアムAPI
Core API
ガイド

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

より良くするためにご協力ください!
このページを共有して、より良い製品を作るのに協力してください。