Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARC-51: Method Reference Discovery #230

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions ARCs/arc-draft_get_refs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
arc: <to be assigned>
title: Method Reference Discovery
description: A standardized way contracts can reveal which references will be needed to call a specific method
author: Joe Polny (@joe-p)
discussions-to: <URL>
status: Draft
type: Standards Track
category: ARC
created: 2023-07-28
requires (*optional): 4
---

## Abstract
A contract caller needs to know which resources a contract needs to be availible before calling a method. This ARC proposes a standard way to make that information discoverable.

## Motivation
As of the time of this ARC, it can be hard to know which resources a caller needs to make availible when calling an application. The current solution typically involves proprietary SDKs which can make app usage and composability difficult.

### Simulation Consideration

It should be noted that it is currently planned for the algod simulate endpoint to allow readonly execution of a method without providing references. The response to this endpoint will return the necessary resources. Once this functionality is availible, this ARC will no longer be needed. The primary intent of this ARC is to serve as an intermediate solution.

## Specification
If an application has a method and the contract wants to make the required resources for calling the method discoverable, it **MUST** implement a readonly method with the same exact signature with an `arcXXXX_` prefix and a return type of `(address[],uint64[],uint64[],(uint64,byte[]))`.

The return value corresponds to arrays containing the required account, application, asset, and box references respectively.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to provide clarity in the case of a method which takes reference type arguments.

I.e. does its arcXXXX_ function need to return the already specified reference types, or can it omit them?


The argument values provided to this method when called **SHOULD** match the arguments passed to the method for which the callers wants to know the required resources for.

The ARCXXXX method **MUST** be readonly.

## Rationale
The provided method will provide all of the references needed to call the application, which was previously not possible in a standardized way.

## Backwards Compatibility
N/A

## Test Cases
N/A

## Reference Implementation

### ARC200 example

In this example, let's say `arc200_totalSupply()uint256` requires two box refences `"baseSupply"` and `"supplyMultiplier"`, each encoded as `byte[]`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be nice to show an example with arguments to reenforce the restriction that the arcXXXX_ must be declared with the same set of arguments.


#### Method Signature

The ARCXXXX method signature would be `arcXXXX_arc200_totalSupply()(address[],uint64[],uint64[],(uint64,byte[]))`

#### Return Value

The ARCXXXX method would return the following value: `[],[],[],[[0, "baseSupply"], [0, "supplyMultiplier"]]`

## Security Considerations
N/A

## Copyright
Copyright and related rights waived via <a href="https://creativecommons.org/publicdomain/zero/1.0/">CCO</a>.
Loading