Add `read-only` annotation to ABI methods
The following document introduces a convention for creating methods (as described in ARC-4) which don’t mutate state.
Abstract
The goal of this convention is to allow smart contract developers to distinguish between methods which mutate state and methods which don’t by introducing a new property to the Method descriptor.
Specification
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in RFC-2119.
Comments like this are non-normative.
Read-only functions
A read-only function is a function with no side-effects. In particular, a read-only function SHOULD NOT include:
- local/global state modifications
- calls to non read-onlyfunctions
- inner-transactions
It is RECOMMENDED for a read-only function to not access transactions in a group or metadata of the group.
The goal is to allow algod to easily execute
read-onlyfunctions without broadcasting a transaction
In order to support this annotation, the following Method descriptor is suggested:
1interface Method {2  /** The name of the method */3  name: string;4  /** Optional, user-friendly description for the method */5  desc?: string;6  /** Optional, is it a read-only method (according to ARC-22) */7  readonly?: boolean8  /** The arguments of the method, in order */9  args: Array<{10    /** The type of the argument */11    type: string;12    /** Optional, user-friendly name for the argument */13    name?: string;14    /** Optional, user-friendly description for the argument */15    desc?: string;16  }>;17  /** Information about the method's return value */18  returns: {19    /** The type of the return value, or "void" to indicate no return value. */20    type: string;21    /** Optional, user-friendly description for the return value */22    desc?: string;23  };24}Rationale
Security Considerations
None.
Copyright
Copyright and related rights waived via CCO.