Bắt đầu với TheRPC
Tham khảo API
Ethereum API
Core API
Hướng dẫn

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

Giúp chúng tôi trở nên tốt hơn!
Chia sẻ trang này và giúp chúng tôi tạo ra sản phẩm tốt hơn cho bạn.