A beginner-friendly Solidity project built with :contentReference[oaicite:0]{index=0}.
This project demonstrates:
- Solidity basic data types
- State variables
- Structs
- Arrays
- Mappings
- Memory vs Storage vs Calldata
- Reading & writing blockchain state
- Deploying contracts with Foundry scripts
.
├── src/
│ └── SimpleStorage.sol
│
├── script/
│ └── DeploySimpleStorage.sol
│
├── test/
│
├── foundry.toml
└── README.md
A simple contract that stores and retrieves a favorite number while showcasing common Solidity concepts.
- Store and update a number
- Retrieve stored value
- Add people with favorite numbers
- Map names to favorite numbers
- Demonstrates:
booluintintstringaddressbytes32- arrays
- structs
- mappings
function store(uint256 _favNum) publicUpdates the stored favorite number.
function retrieve() public view returns (uint256)Returns the current favorite number.
function addPerson(string memory _name, uint256 _favNum) publicAdds a person and maps their name to a favorite number.
Deploys the SimpleStorage contract using Foundry scripting.
Uses:
vm.startBroadcast()vm.stopBroadcast()
to send deployment transactions.
git clone <REPOSITORY_URL>cd <PROJECT_DIRECTORY>If Foundry is not installed:
Follow the up to date installation through this link
Inside the project directory, install the dependencies:
forge installCompile the smart contracts.
forge buildTest files are not included yet.
A dedicated test suite using Forge will be added in future updates.
Example command once tests are implemented:
forge testFormat Solidity files.
forge fmtRun a local Ethereum development node using Anvil.
anvilcast wallet import local-deployer --interactiveYou will:
- paste your private key once
- create a secure password
The key will be encrypted and stored locally.
forge script script/DeploySimpleStorage.sol:DeploySimpleStorage \
--rpc-url http://localhost:8545 \
--account local-deployer \
--broadcastFoundry will securely prompt for your password.
Once the contract is deployed, you can interact with it using cast.
After deployment, copy the deployed contract address
This sends a transaction to update the state.
cast send <CONTRACT_ADDRESS> \
"store(uint256)" 42 \
--rpc-url http://localhost:8545 \
--account local-deployerstore(uint256)→ function being called42→ new favorite number--account local-deployer→ your saved wallet
This is a read-only call (no gas spent).
cast call <CONTRACT_ADDRESS> \
"retrieve()(uint256)" \
--rpc-url http://localhost:8545cast balance <YOUR_ADDRESS> --rpc-url http://localhost:8545You can inspect a transaction hash:
cast tx <TX_HASH> --rpc-url http://localhost:8545cast send→ writes to blockchain (state change)cast call→ reads from blockchain (no gas)--account [NAME]→ uses your secure wallet
cast --to-base 0xfd31c decPermanent blockchain data.
Temporary and modifiable during execution.
Temporary, read-only function input data.
Foundry, which includes:
- Forge → testing framework
- Cast → blockchain interaction CLI
- Anvil → local Ethereum node
- Chisel → Solidity REPL
MIT