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

Clarity: try-read-only contract calls? #1630

Closed
jcnelson opened this issue May 26, 2020 · 5 comments
Closed

Clarity: try-read-only contract calls? #1630

jcnelson opened this issue May 26, 2020 · 5 comments

Comments

@jcnelson
Copy link
Member

This is more of a design question. Should it be possible to call a define-public function with a dynamic assertion that it is read-only? My main motivation for this is to provide a way to call define-public functions via the RESTful API that could be read-only, and have them abort with an assertion failure if they try to mutate any state. I could also see us adding something akin to a contract-call? but that adds a runtime assert that no mutations occur (maybe something like contract-call-ro?).

@jcnelson
Copy link
Member Author

The consensus seems to be that, abort or not, we can run any function or any code via the RESTful API. We can abort on mutation, or just not materialize any mutation.

@psq
Copy link
Contributor

psq commented May 28, 2020

@jcnelson if by the RESTful API, you mean using /v2/contracts/call-read, this will fail with PublicFunctionNotReadOnly, even though technically, yes, you could rollback it if did mutate, but right now you have to use a transaction to call any function that is not defined as define-read-only, but probably a separate issue.

@jcnelson
Copy link
Member Author

Right -- what the API should be doing (#1641) is allowing you to call any Clarity function you want (not just the read-only ones) via the RESTful API, but without materializing any writes.

@psq
Copy link
Contributor

psq commented May 28, 2020

sounds good! Thank you @jcnelson

@blockstack-devops
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@stacks-network stacks-network locked as resolved and limited conversation to collaborators Nov 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants