Variables & Data Types
Explore Solidity's fundamental data types (uint, address, bool, bytes) and how to declare and use variables within smart contracts.
Variables & Data Types: The Basics
Welcome to Lesson 2! In Solidity, just like other programming languages, we need ways to store and manage information.
This is where variables and data types come in handy. They are fundamental for building any smart contract.
- Variables: Think of them as containers that hold a specific piece of data.
- Data Types: Define what kind of data a variable can hold (e.g., numbers, text, true/false).
Storing Whole Numbers: `uint`
The uint data type is used to store unsigned integers. 'Unsigned' means they can only hold positive whole numbers (including zero).
uintcan range fromuint8(8 bits) up touint256(256 bits).uint256is the default if you just writeuint.- These are perfect for token balances, counts, or IDs.
All lessons in this course
- Introduction to Solidity
- Variables & Data Types
- Functions & Control Structures