Skip to content

πŸ’°This collection features a diverse range of real-world smart contract examples and projects written in Solidity, covering decentralized finance, NFTs, DAOs, gaming, supply chain management, tokenization, prediction markets, and identity verification systems.

License

Notifications You must be signed in to change notification settings

supercodestart/solidity-examples

Hits GitHub forks GitHub Discussions GitHub Issues GitHub License GitHub Repo stars GitHub top language GitHub repo file or directory count GitHub code size in bytes GitHub repo size GitHub Release GitHub Tag

Auto Assign CodeQL Proof HTML

Solidity Examples

This is a compilation of Solidity examples that I worked on while learning about Solidity and developing smart contracts.

Nearly all the smart contracts are accompanied by tests, so feel free to experiment with them to gain a deeper understanding of the Solidity programming language and the business logic within the contracts themselves.

Table of Contents

Basic

  1. Hello World
  2. First App
  3. Primary Data Types
  4. Variables
  5. Constants
  6. Immutable
  7. Reading & Writing to a State Variable
  8. Ether and Wei
  9. Gas and Gas Price
  10. If and Else
  11. For and While Loop
  12. Mapping
  13. Array
  14. Enum
  15. Structs
  16. Data Locations - Storage, Memory, and Calldata
  17. Transient Storage 🚧
  18. Function
  19. View and Pure Functions
  20. Error
  21. Function Modifier
  22. Events
  23. Constructor
  24. Inheritance
  25. Shadowing Inherited State Variables
  26. Calling Parent Contracts
  27. Visibility
  28. Interface
  29. Payable
  30. Sending Ether (transfer, send, call)
  31. Fallback
  32. Call
  33. Delegatecall
  34. Function Selector
  35. Calling Other Contract
  36. Contract that creates other contracts
  37. Try Catch
  38. Import
  39. Library
  40. ABI Encode
  41. ABI Decode
  42. Hashing with Keccak256
  43. Verifying Signature
  44. Gas Saving Techniques
  45. Bitwise Operators
  46. Unchecked Math
  47. Assembly Variable
  48. Assembly Conditional Statements
  49. Assembly Loop
  50. Assembly Error
  51. Assembly Math

Applications

  1. Ether Wallet
  2. Multi-Sig Wallet
  3. Merkle Tree
  4. Iterable Mapping
  5. ERC20
  6. ERC721
  7. ERC1155
  8. Gasless Token Transfer 🚧
  9. Simple Bytecode Contract
  10. Precompute Contract Address with Create2
  11. Minimal Proxy Contract
  12. Upgradeable Proxy 🚧
  13. Deploy Any Contract

Contributors

We enthusiastically welcome pull requests from all contributors. By actively participating in submitting examples, we firmly believe that others will find them invaluable when embarking on their Solidity journey.

@james-gates-0212 @clive-goldminer @dragon-8800

License

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

Preparation

npm i -g pnpm
pnpm install

Git commit

Note

Please use Conventional Commits for your commits.

e.g.

{emoji}<type>[scope]: <subject>
[body]
[footer]

Types

Important

type should be one of belows.

add
adopt
apply
build
chore
config
delete
docs
feat
fix
init
refactor
remove
style
test
update
upgrade

Emoji

Important

Your commit should start with gitmoji code.
Please check the emoji code on https://gitmoji.dev/

