Vyper theorytheory 0/50 · 0%
Web3 integration · medium

30. Interfaces and implements

Declaring a contract's ERC compliance explicitly.

Beyond calling other contracts, you can declare that your own contract implements a given interface using `implements: InterfaceName`. The compiler then checks at compile time that every required function is present with a matching signature.

from vyper.interfaces import ERC20

implements: ERC20

@external
def transfer(to: address, amount: uint256) -> bool:
    ...

This turns a documentation promise ('this is an ERC-20') into a compiler-enforced guarantee, catching missing or mis-signatured functions before deployment.

Check your understanding

  1. 1. What does `implements: ERC20` do?

  2. 2. What happens if a required function is missing?

  3. 3. Where do standard interfaces like ERC20 commonly come from?