Array.length cause "stack too deep" error

I’m making an erc1155 reciever and I get a strange error “stack too deep”, but only if I use the array.length of the “tokenIds” argument, if I use the “amounts” argument it doesn’t happen…

does anyone know why?

hey,
If you get this error it probably means you have too many function arguments, local variables or return values in your function.
you can try to split your solidity functions into two and if you are using string for some vars which are not so long, you can change them to byte32.

2 Likes

@liron As fas as i can see from the syntax, lenght in an in-built solidity keyword avoid using it.

apart from that EVM stack has 16 slots, if you try referencing a variable higher than 16 then you get the error

check this link: https://soliditydeveloper.com/stacktoodeep

1 Like