TransWikia.com

Modify number of confirmations

Ethereum Asked by sapiensapiens on August 26, 2021

By default there are 24 confirmations but I am running a testnet with just 3 miners and I would like to change this number bucause it makes not sense to have 24. I have been checking transactionConfirmationBlocks on the following way:

const options = {
   transactionConfirmationBlocks: 3
}

var web3 = new Web3(new Web3.providers.WebsocketProvider(provider_string, options));

I am not getting errors, but when I make a transaction it is still making 24 confirmations. if I check the number of confirmations (web3.eth.transactionConfirmationBlocks) is still 24. What is the right way to set the number of confirmations?

2 Answers

You need to pass the options parameter to Web3, not to WebsocketProvider, like this:

const options = {
   transactionConfirmationBlocks: 3
}

const web3 = new Web3(
  new Web3.providers.WebsocketProvider(provider_string),
  null,
  options
);

According to the docs it can also be set like this:

web3.transactionConfirmationBlocks
web3.eth.transactionConfirmationBlocks
web3.shh.transactionConfirmationBlocks

Answered by Carlos Fuentes on August 26, 2021

You tryed this?

const Web3 = require('web3')

const options = {
    transactionConfirmationBlocks: 24,
}

const web3 = new Web3('http://localhost:8545', null, options);

Answered by misael zurdo on August 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP