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?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityStrings 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