Skip to main content
readContract() runs a read-only simulation against a Soroban smart contract and returns the result. Unlike requestTransaction(), it does not open any popup, does not require the user’s approval, and does not submit anything to the Stellar network. It is the right tool whenever you need on-chain data — a token balance, contract configuration, pool state, or any other view function — without changing state or spending gas.

Method signature

Parameters

ReadContractRequest
required
The read request describing the contract and function to simulate.

Return value

readContract() returns Promise<unknown>. The resolved value is the raw return value of the contract function — the shape depends entirely on the contract you are calling. Cast the result to a known type after calling:

No approval required

Because readContract() only simulates execution and never submits a transaction, it requires no active session and no user interaction. You can call it at any point — on page load, in the background, or before asking the user to authenticate — to pre-fetch the data your UI needs.

Examples

Read a token balance

Read token metadata

Read staking pool state

Read an allowance

Pre-fetching data before a transaction

A common pattern is to read state first to validate inputs before prompting the user to approve a transaction:

readContract() vs requestTransaction()

Use readContract() freely — it is cheap, requires no authentication, and carries no risk of unintended state changes. Reach for requestTransaction() only when you need to write to the contract.

TypeScript interface