A hands-on educational project for learning Solidity smart contract development using Truffle Suite. This repository follows a progressive learning path, starting with simple contracts and advancing toward complex patterns like DAOs and NFT marketplaces.
This project is designed for study purposes to practice and understand:
- Solidity programming fundamentals
- Smart contract patterns (access control, pausable, reentrancy guards)
- Testing smart contracts with Truffle/Mocha
- Deploying to local and test networks
See CHALLENGE.md for the complete learning roadmap with 9 progressive challenges.
- Solidity 0.8.21 - Smart contract language
- Truffle Suite - Development framework
- Ganache - Local Ethereum blockchain
- Web3.js - Ethereum JavaScript API
- Mocha - Testing framework
- Infura - Ethereum node provider (for testnet deployment)
smart-contract/
├── contracts/ # Solidity smart contracts
├── migrations/ # Truffle deployment scripts
├── test/ # Contract test files
├── build/ # Compiled contract artifacts (generated)
├── truffle-config.js # Truffle configuration
├── package.json # Node.js dependencies
├── .env.example # Environment variables template
├── CHALLENGE.md # Learning roadmap
└── README.md # This file
-
Clone the repository:
git clone [email protected]:allanbatista/study-smart-contracts.git cd smart-contract
-
Install dependencies:
yarn install
-
Copy the environment file and configure it:
cp .env.example .env
Edit
.envwith your credentials (required for testnet deployment only).
-
Start a local blockchain:
npx ganache
-
In another terminal, compile contracts:
npx truffle compile
-
Deploy contracts to local network:
npx truffle migrate
-
Run tests:
npx truffle test
-
Configure
.envwith your credentials:INFURA_PROJECT_ID: Get from InfuraPRIVATE_KEY: Your wallet private key (never commit this!)
-
Get test ETH from a faucet (see Testnet Resources)
-
Deploy to Sepolia:
npx truffle migrate --network sepolia
| Contract | Description |
|---|---|
CounterContract |
Basic counter with increment functionality |
CounterWithOwnerContract |
Counter with owner access control and pause functionality |
Run all tests:
npx truffle testRun a specific test file:
npx truffle test test/counter_contract.js- Faucet: https://cloud.google.com/application/web3/faucet/ethereum/sepolia
- Explorer: https://sepolia.etherscan.io/
- Faucet: https://www.bnbchain.org/en/testnet-faucet
- Explorer: https://bscscan.com/
This project follows a progressive learning path with 9 challenges:
- Counter with Owner + Pausable - Access control and pause functionality
- Whitelist / Allowlist - Permission management with mappings
- Vault (Cofrinho) - ETH deposits/withdrawals with reentrancy guards
- ERC-20 Token - Standard token implementation from scratch
- Crowdfunding - Goal-based fundraising with deadlines and refunds
- Auction - Bidding system with pull payments
- NFT ERC-721 - Non-fungible tokens with supply caps
- NFT Marketplace - List, buy, sell NFTs with royalties
- DAO - Governance with proposals, voting, and timelock
See CHALLENGE.md for detailed requirements of each challenge.
My first transaction ever (on Sepolia): 0x450604f90aec9268e8f6d714b7ee88d638c22021e0c5becf2c5a62c20b7ec596