Where you can store data in Solidity
There are a few place you can store data in your Solidity apps, this guide will explain what they are
Table of Contents for Where you can store data in Solidity
Main 3 types of storing values/data in Solidity smart contracts
Memory
- temporarily stored in memory, only there while your functions are running
- not stored in blockchain
- mutatable
Calldata
- similar to memory but is immutable
- calldata is used for the args when you call a function on a smart contract
- See a more in-depth article about calldata here.
Storage
- storage data is stored on blockchain
- Mutable
- costs quite a bit in gas to store new data. Costs a bit less to update existing data. Can get a gas refund for deleting (setting slot to zero value)
Other ways of storing data
- Logs
- Stack
This post is incomplete and a work-in-progress
I'll update it soon and flesh it out with
more
info!
Spotted a typo or have a suggestion to make this crypto dev article better? Please let me know!
Next post
Previous post
π Solidity Auditing online quiz
Learn how to audit smart contracts by looking at some example code and trying to find the bugs
β½ Solidity Gas Optimizations Guide
How to optimize and reduce gas usage in your smart contracts in Solidity
π§ͺ Guide to testing with Foundry
Guide to adding testing for your Solidity contracts, using the Foundry and Forge tools
π Guide to UTXO
UTXO and the UTXO set (used by blockchains such as Bitcoin) explained
π Solidity Assembly Guide
Introduction guide to using assembly in your Solidity smart contracts
π¦ Ethereum EOF format explained
Information explaining what the upcoming Ethereum EOF format is all about