Quickstart: Your First Seesaw Integration#
This tutorial walks you through installing the SDK, connecting to a Solana RPC node, listing live markets, and reading the order book to estimate a fill — all without placing an order. By the end you will have a working script that talks to mainnet and a clear map to the next steps.
Time: ~15 minutes.
Step 1 — Install the package#
The trustless package works against any standard Solana RPC node; no Seesaw API key is needed for the steps in this tutorial.
npm install @seesaw/trustless @seesaw/core
yarn add / pnpm add work identically. See
Installation for the full dependency table and
TypeScript configuration (module: "node16", target: "ES2020").
Step 2 — Create the RPC client#
import { TrustlessRpc } from '@seesaw/trustless';
const rpc = new TrustlessRpc({ url: process.env.SOLANA_RPC_URL! });
Set SOLANA_RPC_URL in your environment (e.g., in a .env file):
SOLANA_RPC_URL=https://your-rpc-provider.example
The TrustlessRpc client uses plain fetch — no additional RPC SDK required.
Step 3 — List live markets#
This step verifies the installation: it calls getProgramAccounts on the
Seesaw program and decodes every MarketAccount directly from chain state.
import { TrustlessRpc, listMarkets } from '@seesaw/trustless';
const rpc = new TrustlessRpc({ url: process.env.SOLANA_RPC_URL! });
const markets = await listMarkets(rpc);
console.log(`Found ${markets.length} Seesaw markets`);
for (const { address, market } of markets.slice(0, 5)) {
console.log(address, 'marketId:', market.marketId.toString());
}
console.log('SDK installed successfully!');
If you see Found N Seesaw markets and a list of addresses, your SDK is
working. If you see a rate-limit error, switch to a dedicated RPC provider —
public endpoints throttle getProgramAccounts aggressively.
Step 4 — Read the order book and estimate a fill#
Pick the first market from the previous step and estimate what a buy-NO limit order at 4200 bps would fill for:
import { TrustlessRpc, TrustlessResolver, listMarkets } from '@seesaw/trustless';
import { aggregateOrderbook, estimateFillFromLevels, OrderSide, OrderType } from '@seesaw/core';
const rpc = new TrustlessRpc({ url: process.env.SOLANA_RPC_URL! });
const resolver = new TrustlessResolver(rpc);
const markets = await listMarkets(rpc);
const marketAddress = markets[0].address;
// Fetch and aggregate the order book.
const { value: orderbook } = await resolver.getOrderbook(marketAddress);
const book = aggregateOrderbook(orderbook);
// Fetch the protocol fee configuration.
const {
value: { config },
} = await resolver.getConfig();
// Estimate the fill.
const estimate = estimateFillFromLevels({
side: OrderSide.BuyNo,
quantity: 50_000_000n,
orderType: OrderType.Limit,
limitPriceBps: 4_200,
book,
fee: { capBps: config.feeCapBps, decayBps: config.decayRateBps },
});
console.log('Fill estimate:', estimate);
estimateFillFromLevels returns the expected fill quantity, average price,
and estimated fee — all computed locally from the decoded chain state, no
server involved.
Next step — build a create-market transaction#
Market creation uses the full @seesaw/core transaction builder. The oracle
mode is explicit:
import { createMarket } from '@seesaw/core';
const { instructions, accounts } = await createMarket({
marketId: 1888888n,
pythFeedId: feedIdBytes, // 32-byte Pyth feed id, not a Solana account
pythFeed: pythAccountAddress,
settlementMint,
payer: walletAddress,
creator: walletAddress,
durationSeconds: 900n,
maxConfidenceRatioBps: 500,
maxOracleJumpBps: 0,
oracleMode: 'push', // or 'pull'
marketSizeParams: { bidsSize: 512, asksSize: 512, numSeats: 128 },
});
For Push, pythFeed is the Receiver-owned push-feed account address. For Pull,
pythFeed is the Receiver-owned PriceUpdateV2 account supplied for the create
snapshot; later lifecycle calls validate Pull updates by pythFeedId instead of
by a fixed feed-account address.
Pyth Core's upgraded Hermes endpoint requires a bearer key. Keep
PYTH_API_KEY on server-side relay/proxy infrastructure only; never embed it in
browser or mobile SDK integrations.
Where next?#
| Goal | Read |
|---|---|
| Understand trust-based vs. trustless and pick your SDK | SDK Guide |
| Install all packages and set up TypeScript | Installation |
| Place, cancel, and redeem orders | Building Transactions |
| Decode PDAs, positions, and streams | Reading Data |
| Copy-pasteable end-to-end programs | Examples |
| Validate every account from any RPC without trusting Seesaw | Trustless SDK |
| Python or Rust | Python SDK · Rust SDK |