Inheritance
In Solidity, inheritance works by means of a keyword, is
, which is used to indicate that one contract inherits from another.
Example
Contract B inherits from the contract A.
This means that B will have access to the
foo()
function defined in A. In addition, it will also have its ownbar()
function.
Import + Inherit
ModifierExample contract inherits all the functionality of the base contract.
It means that when you instantiate the contract, a single object code (i.e., a single contract instance) containing all of that functionality is deployed on the network. Any call to a function of the base contract yields a non-external function call.
On deployment, there is only a single address.
Last updated