If trying to slice bytes in memory one gets the error below. The solidity docs give no explanation just state that array slices are only supported for calldata as of now.

TypeError: Index range access is only supported for dynamic calldata arrays.

Does anyone have a good technical reason for this? Thanks

1 Answer 1


in solidity the length of an array is stored right before the buffer. since calldata is a different buffer it's simple to just update the offset and length to the calldata, but when the buffer is in memory then the length of the new sliced buffer will overwrite the original buffer.

  • thanks can you explain this in easier terms?
    – FreddyC
    Oct 11, 2023 at 4:49

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.