Skip to content

VIP: add method_id member to interface functions #2098

@iamdefinitelyahuman

Description

@iamdefinitelyahuman

Simple Summary

Add a method_id member to interface functions:

from vyper.interfaces import ERC20

m: Bytes[4] = ERC20.transfer.method_id

Motivation

Currently, when using raw_call we have to generate the method ID from a string of the function selector, using the method_id builtin. Adding method_id as a member to interfaces is less error-prone and arguably more readable.

Specification

<INTERFACE>.<FUNCTION>.method_id

The member is accessible only from the primitive type:

# valid, accessing via the primitive
m: Bytes[4] = ERC20.transfer.method_id

# not valid, trying to access from a defined type
m: Bytes[4] = ERC20(_addr).transfer.method_id

Backwards Compatibility

Not a breaking change.

Copyright

Copyright and related rights waived via CC0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions