stacks-network / stacks-network/stacks-core
[RPC] Add method to check of a contract function is read-only, even if it's `define-public`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 3.1k
- Forks
- 762
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 76
Description
Currently, trait definitions do not enforce a read-only property on trait implementations. This is desirable because trait implementation consumers may want to be assured that a particular implementation cannot alter blockchain state. For example, the SIP-009 trait function get-last-token-id should not write new state.
Until the VM can be extended to support read-only enforcement for trait concretizations, the Clarity VM could instead record whether or not a function is truly read-only at analysis time. This analysis is something it already does as part of verifying that a function is properly defined. Once the VM does this, then we can add an RPC endpoint to allow users to query whether or not a trait concretization (or really, any defined function anywhere in the chain) is read-only. This way, users of popular trait concretizations like SIP-009 NFTs can ascertain whether or not functions that are expected to be read-only truly are.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the Clarity VM's existing analysis of whether functions are truly read-only, then identify the RPC entry point where that result would be exposed. Done should include a way to query read-only status for trait concretizations and other defined functions, with behavior validated for functions such as SIP-009 get-last-token-id.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- api, blockchain
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100