Skip to main content
This example demonstrates buying and selling Ondo Global Markets tokenized stocks & ETFs with the Pods API. Market-share strategies live on BSC (Ondo-<TICKER>-bsc), but you can fund a buy from — or receive a sell payout on — another EVM chain; Pods handles the bridge.
Settlement is asynchronous. The on-chain transaction submits the request in seconds; the order reaches SUCCESS only after Ondo fills it (minutes later). Track it via GET /actions/{id}.

Overview

This example covers:
  • Market statusGET /ondo/stocks/market-status
  • Buy (action=request-lend) — fund cross-chain from Base USDC
  • Sell (action=request-withdraw) — redeem shares, receive USDC cross-chain
  • Async order trackingGET /actions/{id}
  • Optional limit / expirypriceInUsd (USD cents) and expireAt (Unix seconds) on Ondo BSC bytecode; cancel via GET /actions/{id}/cancel?wallet=

Prerequisites

  • Node.js 18+
  • Pods API key
  • Wallet with USDC to buy (or an open Ondo position to sell)

Installation

Environment Variables

Step-by-Step Walkthrough

1. Check Market Status

2. Buy (request-lend) — cross-chain funding

Fund the BSC position from Base USDC. amount is in the fromTokenAddress token’s base units (6 decimals for Base USDC; 18 for BSC USDC). The response returns origin-chain bytecode legs and an Action id.
To pin a client CoW limit (cents) and/or validTo, add priceInUsd and expireAt. They are independent and only work on Ondo BSC. See limit price, expiry, and cancel.

3. Sell (request-withdraw) — cross-chain payout

Redeem market shares and receive USDC on Base. amountInShares is the share amount (18 decimals).

4. Execute the request (atomic batch on the origin chain)

Batch all origin-chain bytecode legs into one transaction. See Executing Bytecode.

5. Track the async order fill

The on-chain tx only submits the request. Poll the Action id until the order reaches a terminal state. For cross-chain, the bridge leg settles first, then the order.
An unfilled client-limit order (priceInUsd set) can be cancelled after funding:
For a strategy-scoped view of pending orders, use GET /strategies/{id}/status?wallet={address} — it returns hasPending, per-action orderBook eligibility, and the actions[] list.

Running the Example

Download both files into the same folder to run this example: ondo.js and the shared EIP-7702 batch helper eip7702-batch.js that it imports.
See the full runnable script: ondo.js.

Next Steps

Ondo Global Markets Guide

Full buy/sell, cross-chain, and accounting details

Track & Positions

Read positions and track actions

Cross-Chain Swap

Bridge tokens across chains

API Reference

View complete API documentation