The web3.js API allows for synchronous RPC batch requests with the example given as:

var batch = web3.createBatch();
    '0x0000000000000000000000000000000000000000', 'latest', callback));
batch.add(web3.eth.contract(abi).at(address).balance.request(address, callback2));

However when I try to implement it in my frontend like this:

var batch = web3.createBatch();
batch.add(currentK.claimFor.request(holderAddr.get(),{from:holderAddr.get(), gas:300000}));
batch.add(currentK.claimFor.request(to,{from:holderAddr.get(), gas:300000}));
batch.add(currentK.transfer.request(to, amount,{from:holderAddr.get(), gas:300000}));

...where claimFor is an ABI function. edit as ABI was incorrectHowever it bombs out and the console presents an error message:

The actual problem is that no activity is seen to be put against the blockchain.


logging to console through a callbacks on the added functions returns the error: Error: invalid argument 0: cannot unmarshal non-string as hex data. In both claimFor and transfer the first arg is a string containing a valid address.

  • Is transfer actually a function? I don't think this is a problem with the batch, it looks like either currentK.claimFor or currentK.transfer is undefined Apr 12 '17 at 4:09
  • Perhaps, but clearly one or both of the functions is undefined in your code, so make sure your contract definitions are correct. I.e. check what console.log(currentK.claimFor) returns Apr 12 '17 at 4:14
  • Sorry my bad. Was using an obsolete ABI. However with that corrected it's unmasked my original problem, in that no TX's are seen to be put against the chain. Editing question..
    – o0ragman0o
    Apr 12 '17 at 5:42
  • Are your callbacks executed? Apr 12 '17 at 12:42
  • Yes, that's how I'm getting the error message
    – o0ragman0o
    Apr 12 '17 at 22:38

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.