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?

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

You tryed this?

const Web3 = require('web3')

const options = {
    transactionConfirmationBlocks: 24,
}

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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