This is a collection of solidity examples that I practiced while I was learning about Solidity and writing smart contracts.
Almost all smart contracts have tests with them, so feel free to play around with them to understand more about Solidity programming language or business logic in the contract itself.
$ npm install
$ npx hardhat test
- Data types
- Constructors
- Variables
- Functions
- Visibility
- Pure and View
- Function modifiers
- Gas
- Events
- Error handling
- Fallback function
- For Loop
- Array
- Mapping
- Enum
- Struct
- Payable modifier
- Import into a contract
- Contract cleanup
- Memory vs storage
- Inheritance
- If statements
- Libraries
- Interface
- Sample Contract
- Address Book
- Hotel Room
- Time lock
- ERC20 Token
- Shared Wallet
- Swap Token
- ETH Game
- Ballot
- Vault / Liquidity Pool
- Flash Loan. (See more resources)
- Uniswap - Simple Swap
- NFT Smart Contract ECR-721
- Buy Me A Coffee
- NFTs with On-Chain Metadata
- NFT Gallery
- Connect APIs to your Smart Contracts using Chainlink
We love pull requests from everyone. By participating in submitting examples, we believe other people will find them useful when they getting started with Solidity.
The software is available as open source under the terms of the MIT License.