When attempting to send a batch request of transactions to my contract from web3, I encountered an issue with typing in the .request
method. My contract's methods are defined as
NonPayableTransactionObject<void>
using Typechain, and it seems that this type does not support the necessary typing for the .request
method when using batch.add()
. For instance...
let batch = new web3.eth.BatchRequest();
for (let id of tokenIDs) {
batch.add(myContract.methods.myMethod(id).send.request({ from: defaultAccount })
}
batch.execute();
This results in the error message
Property 'request' does not exist on type '(tx?: NonPayableTx | undefined) => PromiEvent<TransactionReceipt>'.ts(2339)
.
I'm wondering if there is an alternative approach to sending transactions to a contract via Batch Request using Typescript/Typechain?