[Ethereum] Solidity mappings stored

remixsolcsolidity

Are Solidity mappings stored in memory or storage?

I know that keys are hashed to a unique identifier for the value, which is stored where?

I can't seem to find any clue in the documentation.

Best Answer

They will be in storage as memory should be cleared after each transaction. So if a mapping was anything but storage it would not persist. Anything defined within the scope of a contract will be stored in that contract's storage.

What is the memory keyword? What does it do? The Ethereum Virtual Machine has three areas where it can store items.

The first is “storage”, where all the contract state variables reside. Every contract has its own storage and it is persistent between function calls and quite expensive to use.

The second is “memory”, this is used to hold temporary values. It is erased between (external) function calls and is cheaper to use.

The third one is the stack, which is used to hold small local variables. It is almost free to use, but can only hold a limited amount of values.

See http://solidity.readthedocs.io/en/latest/frequently-asked-questions.html#what-is-the-memory-keyword-what-does-it-do

Here's the proof of work Ethereum Blockchain Mechanism

enter image description here

Also see Where are the variables of a smart contract stored?

Related Topic