Skip to content

Solidity

Examples

  • kalidao - programmable structures for web3 companies and funds
  • https://github.com/edendao/protocol
  • https://github.com/GiupiDeLuca/Solidity-Samples/blob/main/MultiSig.sol
  • https://github.com/mangrovedao/mangrove
  • https://github.com/optionality/clone-factory
  • https://github.com/trufflesuite/solidity-test-cases/tree/master/library-collision-test

Core language concepts...

  • Contracts
  • Delegates
  • Enums
  • Events
  • Functions
  • Interfaces
  • Mappings
  • Modifiers

Data Types

  • uint
  • string
  • boolean
  • struct
  • address
  • mapping

Mappings

  • When a mapping has public visibility, a getter function is intrinsically generated for accessing

Patterns

Libraries

Utilities

Units & Global Variables

https://docs.soliditylang.org/en/v0.7.5/units-and-global-variables.html

Inheritance

Errors

Examples

  • out-of-gas
  • divide by zero
  • data type overflow
  • array-out-of-index

Error Handing

  • require - Note that โ€˜Requireโ€™ consumes GAS unless it hits the REVERT opcode and so it is important that โ€˜requireโ€™ statements should generally be placed at the beginning of the function
  • assert
  • revert

new keyword

  • "Using the new keyword is a design time static creation of a smart contract"

Inline Assembly

Mixing of "both Solidity statements and Assembly code in the same smart contract".

  • Memory (MLOAD, MSTORE, etc) slots and storage (SLOAD, SSTORE, etc) slots are both accessible

Storage

Order

  1. events
  2. modifiers
  3. constructor
  4. external
  5. external view
  6. external pure
  7. public
  8. public view
  9. public pure
  10. internal
  11. internal view
  12. internal pure
  13. private
  14. private view
  15. private pure