I have a contract with the following mapping:
mapping (uint16 => uint256[]) public barLengthToBarIndexForSale;
What's the best way to retrieve the length of an array for a given key on the frontend using truffle?
Something like this...
barERC721Inst.barLengthToBarIndexForSale(5).length;
... seems to not work.
Using an additional function in my contract to retrieve the length...
function getBarLengthToBarIndexForSaleLength(uint16 _length) external view returns (uint) {
return barLengthToBarIndexForSale[_length].length;
}
...seems also not to work :(
I tried calling it on the frontend like this:
barERC721Inst.barLengthToBarAmtForSale.call(5)
and
barERC721Inst.barLengthToBarAmtForSale(5)
both throw errors.
Any help is appreciated.
_length
to_index
. Other than that, you'll need to explain what exactly "seems also not to work".