My beginner friendly Solidity project demonstrating the basic smart contract functionality, including state management, structs, arrays, mappings, and contract factory patterns.
- ✨ Overview
- 📜 Contracts
- 🚀 Getting Started
- 💡 Usage
- 📁 Project Structure
- 👤 Author
- 🙏 Acknowledgements
- 🤝 Contributing
This project contains two Solidity smart contracts that demonstrate the fundamental Ethereum development concepts:
- SimpleStorage: A basic contract that stores and retrieves numbers, and manages a list of people with their favorite numbers
- StorageFactory: A factory contract that creates and manages multiple instances of SimpleStorage contracts
These contracts are ideal for learning Solidity and cover essential concepts like:
- State variables and visibility
- Functions and function modifiers
- Structs, arrays, and mappings
- Contract deployment and interaction
- Basic inheritance (virtual functions)
The SimpleStorage contract provides basic storage functionality with the following features:
- Store and retrieve a single number
- Add people with names and their favorite numbers
- Track all added people in an array
- Look up favorite numbers by name using a mapping
The StorageFactory contract demonstrates the factory pattern by:
- Creating multiple instances of SimpleStorage contracts
- Keeping track of all created contracts
- Providing functions to interact with any created contract
- Clone or download this project
- Install dependencies (if using a development framework like Hardhat or Truffle)
- Set up your development environment
For a simple test environment, you can use Remix IDE:
- Go to https://remix.ethereum.org/
- Create a new file named
SimpleStorage.sol
and paste the first contract - Create another file named
StorageFactory.sol
and paste the second contract
If using Remix:
- Open the Solidity compiler plugin
- Select compiler version 0.8.19 or higher
- Compile each contract separately
While this project doesn't include tests, you can deploy and test the contracts:
- Deploy SimpleStorage first
- Then deploy StorageFactory (pointing to the SimpleStorage address if needed)
- Use the provided functions to interact with the contracts
After deploying SimpleStorage, you can:
- Store a number: Call
store()
with any uint256 value - Retrieve the number: Call
retrieve()
to get the stored value - Add a person: Call
addPerson()
with a name and favorite number - View people: Check the
listOfPeople
array to see all added persons - Look up by name: Use the
nameToFavouriteNumber
mapping to find a person's favorite number by name
After deploying StorageFactory, you can:
- Create new SimpleStorage contracts: Call
createSimpleStorageFactory()
to deploy new instances - Access created contracts: View all created contracts in the
listOfSimpleStorageContracts
array - Interact with specific contracts: Use
sfStore()
andsfGet()
with the contract index to modify and read values
project-root/
│
├── contracts/
│ ├── SimpleStorage.sol
│ └── StorageFactory.sol
│
├── scripts/
│ ├── deploy.js (optional)
│ └── interact.js (optional)
│
└── README.md
JESSE
Beginner Solidity Developer
- Learning blockchain development and smart contract programming
- Exploring the Ethereum ecosystem
This project was built during my learning phase with guidance from excellent educational resources:
- Cyfrin Updraft: For their comprehensive smart contract development courses
- Patrick Collins: For his exceptional teaching style and making complex concepts accessible to beginners
- The entire Cyfrin team for creating valuable learning materials for the Web3 community
Special thanks to the open-source community and all the developers who share their knowledge to help others learn and grow.
This is a learning project, but if you'd like to suggest improvements:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request