-
Notifications
You must be signed in to change notification settings - Fork 0
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
Remove unnecessary read only methods #15
Comments
I agree with this in general but do see the value in creating aggregated read-only functions that expose a set of variables. This serves as an external lookup for UIs and other contracts that cannot read these values directly. For example, if you have: bitcoin-dao/contracts/extensions/bde020-resource-manager.clar Lines 41 to 47 in 7503978
Then instead of a one-off read only function exposing the variable like this: bitcoin-dao/contracts/extensions/bde020-resource-manager.clar Lines 123 to 126 in 7503978
We could return a single tuple instead: (define-read-only (get-contract-stats)
{
totalUsers: (var-get userCount),
totalResources: (var-get resourceCount),
totalInvoices: (var-get invoiceCount),
totalRevenue: (var-get totalRevenue),
}
) Before I'm fully convinced though I'd like to do a cost comparison.
Also, looking at the docs for the API, it looks like we can query a map inside a contract but can you read a |
Agree with all these points. You can get a data var through API but it hasn't been documented just raised this here
Contracts can also directly read data-vars from other contracts (according to chatgpt - never tried this myself);
Agree comparison of the costs is important. |
I suspect that won't work but we should test, would be another reason to fine tune a model more on stacks/clarity! |
According to Clarity WG we should favour map-get / var-get api calls over read-only functions which return the same information as the contract footprints are lighter.
The text was updated successfully, but these errors were encountered: