I want to override the default transactionBlockTimeout from 50 Blocks to 5 Blocks. However, it appears not to have any affect when using web3js with Truffle Contract.

A high level overview of my code looks like this:

// Initialize web3js and set transactionBlockTimeout property
const Web3 = require('web3');
web3 = new Web3(provider); // provider already set elsewhere
web3.eth.transactionBlockTimeout = 5

// Initialize contract
const MyContractArtifact = require("../build/contracts/MyContract.json")
MyContract = contract(MyContractArtifact)
myContractInstance = await MyContract.deployed()

// Call contract function
tx = await myContractInstance.someFunctionThatICall()

Let's say I send this transaction to ropsten testnet with a very low gas to ensure it is not mined right away the transaction does not timeout after 5 blocks but will still only timeout after the default 50 blocks.

Interestingly, it appears that sending a transaction using web3js library directly like in the example below does pick up the updated value for transactionBlockTimeout.

web3.eth.sendTransaction({from: accounts[0], to: accounts[0], value: 1e18, gasPrice: 100}) // sending with very low gas to trigger a block timeout

So this would appear to be an issue with Truffle Contract. Has anyone come across this situation and do you have a solution on how to control the block timeout in this case, perhaps directly using the Truffle Contract API?

The version of web3js and Truffle Contract are as follows:

├─┬ @openzeppelin/test-helpers@0.5.6
│ ├─┬ @truffle/contract@4.2.1
│ │ └── web3@1.2.1
│ └── web3@1.2.11  deduped
├─┬ @truffle/contract@4.2.22
│ ├─┬ @truffle/interface-adapter@0.4.16
│ │ └── web3@1.2.1
│ ├─┬ ethereum-ens@0.8.0
│ │ └── web3@1.2.11  deduped
│ └── web3@1.2.1
├─┬ @truffle/hdwallet-provider@1.0.43
│ └─┬ @types/web3@1.2.2
│   └── web3@1.2.11  deduped
└── web3@1.2.11

Many thanks!

Your Answer

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

Browse other questions tagged or ask your own question.