I have private/local network/chain setup. I'm building this with Nodejs-->expressjs.

const contract = new web3.eth.Contract(abi, address);

const batch = new web3.BatchRequest();
    batch.add(contract.methods.balance(address).sent.request({from: '0x0000000000000000000000000000000000000000'}));
    batch.execute().then((error,result) =>{
if(!error) console.log(result);
else console.log(error);

batch.execute() gives "(node:31377) UnhandledPromiseRejectionWarning: TypeError: method.callback is not a function" error. As i worked more on it by putting console.log()'s i came to know that this issue is from batch.execute()... . I also tried to remove then() and try, it gave same error. Also found this in node_module/web3/web-core.cjs

export class BatchRequest {
constructor(moduleInstance: AbstractWeb3Module);

add(method: AbstractMethod): void;

execute(): Promise<{methods: AbstractMethod[]; response: any[]} | Error[]>;

where execute() is a method.

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.