Skip to content

VIP: Support @pure decorator #2041

@fubuloubu

Description

@fubuloubu

Simple Summary

Support the use of @pure as a decorator for methods

Motivation

To be consistent with the ABI stateMutability field, we should add support for specifying a method as @pure.

Specification

A method that is decorated as @pure must not read any blockchain state such as storage variables, environment variables, querying contract code or account balances, or making a call to nonpure methods, or to other contracts. In the event this happens, this should raise an exception that uniquely details a violation of reading blockchain state. Such a function might be useful for complex math or other purposes.

A method decorated with @pure looks like:

@pure
@public
def getMaff() -> uint256:
    return 1 + 2

Backwards Compatibility

No backwards compatibility issues

Dependencies

No dependencies. Related to #2040

References

Copyright

Copyright and related rights waived via CC0

Metadata

Metadata

Assignees

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