This may be a dumb question, but I'm trying to understand is there a difference re: byte-wise or gas-wise in between using calldata and explicitly mentioning arguments. For example, for this struct:

struct Book {
    string: title;
    uint256: pages;

There is a makeBook function. Now, is there any difference in the following ways of writing the function?

/// Using calldata
function makeBook(Book calldata book) external {
    newBook = Book(book.title, book.pages);

/// Mentioning arguments
function makeBook(string title, uint256 pages) external {
    newBook = Book(title, pages);

1 Answer 1


You can think calldata is a special type of argument that can be used in external functions and can not be modifiable. If you do not use keyword memory or calldata, that argument can be considered as storage. The main difference between calldata(memory) and storage is the lifetime of the variable.

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.