Hash map/Array as an argument in Solidity 0.8.4

Trying to refactor a smart contract and ideally need to either pass a hash map mapping(string => uint256) or an array uint256[5] as a function argument and then parse these args.

According to the official doc it is not possible to pass a hash map as an argument:

They cannot be used as parameters or return parameters of contract functions that are publicly visible. These restrictions are also true for arrays and structs that contain mappings.

But someone might know a work-around to get this working. Alternatively, when doing the following:

function _getArray() private view {
    return([uint256 a, uint256 b, uint 256 c])
}

I would like to then be able to do this:

function _foo(uint[3] array) private view {
    (uint256 a, uint256 b, uint256 c) = _getArray();
    --- SNIP ---
}

But the compiler is not having it and complains that that the number of args on the (right|left) side of this assignement do not match.

Any idea? :thinking:

1 Like

Did you manage to solve this somehow?

1 Like