0

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
  • I think the options have to be passed as a second argument to new Web3(..) rather than ...WebSocketProvider(..). Feb 15, 2019 at 18:19
  • I did it and it has the same behaviour Feb 15, 2019 at 18:27

2 Answers 2

0

You tryed this?

const Web3 = require('web3')

const options = {
    transactionConfirmationBlocks: 24,
}

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.