Encode-Club-Solidity-Foundations / Lesson-02

4 stars 7 forks source link

Importing interface/contract address #9

Open Booker-CU opened 2 years ago

Booker-CU commented 2 years ago

In the example code, wouldn't HelloWorldInterface need to be imported in some way and/or have a contract address for it to be imported into our contract?

Like for Chainlink you have to import their interface at the top and then create an instance of their interface inside the contract. https://docs.chain.link/docs/consuming-data-feeds/

Are there different ways to code interfaces? thx

MatheusDaros commented 2 years ago

Hello @Booker-CU Thanks for the question. Interfaces can be either imported from another file or defined at the same file where the other(s) contract(s) is(are). As for the usage, it could be inherited by other contracts and even interfaces, or it could be used to define a contract interface for an address and allow external calls for it.