Description Emoji Code
Add a dependency. βž• :heavy_plus_sign:
Add a failing test. πŸ§ͺ :test_tube:
Add or update a .gitignore file. πŸ™ˆ :see_no_evil:
Add or update an easter egg. πŸ₯š :egg:
Add or update analytics or track code. πŸ“ˆ :chart_with_upwards_trend:
Add or update animations and transitions. πŸ’« :dizzy:
Add or update assets. 🍱 :bento:
Add or update business logic. πŸ‘” :necktie:
Add or update CI build system. πŸ‘· :construction_worker:
Add or update code related to multithreading or concurrency. 🧡 :thread:
Add or update code related to validation. 🦺 :safety_vest:
Add or update comments in source code. πŸ’‘ :bulb:
Add or update compiled files or packages. πŸ“¦οΈ :package:
Add or update configuration files. πŸ”§ :wrench:
Add or update contributor(s). πŸ‘₯ :busts_in_silhouette:
Add or update development scripts. πŸ”¨ :hammer:
Add or update documentation. πŸ“ :memo:
Add or update healthcheck. 🩺 :stethoscope:
Add or update license. πŸ“„ :page_facing_up:
Add or update logs. πŸ”Š :loud_sound:
Add or update secrets. πŸ” :closed_lock_with_key:
Add or update seed files. 🌱 :seedling:
Add or update snapshots. πŸ“Έ :camera_flash:
Add or update text and literals. πŸ’¬ :speech_balloon:
Add or update the UI and style files. πŸ’„ :lipstick:
Add or update types. 🏷️ :label:
Add sponsorships or money related infrastructure. πŸ’Έ :money_with_wings:
Add, update, or pass tests. βœ… :white_check_mark:
Add, update, or remove feature flags. 🚩 :triangular_flag_on_post:
Begin a project. πŸŽ‰ :tada:
Catch errors. πŸ₯… :goal_net:
Critical hotfix. πŸš‘οΈ :ambulance:
Data exploration/inspection. 🧐 :monocle_face:
Deploy stuff. πŸš€ :rocket:
Deprecate code that needs to be cleaned up. πŸ—‘οΈ :wastebasket:
Downgrade dependencies. ⬇️ :arrow_down:
Fix a bug. πŸ› :bug:
Fix CI Build. πŸ’š :green_heart:
Fix compiler / linter warnings. 🚨 :rotating_light:
Fix security or privacy issues. πŸ”’οΈ :lock:
Fix typos. ✏️ :pencil2:
Improve accessibility. ♿️ :wheelchair:
Improve developer experience. πŸ§‘β€πŸ’» :technologist:
Improve performance. ⚑️ :zap:
Improve SEO. πŸ”οΈ :mag:
Improve structure / format of the code. 🎨 :art:
Improve user experience / usability. 🚸 :children_crossing:
Infrastructure related changes. 🧱 :bricks:
Internationalization and localization. 🌐 :globe_with_meridians:
Introduce breaking changes. πŸ’₯ :boom:
Introduce new features. ✨ :sparkles:
Make architectural changes. πŸ—οΈ :building_construction:
Merge branches. πŸ”€ :twisted_rightwards_arrows:
Mock things. 🀑 :clown_face:
Move or rename resources (e.g.: files, paths, routes). 🚚 :truck:
Perform database related changes. πŸ—ƒοΈ :card_file_box:
Perform experiments. βš—οΈ :alembic:
Pin dependencies to specific versions. πŸ“Œ :pushpin:
Refactor code. ♻️ :recycle:
Release / Version tags. πŸ”– :bookmark:
Remove a dependency. βž– :heavy_minus_sign:
Remove code or files. πŸ”₯ :fire:
Remove dead code. ⚰️ :coffin:
Remove logs. πŸ”‡ :mute:
Revert changes. βͺ️ :rewind:
Simple fix for a non-critical issue. 🩹 :adhesive_bandage:
Update code due to external API changes. πŸ‘½οΈ :alien:
Upgrade dependencies. ⬆️ :arrow_up:
Work in progress. 🚧 :construction:
Work on code related to authorization, roles and permissions. πŸ›‚ :passport_control:
Work on responsive design. πŸ“± :iphone:
Write bad code that needs to be improved. πŸ’© :poop:
Write code drunkenly. 🍻 :beers:

About

πŸ’°This collection features a diverse range of real-world smart contract examples and projects written in Solidity, covering decentralized finance, NFTs, DAOs, gaming, supply chain management, tokenization, prediction markets, and identity verification systems.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5