Interface
You have interacted with a smart contract as a user, but a smart contract can also interact with another smart contract using an interface.
Let’s create a smart contract that interacts with the Storage.vy
smart contract that you deployed previously, by creating StorageClient.vy
and adding the following code to it:
# @version ^0.3.0 interface Storage: def retrieve() -> uint256: view storage_contract: Storage @external def __init__(storage_address: address): self.storage_contract = Storage(storage_address) @external def call_retrieve() -> uint256: return self.storage_contract.retrieve()
You know that there is a retrieve
method for Storage.vy
. To interact with this method on Storage.vy
, you create an interface, and then inside it, you define the method with the same name. You must also add the argument’s signature and the return value. You can omit the definition of the retrieve...