1

Using python web3 module, attempting to call a contract function that takes one argument, a list of 48 uints:

function checkOrderBatch(uint[48] input) external view returns(uint16[16] status, uint[16] amount) { ...

Calling the function like so:

res = contract.functions.checkOrderBatch(o).call()

Where o is my input.

I've been able to successfully interact with this contract already with the python web3 module, but everything I try for this function returns an error about my input values.

Here are the things I've tried, and the errors I've recieved:

  1. Input: List of 48, with each element being a string of the following form

    '0x0160e8043c35120bde2b0788f918bdd57160a127d2d56cea9c24a1342b45320c'

    Error:

Could not identify the intended function with name checkOrderBatch, positional argument(s) of type (<class 'list'>,) and keyword argument(s) of type {}. Found 1 function(s) with the name checkOrderBatch: ['checkOrderBatch(uint256[48])'] Function invocation failed due to improper argument encoding.

  1. Input: List of 48, with each element being bytes of the following form

    b'0160e8043c35120bde2b0788f918bdd57160a127d2d56cea9c24a1342b45320c'

    Error: Same as #1

  2. Input: List of 48, with each element being a string of the following form

    '0160e8043c35120bde2b0788f918bdd57160a127d2d56cea9c24a1342b45320c'

    Error: Same as #1

  3. Input: List of 48, with each element being bytes of the follow form

    b'0x0160e8043c35120bde2b0788f918bdd57160a127d2d56cea9c24a1342b45320'

    Error: Same as #1

  4. Input: 48 separate arguments. Error: As expected, incorrect number of arguments.

Clearly I'm not an expert in the data types intended here, so I'm likely doing something stupid. But I can't seem to figure it out. Any help would be greatly appreciated!

If you would like something to test, here is the specific contract:

https://etherscan.io/address/0x37304b0ab297f13f5520c523102797121182fb5b#code

The function is checkOrderBatch. It is a view function, so you can mess with it without wasting gas. If you can submit anything to it and get past the point I got, that's all I need! It's ok if the function returns an error. I just need to get the encoding right.

Thank you!

  • 1
    I would think it should be a list of numbers: [0, 1, 2, ...] – user19510 Aug 16 '18 at 15:35
  • Thx smarx. So are you saying i should do hex to decimal conversion on those strings? I know the content that needs to go in, just not the proper encoding – user44891 Aug 16 '18 at 15:43
2

I knew I was doing something stupid due to being relatively new to this ...

For anyone who's curious, this is what I was missing:

int(your_string_here,16)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.