2

I wonder where strings are stored in Solidity?

Especially, where are string literals, function arguments, and variables stored?

I recall, I've read that strings cannot be saved to memory, but is that right?

1

Strings can be stored in both Storage and Memory - it depends on the type of variable / usage - here's an example:


pragma solidity ^0.4.17;

contract StorageTest {

    string string1; // string1 is storage

    function func1(string param1) public pure { // param1 is memory
        string memory string2 = "foo";  // string2 is memory in this instance
    }
}

There's a great section in the Solidity documentation

And also a great answer from @eth about memory in Ethereum

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.