I'm using Solidity 0.8.0 (so I'm using ABIEncoderV2) and web3.js 1.3.4 and I'm trying to call a contract's method passing a nested struct.

            [tokenAId, tokenBId],
            [tokenAAmount, tokenBAmount],
        ).send({ from: owner });

where my payload is

let payload = [
                    ['0x0000000000000000000000000000000000000000', '42', '43', true]

Since I take advantage of the ERC1155 callback onERC1155BatchReceived() in my orchestrator contract, currently I don't even load it in the front-end. I know that latest Solidity versions exposes struct informations in the ABIs, so maybe this could be part of the problem.

However, operationId is an uint256 and receiver is an address, in my contract I use two consecutive abi.decode(). [['0x0000000000000000000000000000000000000000', '42', '43', true] is a vector of struct such this:

struct MyStruct {
        address fieldA;
        uint256 fieldB;
        uint256 fieldC;
        bool fieldD;

Indeed one of these fields should be a struct itself, but even with the simplification I used here I get the same error when I try to send the transaction:

Error: invalid arrayify value (argument="value", value=["6",[[["0x0000000000000000000000000000000000000000","42","43",true]],"0x0000000000000000000000000000000000000000"]], code=INVALID_ARGUMENT, version=bytes/5.0.9)
    at t.value (index.ts:205)
    at t.value (index.ts:217)
    at t.value (index.ts:221)
    at c (index.ts:136)
    at r.value (bytes.ts:13)
    at array.ts:62
    at Array.forEach (<anonymous>)
    at m (array.ts:54)
    at r.value (tuple.ts:23)
    at t.value (abi-coder.ts:106)
  • The last parameter payload from safeTransferFrom is bytes, so you need to encode it as bytes. Since the correct encoding depends on the usage how is it decoded?
    – Ismael
    Commented Apr 1, 2021 at 17:00


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.