Skip to content

Add /v3/contracts/fast-call-read endpoint for (authorized) read only calls without cost tracking #6207

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

Merged
merged 18 commits into from
Jul 9, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
69 changes: 69 additions & 0 deletions docs/rpc/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -948,3 +948,72 @@ paths:
$ref: ./api/core-node/get-health-error.schema.json
example:
$ref: ./api/core-node/get-health-error.example.json

/v3/contracts/fast-call-read/{contract_address}/{contract_name}/{function_name}:
post:
summary: Call read-only function in fast mode (no cost and memory tracking)
tags:
- Smart Contracts
operationId: fast_call_read_only_function
description: |
Call a read-only public function on a given smart contract without cost tracking.

**This API endpoint requires a basic Authorization header.**

The smart contract and function are specified using the URL path. The arguments and the simulated tx-sender are supplied via the POST body in the following JSON format:
responses:
"200":
description: Success
content:
application/json:
schema:
$ref: ./api/contract/post-call-read-only-fn.schema.json
examples:
success:
$ref: ./api/contract/post-call-read-only-fn-success.example.json
fail:
$ref: ./api/contract/post-call-read-only-fn-fail.example.json
"400":
description: Endpoint not enabled.
"401":
description: Unauthorized.
"408":
description: ExecutionTime expired.
parameters:
- name: contract_address
in: path
required: true
description: Stacks address
schema:
type: string
- name: contract_name
in: path
required: true
description: Contract name
schema:
type: string
- name: function_name
in: path
required: true
description: Function name
schema:
type: string
- name: tip
in: query
schema:
type: string
description: The Stacks chain tip to query from. If tip == latest, the query will be run from the latest
known tip (includes unconfirmed state).
required: false
requestBody:
description: map of arguments and the simulated tx-sender where sender is either a Contract identifier or a normal Stacks address, and arguments is an array of hex serialized Clarity values.
required: true
content:
application/json:
schema:
$ref: './entities/contracts/read-only-function-args.schema.json'
example:
sender: 'SP31DA6FTSJX2WGTZ69SFY11BH51NZMB0ZW97B5P0.get-info'
arguments:
- '0x0011...'
- '0x00231...'
10 changes: 10 additions & 0 deletions stackslib/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3719,6 +3719,13 @@ pub struct ConnectionOptionsFile {
/// @default: [`DEFAULT_BLOCK_PROPOSAL_MAX_AGE_SECS`]
/// @units: seconds
pub block_proposal_max_age_secs: Option<u64>,

/// Maximum time (in seconds) that a readonly call in free cost tracking mode
/// can run before being interrupted
/// ---
/// @default: 30
/// @units: seconds
pub read_only_max_execution_time_secs: Option<u64>,
}

impl ConnectionOptionsFile {
Expand Down Expand Up @@ -3870,6 +3877,9 @@ impl ConnectionOptionsFile {
block_proposal_max_age_secs: self
.block_proposal_max_age_secs
.unwrap_or(DEFAULT_BLOCK_PROPOSAL_MAX_AGE_SECS),
read_only_max_execution_time_secs: self
.read_only_max_execution_time_secs
.unwrap_or(default.read_only_max_execution_time_secs),
..default
})
}
Expand Down
2 changes: 1 addition & 1 deletion stackslib/src/net/api/callreadonly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub struct CallReadOnlyResponse {

#[derive(Clone)]
pub struct RPCCallReadOnlyRequestHandler {
maximum_call_argument_size: u32,
pub maximum_call_argument_size: u32,
read_only_call_limit: ExecutionCost,

/// Runtime fields
Expand Down
Loading
Loading