I watched this video and he uses memory a lot like function verify(address _signer, string memory _message, bytes memory _sig. Why so? Could the function work without using memory?

While the usual function transferFrom(address owner, address buyer, uint256 numTokens) has no memory.

When do we use memory and when we don't have to use them?

  • 1
    you must either use calldata or memory by "string" and "arrays" i think. here is a more detailed answer about when to use calldata and when to use memory handle_bidder
    – Majd TL
    Commented Jan 10, 2022 at 11:40

1 Answer 1


As mentioned in the comment it depends on the type of your variable.

Many types are exactly 1 word (32 bytes) wide. These are called Value Types. As they have a constant width these normally exist on the stack.

Some other types (such as array based types like bytes or string) might take more storage and therefore are not kept on stack. The stack only keeps a reference to the data. They are called Reference Types. To know where the reference is pointing it is necessary to define the storage location, which might be calldata, memory and storage. Depending on the location the compiler will access the data differently. This is described in detail in the Data location section.

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.