Signed Rust, Python, and CLI journeys#
Use these procedures with the funded local sandbox. They use the actual language SDKs and the actual CLI. They do not establish compatibility with a production deployment. The Rust and Python examples accept only an HTTP loopback RPC with an explicit port. They also compare the RPC genesis hash with the selected fixture.
Supported task#
The language examples read accounts, save a bounded order review, sign an authorized order, and examine its finalized result. They support wallet-funded IOC buys and sells in each native YES or NO price lane. The minimum fill equals the requested quantity. A partial fill cannot satisfy these examples.
Use a native Pyth market without a maker spline. The wallet must have:
- SOL for fees and any required position rent.
- Initialized settlement, YES, and NO token accounts with the correct owner and mints.
- Sufficient settlement tokens for a buy, or sufficient selected-outcome tokens for a sell.
- No referral binding, resting orders, or nonzero trader-ledger balances.
The examples reject unsupported state. They do not replace referral attribution or combine ledger and wallet assets. They do not create markets, accounts, or liquidity. They do not provide terminal redemption or multi-page cleanup. Use the Node and browser tutorials for those supported application adapters.
Run one sender at a time for this wallet. Another sender can change balances between review and final verification. A changed balance causes the example to stop. Its economic assertions stay the same.
Build from the checkout#
Use the documented source installation. These commands run from the repository root. No registry publication is implied.
cargo build --locked -p seesaw-sdk --features rpc --example local_journey
PYTHONPATH=packages/sdk-python python3 -m pytest \
packages/sdk-python/tests/test_local_journey.py -q
bun --filter @seesaw/cli build
Rust uses the existing rpc feature and Solana SDK signing implementation.
Python uses solders signing, the Seesaw SDK, and the standard-library HTTP client.
The journal implementations require a Unix-like local filesystem. They use OS file locks and durable, exclusive file creation.
Do not put these journals on a network filesystem.
Select the fixture#
Run the sandbox's inputs command to create the tutorial input file.
Its nodeEnvironment object contains deployment addresses and a keypair file path. It does not contain private key bytes.
The keypair file must be private, with mode 0600.
Set DOCS_ENV_JSON to the actual fixture file. Do not use the example path for an unrelated run.
export DOCS_ENV_JSON=/private/tmp/seesaw-tutorial-inputs.json
with_fixture() {
python3 - "$DOCS_ENV_JSON" "$@" <<'PY'
import json, os, subprocess, sys
from pathlib import Path
settings = json.loads(Path(sys.argv[1]).read_text())["nodeEnvironment"]
if not all(k.startswith("SEESAW_") and isinstance(v, str) for k, v in settings.items()):
raise SystemExit("Expected string-valued SEESAW fixture settings")
env = dict(os.environ)
action_defaults = {"SEESAW_OUTCOME", "SEESAW_INTENT", "SEESAW_PRICE_BPS", "SEESAW_QUANTITY"}
for key, value in settings.items():
if key in action_defaults:
env.setdefault(key, value)
else:
env[key] = value
raise SystemExit(subprocess.run(sys.argv[2:], env=env).returncode)
PY
}
The helper uses the fixture's deployment, signer, and account settings.
It keeps explicit action settings from the shell. Examine those settings before you run it.
The examples require the RPC URL, expected genesis hash, program, market, and three token-account addresses.
Use SEESAW_KEYPAIR for signing. A read-only invocation can use SEESAW_USER_ADDRESS when no keypair is set.
Never print or copy the keypair contents into a guide or evidence log.
Python: read, review, authorize, send#
Use a new private journal directory for this tutorial. Keep that directory for all later attempts and recovery.
export PYTHONPATH=packages/sdk-python
export SEESAW_JOURNEY_DIRECTORY="$PWD/.e2e-runs/python-native-journey"
with_fixture python3 packages/sdk-python/examples/local_journey.py read
The read validates the market and account PDAs, account owners, token mints, wallet owners, and initialized token state. It shows wallet balances, chain time, market end time, fee epoch, and cumulative position fees. A position mirror is not added to wallet holdings.
For the sandbox's YES offer at 5000 bps, prepare this one-share buy:
export SEESAW_ACTION_ID=python-buy-yes-01
export SEESAW_OUTCOME=YES
export SEESAW_INTENT=BUY
export SEESAW_PRICE_BPS=5000
export SEESAW_QUANTITY=1000000
export SEESAW_MAX_QUOTE_INPUT=510000
with_fixture python3 packages/sdk-python/examples/local_journey.py review
Examine the printed review before authorization. It includes the deployment, wallet, token accounts, instruction, and all economic bounds. The example saves that exact review under the action ID. It does not overwrite an existing review. The review expires after at most 120 chain seconds, or at market close if earlier. The fee epoch is pinned. The wallet must cover the full buy budget.
Copy the printed digest only after you accept that review:
export SEESAW_AUTHORIZED_DIGEST='<digest from the reviewed output>'
with_fixture python3 packages/sdk-python/examples/local_journey.py send
with_fixture python3 packages/sdk-python/examples/local_journey.py read
The sender rereads account state before signing. It rejects changed balances, scope, fee configuration, or instruction accounts. It saves the signed bytes and signature durably before the first send. The result is complete only after finalized success and the token-delta assertions pass.
For this fixture, the buy decreases settlement tokens by 510000 and increases YES tokens by 1000000.
SOL fees and position rent are separate. The other outcome balance must stay unchanged.
Rust: the same bounded task#
Use the built Rust executable with its own persistent directory. Do not run it concurrently with another wallet sender.
export SEESAW_JOURNEY_DIRECTORY="$PWD/.e2e-runs/rust-native-journey"
with_fixture target/debug/examples/local_journey read
export SEESAW_ACTION_ID=rust-buy-yes-01
export SEESAW_OUTCOME=YES
export SEESAW_INTENT=BUY
export SEESAW_PRICE_BPS=5000
export SEESAW_QUANTITY=1000000
export SEESAW_MAX_QUOTE_INPUT=510000
with_fixture target/debug/examples/local_journey review
Examine the Rust review. Copy its own digest; a digest from another review is not authorization for this action.
export SEESAW_AUTHORIZED_DIGEST='<digest from the Rust review>'
with_fixture target/debug/examples/local_journey send
with_fixture target/debug/examples/local_journey read
Rust uses the actual low-level PlaceOrderParams builder to encode quote bounds and the fee epoch.
Its journal contains the exact legacy transaction wire, signature, signed transaction, and prior balances.
It enforces the same full-fill and final token-delta conditions as the Python example.
Complete the four-action exercise#
The following prices are controlled sandbox liquidity, not live quotes.
Each row trades 1000000 share base units. Use a new action ID for each row.
For each action, run review, examine its output, authorize that digest, and run send.
| Outcome | Intent | Price bps | Required quote bound | Expected wallet change |
|---|---|---|---|---|
| YES | BUY | 5000 | SEESAW_MAX_QUOTE_INPUT=510000 | −510000 quote; +1000000 YES |
| YES | SELL | 4800 | SEESAW_MIN_QUOTE_OUTPUT=470400 | +470400 quote; −1000000 YES |
| NO | BUY | 4000 | SEESAW_MAX_QUOTE_INPUT=408000 | −408000 quote; +1000000 NO |
| NO | SELL | 3800 | SEESAW_MIN_QUOTE_OUTPUT=372400 | +372400 quote; −1000000 NO |
The four actions reduce quote by 75200 base units. YES and NO holdings return to their initial values.
The taker fees total 35200 base units. The remaining 40000 is the two price spreads.
These checks exclude SOL fees and rent. A different book cannot reproduce these exact amounts.
Restart or unknown result#
Keep the journal after a timeout, process exit, or missing RPC response. Do not change the action ID or directory to evade a pending attempt.
with_fixture python3 packages/sdk-python/examples/local_journey.py reconcile
# Or, for the Rust journal:
with_fixture target/debug/examples/local_journey reconcile
Use the executable and journal for the original attempt. A missing historical status, an expired blockhash, or a merely confirmed status remains unresolved. An unresolved record blocks another send. The example never signs an automatic replacement. A finalized failure is recorded as failed. A finalized success must also pass the balance assertions.
If RPC preflight rejects a signed attempt, the conservative journal can still keep it unresolved. Keep the record for investigation. This tutorial supplies no automatic discard or replacement override. A changed genesis, wallet, market, or account scope cannot reuse the journal. The examples do not provide a rebroadcast command; recovery observes the original signature.
Actual CLI commands#
The CLI signs with the selected keypair. Local write commands can send immediately; there is no separate order-review mode. Examine every argument before executing. Keep stdout, stderr, and any returned signature. A shell marker can prevent accidental repeat execution, but it is not the Rust/Python signed-transaction journal.
Copy the named values from the selected fixture into the shell. Replace each placeholder before continuing. Do not use another run's addresses or keypair.
export SEESAW_RPC_URL='http://127.0.0.1:32768'
export SEESAW_PROGRAM_ADDRESS='<fixture program address>'
export SEESAW_MARKET_ADDRESS='<fixture market address>'
export SEESAW_KEYPAIR='<private fixture keypair file path>'
export SEESAW_USER_SETTLEMENT_ACCOUNT='<fixture settlement token account>'
export SEESAW_USER_YES_ACCOUNT='<fixture YES token account>'
export SEESAW_USER_NO_ACCOUNT='<fixture NO token account>'
These shell variables are necessary because the shell expands command arguments before it starts a child process.
The with_fixture helper does not change variables in the parent shell.
The current CLI config get output omits feeEpoch; the Rust or Python read above includes it.
Define a wrapper after those variables are set:
seesaw_local() {
node packages/cli/dist/index.js \
--rpc-url "$SEESAW_RPC_URL" --program-id "$SEESAW_PROGRAM_ADDRESS" \
--keypair "$SEESAW_KEYPAIR" "$@"
}
seesaw_local config get
seesaw_local market get "$SEESAW_MARKET_ADDRESS"
seesaw_local position get --market "$SEESAW_MARKET_ADDRESS"
seesaw_local order list --market "$SEESAW_MARKET_ADDRESS"
Set SEESAW_SETTLEMENT_MINT from the validated fixture and SEESAW_EXPECTED_FEE_EPOCH from the current account read.
Set SEESAW_EXECUTION_DEADLINE to a future chain Unix second before market close.
This is the actual bounded YES buy command used by the CLI tutorial:
seesaw_local order place \
--market "$SEESAW_MARKET_ADDRESS" --outcome yes --intent buy \
--price 5000 --quantity 1000000 --order-type ioc \
--token-account "$SEESAW_USER_SETTLEMENT_ACCOUNT" \
--settlement-mint "$SEESAW_SETTLEMENT_MINT" \
--user-yes-ata "$SEESAW_USER_YES_ACCOUNT" --user-no-ata "$SEESAW_USER_NO_ACCOUNT" \
--self-trade-behavior 0 --worst-acceptable-price-bps 5000 \
--min-fill-quantity 1000000 --match-limit 12 --max-quote-input 510000 \
--expected-fee-epoch "$SEESAW_EXPECTED_FEE_EPOCH" \
--execution-valid-until "$SEESAW_EXECUTION_DEADLINE" --protocol-treasury-index 0
To sell that one YES share in the fixture, use --intent sell, price and worst-price 4800, and --min-quote-output 470400.
Remove --max-quote-input for the sell. Set a fresh deadline and examine the complete command again.
After each finalized result, read wallet token balances and the position. Do not rely only on a success message.
The tested roundtrip decreases quote by 39600 and leaves the initial YES and NO quantities unchanged.
These additional CLI paths use the named current commands:
seesaw_local order deposit-funds --market "$SEESAW_MARKET_ADDRESS" \
--user-stablecoin-ata "$SEESAW_USER_SETTLEMENT_ACCOUNT" \
--settlement-mint "$SEESAW_SETTLEMENT_MINT" --amount 1000000
seesaw_local order withdraw-funds --market "$SEESAW_MARKET_ADDRESS" \
--user-stablecoin-ata "$SEESAW_USER_SETTLEMENT_ACCOUNT" \
--settlement-mint "$SEESAW_SETTLEMENT_MINT" --amount 1000000
The tested deposit moves one quote unit from wallet to ledger. The withdrawal moves it back.
It does not create profit or change outcome holdings. Locked quote is not withdrawable free quote.
Use order cancel --help, position mint --help, position merge-complete-set --help, and position redeem --help for their full account requirements.
Terminal redemption requires an actual terminal outcome. It was not part of the funded cross-language run described here.
Ordinary CLI order commands do not save the Rust/Python persistent journal. On an unknown result, stop and reconcile the printed signature against the same RPC and affected accounts. The CLI warns against replacement after unresolved expiry. Do not rerun a write command as a timeout remedy.
Evidence and limits#
packages/sdk-python/tests/test_local_journey.py exercises authorization, durable-before-send ordering, lost acknowledgement, restart blocking, scope binding, account validation, and economic deltas.
Rust has the corresponding tests in packages/sdk-rust/examples/local_journey.rs.
The deadline check is explicit in the source; the initial safety suites do not claim a separate clock-boundary fixture.
The 2026-10-23 local run completed four finalized orders per language with exact balance and fee assertions. The actual CLI completed a finalized YES buy/sell and a quote deposit/withdraw roundtrip. These use controlled local liquidity and local signing keys. They do not establish mainnet execution, external-provider qualification, or general wallet compatibility. The example registry separates source, offline, local-chain, and deployment evidence.