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.
- Hello World
- First App
- Primary Data Types
- Variables
- Constants
- Immutable
- Reading & Writing to a State Variable
- Ether and Wei
- Gas and Gas Price
- If and Else
- For and While Loop
- Mapping
- Array
- Enum
- Structs
- Data Locations - Storage, Memory, and Calldata
- Transient Storage π§
- Function
- View and Pure Functions
- Error
- Function Modifier
- Events
- Constructor
- Inheritance
- Shadowing Inherited State Variables
- Calling Parent Contracts
- Visibility
- Interface
- Payable
- Sending Ether (transfer, send, call)
- Fallback
- Call
- Delegatecall
- Function Selector
- Calling Other Contract
- Contract that creates other contracts
- Try Catch
- Import
- Library
- ABI Encode
- ABI Decode
- Hashing with Keccak256
- Verifying Signature
- Gas Saving Techniques
- Bitwise Operators
- Unchecked Math
- Assembly Variable
- Assembly Conditional Statements
- Assembly Loop
- Assembly Error
- Assembly Math
- Ether Wallet
- Multi-Sig Wallet
- Merkle Tree
- Iterable Mapping
- ERC20
- ERC721
- ERC1155
- Gasless Token Transfer π§
- Simple Bytecode Contract
- Precompute Contract Address with Create2
- Minimal Proxy Contract
- Upgradeable Proxy π§
- Deploy Any Contract
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.
The software is available as open source under the terms of the MIT License.
npm i -g pnpm
pnpm installNote
Please use Conventional Commits for your commits.
e.g.
{emoji}<type>[scope]: <subject>
[body]
[footer]
Important
type should be one of belows.
add
adopt
apply
build
chore
config
delete
docs
feat
fix
init
refactor
remove
style
test
update
upgrade
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: |


