Skip to content

0xDevNinja/solidity-examples

Repository files navigation

Solidity Examples

CI

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.

How to Run

$ npm install
$ npx hardhat test

Getting Started with Solidity

  1. Data types
  2. Constructors
  3. Variables
  4. Functions
  5. Visibility
  6. Pure and View
  7. Function modifiers
  8. Gas
  9. Events
  10. Error handling
  11. Fallback function
  12. For Loop
  13. Array
  14. Mapping
  15. Enum
  16. Struct
  17. Payable modifier
  18. Import into a contract
  19. Contract cleanup
  20. Memory vs storage
  21. Inheritance
  22. If statements
  23. Libraries
  24. Interface

Sample Apps

  1. Sample Contract
  2. Address Book
  3. Hotel Room
  4. Time lock
  5. ERC20 Token
  6. Shared Wallet
  7. Swap Token
  8. ETH Game
  9. Ballot
  10. Vault / Liquidity Pool
  11. Flash Loan. (See more resources)
  12. Uniswap - Simple Swap
  13. Crowdfunding

ERC Standards

  1. ERC1155 GameItems
  2. ERC2612 Permit Token
  3. ERC4626 Tokenized Vault

Security Patterns

  1. Reentrancy Attack Demo
  2. Pull Payment Auction
  3. ECDSA Signature Verifier
  4. Commit-Reveal Voting
  5. EIP-712 Typed Data Signer

DeFi Primitives

  1. Merkle Airdrop
  2. Linear Vesting
  3. Staking Rewards
  4. Constant Product AMM
  5. Bonding Curve Token

Upgradeability

  1. UUPS Upgradeable Counter
  2. Transparent Proxy Box
  3. Minimal Diamond (EIP-2535)

Governance

  1. Simple Token-Weighted DAO
  2. Governor + Timelock

Account Abstraction

  1. Simple Account (ERC-4337 minimal)
  2. Paymaster

Road to Web3

  1. NFT Smart Contract ECR-721
  2. Buy Me A Coffee
  3. NFTs with On-Chain Metadata
  4. NFT Gallery
  5. Connect APIs to your Smart Contracts using Chainlink

Solidity by Examples

  1. Ether Wallet
  2. Multi Sig Wallet
  3. Wrapped ETH (WETH)

License

The software is available as open source under the terms of the MIT License.

About

Solidity tutorials and sample contracts — learning reference covering patterns and DeFi primitives.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors