Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 1.9 KB

Part 7 - Writing Smart Contracts.md

File metadata and controls

46 lines (31 loc) · 1.9 KB

Inheritance

  • Inheritance in Solidity is similar to Python.
  • A contract that inherits code from another contract is deployed as a single contract. The derived contract inherits the functions and the state of the parent contract.
  • Contracts can inherit multiple contracts
  • Functions can also be overriden by specifying the same function name, inputs and outputs
  • Inheritance order matters! The base contract must be stated first followed by the next "most base like" contract.
  • Function modifier and event names must also be unqiue.

Abstract Contracts

  • Contracts that lack function implmentation are called Abastract Contracts.
  • They will not compile but can be used as base contracts for other contracts.

Interface Contracts

  • Similar to Abstract Contracts but do not have any functions implemented.
  • Cannot inherit from any other contracts
  • Does not contain:
    • Constructor
    • Variables
    • Structs
    • Enums

Libraries

  • A contract that does not have any storage and cannot hold ether is called a library.
  • Libraries are helpful because they allow developers to reference trusted functions rather than having to write functions for every task.
  • Libraries cannot have any payable or fallback functions nor can they inherit from any other contracts (although they can be linked to other libraries)
  • Libraries also dont have an event log, but they can dispatch events.

Resources

Contract-Contract Interaction

Difference between CALL, CALLCODE and DELEGATECALL

Interactions Between Contracts

Inheritance

Inheritance in Solidity

Libraries

Library Driven Development in Solidity