Importing imports all the global symbols from the file being imported into the current global scope.
See the Solidity documentation for details on imports:
An example of importing where you are not inheriting is using utilities such as SafeMath or Counters:
is means that your contract inherits from another contract.
contract MyToken is ERC20 means that your token inherits from the OpenZeppelin Contracts ERC20 implementation.
See the Solidity documentation for details on inheritance:
Also see the OpenZeppelin Contracts documentation on extending:
An example of importing where you are inheriting is extending from ERC20Burnable and ERC20Pausable:
- simply importing an interface in the head of your sol file, versus
Importing an interface would allow you to declare variables of an interface type to interact with contracts using the interface.
See the Solidity documentation for details on interfaces:
An example of importing an interface where you are not inheriting is using IERC20 to interact with an ERC20 contract:
- importing that interface AND ALSO using the ‘is’ keyword referring to that interface in your contract declaration
Importing and inheriting from an interface is just like inheriting from any other contract. Just like an abstract contract you would need to implement the functions defined in the interface.
An example of importing and inheriting from an interface is inheriting from IERC20: