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.
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 community
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.
Here's the proof of work Ethereum Blockchain Mechanism