1

I have this piece of code from a solidity contract:

function loadMintIDs(uint256[MAX_TOKENS + 1] memory array)  external onlyOwner {
        require(array.length == MAX_TOKENS + 1, "List of IDs must be MAX_TOKENS + 1");
        require(!IDsLoaded, "List of IDs is already loaded.");    
        IDs = array;
        IDsLoaded = true;
    }

How do I pass an array of numbers to the function in Etherscan? I tried [0, 61, 201, 31, 728 ...] (1001 values), but get this error back in Etherscan:

invalid BigNumber string (argument="value", value=" 61", code=INVALID_ARGUMENT, version=bignumber/5.1.1)

The error is the first value in the array after 0. I think 0 is always seen as an uint256, but how should the other numbers be formatted? I like passing an array with 'normal' numbers best, so maybe I need my array declaration in the function to not be uint256, but what then?

Swerfer
  • 345
  • 1
  • 9

1 Answers1

1

You have to pass it in as an array of Hex values.

Example:

uint256 9, 9 -> [0x9,0x9]

uint256 100, 100, 100 -> [0x64,0x64,0x64]

Decimal to Hex converter:

https://www.rapidtables.com/convert/number/decimal-to-hex.html

shanq.eth
  • 81
  • 3