Dashboard

Smart Contracts

Soroban RPC API for Smart Contract Developers

Build, test, and monitor Soroban smart contracts with reliable JSON-RPC access. Simulate transactions, query events, read contract state, and deploy to the Stellar network.

What is the Soroban RPC API?

The Soroban RPC API is a JSON-RPC 2.0 interface for interacting with Soroban smart contracts on the Stellar network. It provides the methods developers need to build decentralized applications: simulating transactions, submitting signed operations, reading contract storage, and querying emitted events.

Unlike the Horizon REST API which handles general Stellar data (accounts, payments, assets), Soroban RPC is purpose-built for smart contract workflows. Most Stellar applications need both: Horizon for account and payment operations, and Soroban RPC for contract interactions.

LumenQuery provides managed access to both APIs through a single platform, so you can build full-stack Stellar applications without running any infrastructure.

Core RPC Methods

simulateTransaction

Preview transaction outcome and resource costs

sendTransaction

Submit signed transaction to the network

getTransaction

Check transaction status and result

getEvents

Query contract events with filters

getLedgerEntries

Read contract storage and data

getHealth

Check RPC node health status

getLatestLedger

Get current ledger sequence

getNetwork

Network passphrase and protocol info

Why Developers Need Reliable Soroban RPC

Smart contract development requires fast, reliable RPC access at every stage: development, testing, deployment, and production monitoring.

Transaction Simulation

Preview the outcome of any Soroban transaction before submitting it. Catch errors, estimate fees, and validate contract logic without spending XLM.

Contract Event Monitoring

Query and stream contract events in real time. Filter by contract ID, event topic, and type. Essential for dApp frontends that need to react to on-chain state changes.

Storage State Reading

Read contract storage entries directly via getLedgerEntries. Access persistent, temporary, and instance storage without decoding raw ledger data yourself.

Deployment Pipeline

Deploy contracts from CI/CD pipelines with reliable RPC access. No flaky connections or rate limits slowing down your development workflow.

Gas Estimation

Accurately estimate CPU instructions, memory usage, and storage costs before submitting transactions. Avoid underfunded transactions that fail on-chain.

Production Monitoring

Monitor deployed contracts for errors, unexpected gas spikes, and abnormal event patterns. LumenQuery provides contract analytics out of the box.

Smart Contract Monitoring with LumenQuery

Beyond raw RPC access, LumenQuery provides a complete smart contract monitoring platform. Our Soroban Pro explorer decodes XDR into human-readable data so you can understand exactly what your contracts are doing.

Decoded Call History

Every contract invocation decoded from XDR into readable function names, parameter values, and return data. Filter by function, status, or time range.

Storage State Viewer

Browse persistent, temporary, and instance storage entries with type badges and TTL information. See exactly what data your contract is storing on-chain.

Real-Time Event Stream

Server-Sent Events (SSE) streaming for contract events. Monitor your contract in real time without polling. Filter by topic and event type.

Gas and Error Analytics

Track CPU instructions, memory usage, and storage costs per invocation. Identify expensive functions and error patterns across your contract history.

Example: Soroban RPC Request

Query contract events using the JSON-RPC 2.0 protocol. All Soroban RPC methods follow this standard request format.

POSTJSON-RPC 2.0
// Query contract events via Soroban RPC
const response = await fetch('https://rpc.lumenquery.io', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'YOUR_API_KEY'
  },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'getEvents',
    params: {
      startLedger: 1000000,
      filters: [
        {
          type: 'contract',
          contractIds: [
            'CDLZFC3SYJYDZT7K67VZ75HPJVIEUVNIXF47ZG2FB2RMQQVU2HHGCYSC'
          ],
          topics: [
            ['AAAADwAAAAh0cmFuc2Zlcg==', '*', '*']
          ]
        }
      ],
      pagination: { limit: 100 }
    }
  })
});

const { result } = await response.json();

// result.events contains decoded contract events
result.events.forEach(event => {
  console.log(`Ledger ${event.ledger}: ${event.type}`);
  console.log(`  Topic: ${event.topic}`);
  console.log(`  Value: ${event.value}`);
});
POSTSimulate Transaction
// Simulate a contract invocation before submitting
const simulation = await fetch('https://rpc.lumenquery.io', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-API-Key': 'YOUR_API_KEY'
  },
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 2,
    method: 'simulateTransaction',
    params: {
      transaction: 'AAAAAgAAAAB...' // Unsigned XDR envelope
    }
  })
});

const { result } = await simulation.json();
console.log('Cost:', result.cost);           // CPU + memory usage
console.log('Result:', result.results);       // Expected return value
console.log('Min Fee:', result.minResourceFee); // Minimum fee in stroops

See the full Soroban documentation for all RPC methods, parameters, and response schemas.

Soroban RPC Use Cases

DeFi Protocols

Build lending pools, DEXes, and liquidity protocols. Simulate swaps, monitor pool events, and track position changes in real time.

Token Contracts

Deploy and manage custom token contracts. Monitor transfers, approvals, and balance changes through event streaming.

DAO Governance

Implement on-chain voting, proposal creation, and treasury management. Query contract storage for governance state.

NFT Platforms

Mint, transfer, and query ownership of non-fungible tokens. Track provenance and marketplace events.

Oracle Networks

Feed external data into Soroban contracts. Monitor price updates and validate oracle submissions through event queries.

Gaming & Collectibles

Build on-chain game mechanics with Soroban contracts. Track in-game asset ownership and marketplace activity.

Frequently Asked Questions

What is the Soroban RPC API?

The Soroban RPC API is a JSON-RPC 2.0 interface for interacting with Soroban smart contracts on the Stellar network. It provides methods for simulating transactions, submitting transactions, querying contract events, reading contract data (getLedgerEntries), and checking transaction status.

How is Soroban RPC different from Horizon API?

Horizon API is a REST interface for general Stellar blockchain data (accounts, payments, assets, ledgers). Soroban RPC is a JSON-RPC 2.0 interface specifically for smart contract interactions. Most applications need both: Horizon for account and payment data, Soroban RPC for contract invocations and simulations.

Can I simulate Soroban transactions before submitting them?

Yes. The simulateTransaction method lets you preview the outcome of a Soroban transaction without actually submitting it to the network. This returns the expected result, resource costs (CPU, memory, storage), and any errors, helping you estimate fees and debug issues before spending real XLM.

How do I query Soroban contract events?

Use the getEvents method to query contract events by contract ID, topic filters, event type (contract, system, diagnostic), and ledger range. LumenQuery also provides a smart contract explorer with decoded event streams and real-time SSE streaming for contract events.

Does LumenQuery provide a Soroban contract explorer?

Yes. LumenQuery includes a Soroban Pro contract explorer that decodes XDR data into human-readable formats. You can browse contract calls, storage state, event history, gas analytics, and get AI-powered explanations of contract interactions.

Do I need to run my own Soroban RPC node?

No. LumenQuery provides managed Soroban RPC access so you can skip the complexity of running your own node. Self-hosting requires an embedded Captive Core instance, significant disk space for ledger data, and ongoing maintenance for protocol upgrades.

Related Resources

Start Building with Soroban RPC

Get managed Soroban RPC access with your free LumenQuery account. Deploy contracts, simulate transactions, and monitor events today.