Skip to content

Cannot return ERC20 token address from contract #1376

@Pet3ris

Description

@Pet3ris

Hi There,

I'm trying to compile the following contract running master:

Input contract

from vyper.interfaces import ERC20

token: ERC20

@public
@constant
def tokenAddress() -> address:
    return self.token

Output

vyper.exceptions.TypeMismatchException: line 8: Trying to return base type address(ERC20), output expecting address
    return self.token
-----------^

I can fix it temporarily by changing the address to an address(ERC20), this compiles to runtime bytecode, but doesn't compile when extracting the ABI:

Input contract 2 (-f abi)

from vyper.interfaces import ERC20

token: ERC20

@public
@constant
def tokenAddress() -> address(ERC20):
    return self.token

Output

vyper.exceptions.InvalidTypeException: line 7: Invalid base unit
def tokenAddress() -> address(ERC20):
------------------------------^

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug that shouldn't change language semantics when fixed.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions