3

suppose one of the function input parameter is bool[] testInput sometimes I want to pass 0 length array like this => [] instead of this => [true,false,true], how does it possible with etherscan.io.

For example, how do you pass an empty array to function cmp in this contract on Ropsten?

8
  • Are you trying to remove testInput elements by passing 0 length array? ( btw i don't understad what you mean by saying "doing this with etherscan.io")
    – Masoud jt
    Commented Jun 8, 2020 at 7:34
  • That's a damn good question, it seems that they haven't thought of that possibility on Etherscan! Commented Jun 8, 2020 at 7:37
  • @Masoudjt: What's not to understand here? He/she is trying to pass [] to a contract function using etherscan web-page. Commented Jun 8, 2020 at 7:38
  • @goodvibration oh thanks, i get it now. but i think he can't do that if the function in the contract doesn't have a solution to handle that empty array. can he? i'm testing that but it gives runtime error while i'm calling testInput after passing [] to the function which is assigning the passed parameter to testInput. ( error = invalid opcode)
    – Masoud jt
    Commented Jun 8, 2020 at 7:45
  • @Masoudjt: What has that got to do with whether or not the function in the contract can handle an empty array??? Assume that there is a function in the contract which takes an array as input. How do you call that function with an empty array from etherscan? Commented Jun 8, 2020 at 7:52

1 Answer 1

2

Short answer - It isn't possible through Etherscan's Write Contract at the moment, since Etherscan's write contract functionality uses a customised encoder (which strips empty brackets denoting an empty array, and replaces it with an empty string), then passes the information wrongly to Web3.

This is being reported to them and they'll be looking into it.

enter image description here

Update 2020-07-11: And it's fixed. :)

enter image description here

1
  • 1
    Hi. So how do you enter in an empty string then? When I try on polygonscan (presumably the same thing near enough as etherscan) it refuses to trigger the transaction if there is an empty string field. Commented Jul 19, 2021 at 20:28

Your Answer

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

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