Awesome
Notes on Solidity
Solidity is an object-oriented, high-level language for implementing smart contracts. Smart contracts are programs which govern the behaviour of accounts within the Ethereum state.
Solidity was influenced by C++, Python and JavaScript and is designed to target the Ethereum Virtual Machine (EVM).
Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features.
With Solidity you can create contracts for uses such as voting, crowdfunding, blind auctions, and multi-signature wallets.
When deploying contracts, you should use the latest released version of Solidity. This is because breaking changes as well as new features and bug fixes are introduced regularly.
Documentation:
- Github: https://github.com/ethereum/solidity
- Read the Docs: https://docs.soliditylang.org/en/latest/
Solidity by Example
An introduction to Solidity with simple examples.
Examples
v0.8.10 - source code & license
- Hello World
- First App
- Primitive Data Types
- Variables
- Constants
- Immutable
- Reading and Writing to a State Variable
- Ether and Wei
- Gas and Gas Price
- If / Else
- For and While Loop
- Mapping
- Array
- Enum
- Structs
- Data Locations - Storage, Memory and Calldata
- 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
- Creating Contracts from a Contract
- Try / Catch
- Import
- Library
- ABI Encode
- ABI Decode
- Hashing with Keccak256
- Verifying Signature
- Gas Optimizations
- Bitwise Operators
Applications
- Ether Wallet
- Multi Sig Wallet
- Merkle Tree
- Iterable Mapping
- Precompute Contract Address with Create2
- ERC20
- ERC721
- Minimal Proxy Contract
- Upgradeable Proxy
- Deploy Any Contract
- Write to Any Slot
- Uni-Directional Payment Channel
- Bi-Directional Payment Channel
- English Auction
- Dutch Auction
- Crowd Fund
- Multi Call
- Multi Delegatecall
- Time Lock
Hacks
- Re-Entrancy
- Arithmetic Overflow and Underflow
- Self Destruct
- Accessing Private Data
- Delegatecall
- Source of Randomness
- Denial of Service
- Phishing with tx.origin
- Hiding Malicious Code with External Contract
- Honeypot
- Front Running
- Block Timestamp Manipulation
- Signature Replay
- Bypass Contract size Check
Tests
DeFi
- Uniswap V2 Swap
- Uniswap V2 Add Remove Liquidity
- Uniswap V2 Optimal One Sided Supply
- Uniswap V2 Flash Swap
- Uniswap V3 Swap
- Uniswap V3 Liquidity
- Uniswap V3 Flash Loan
- Uniswap V3 Flash Swap Arbitrage
- Chainlink Price Oracle
- Staking Rewards
- Discrete Staking Rewards
- Vault
- Constant Sum AMM
- Constant Product AMM
- Stable Swap AMM