An external interface can be generated by vyper as such:

vyper -f external_interface contracts/CurveCryptoSwap.vy

Doing that results in the following output:

# External Interfaces
interface Curvecryptoswap:
    def __default__(): payable
    def price_oracle(k: uint256) -> uint256: view
    def price_scale(k: uint256) -> uint256: view
    def last_prices(k: uint256) -> uint256: view

But where exactly does this go? Vyper's documentation on external interfaces states:

The output can then easily be copy-pasted to be consumed.

I tried saving it to <brownie_project>/interfaces/ICurveCryptoSwap.vy but brownie does not see it...

>>> from brownie import interface
>>> pool = interface.Curvecryptoswap(...)
AttributeError: 'InterfaceContainer' object has no attribute 'Curvecryptoswap'

All this is no problem when using vyper -f abi, but the resulting JSON file is just so messy; the external interface provides much cleaner code to read.

  • My working import (which you helped me accomplish) is import interfaces.ifoo as IFoo. Do you need to import your generated file with the relative path: import interfaces.ICurveCryptoSwap? I'm not a Python dev, so I'm discovering its import syntax by trial-and-error.
    – devdanke
    Commented Dec 6, 2022 at 16:16

2 Answers 2


The steps described in the question are correct:

$ vyper -f external_interface contracts/Contract.vy


# External Interfaces
interface Contract:
    def __default__(): payable

save this to a file in the interfaces folder, eg interfaces/IContract.vy. it can then be called in brownie (console) through:

>>> contract = interface.IContract(address)

I had to paste my Foo interface definition into my Bar contract. Otherwise I got a runtime error from Foo saying it doesn't know anything about Foo's method baz().

Having interface Foo defined in its own file and importing it into contract Bar compiled fine, but failed at runtime when calling Foo.baz().

I also had to put my Foo interface definition file into Brownie's contracts directory. At first, I tried putting it in the interfaces directory, but the compiler couldn't find it.

I'm using Brownie 1.19.2 and Vyper 0.3.7, on macos.

  • 1
    i believe the answer to your problem is actually solved here: ethereum.stackexchange.com/questions/129781/…
    – gosuto
    Commented Nov 29, 2022 at 9:49
  • @gosuto You're right. Thanks:-) Now my interface import works! No need to copy paste interface code into my contract.
    – devdanke
    Commented Dec 6, 2022 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.