Skip to content

Latest commit

 

History

History
28 lines (26 loc) · 1.17 KB

Library Restrictions.md

File metadata and controls

28 lines (26 loc) · 1.17 KB

In comparison to contracts, libraries are restricted in the following ways:

  1. They cannot have state variables
  2. They cannot inherit nor be inherited
  3. They cannot receive Ether
  4. They cannot be destroyed
  5. It can only access state variables of the calling contract if they are explicitly supplied (it would have no way to name them, otherwise)
  6. Library functions can only be called directly (i.e. without the use of DELEGATECALL) if they do not modify the state (i.e. if they are view or pure functions), because libraries are assumed to be stateless

Slide Screenshot

113.jpg


Slide Text

  • No State Variables
  • X -> Inherit or Inheritied
  • X -> Receive Ether
  • X -> Be Destroyed
  • Calling Contract -> Only State Vars Supplied
  • Directly vs. delegatecall
  • pure or view Functions

References


Tags

OZ LibrariesselfdestructInheritanceStorage Layout & Inheritance