TypeScript SDK — @openpons/sdk
Location: packages/sdk (workspace package; not yet published to npm). Zero runtime
dependencies. Works in Node 18+ and browsers (uses fetch).
npm run build:sdk # → packages/sdk/dist
Signer responsibility
The SDK never signs and never broadcasts. prepare* methods return an unsigned
PreparedTransaction. You decide whether to sign it, using a wallet or signer you control.
toEip1193Params(tx) converts it to eth_sendTransaction params, and throws if:
chainId !== 4663,simulation.okis false, orexpiresAthas passed.
API
import { OpenPons, OpenPonsError, toEip1193Params } from "@openpons/sdk";
const openpons = new OpenPons({ baseUrl: "https://openpons.xyz/api/v1", timeoutMs: 20_000 });
await openpons.health();
await openpons.contracts();
// tokens
await openpons.tokens.search({ sort: "new" | "active" | "graduated", q?, limit?, cursor? });
await openpons.tokens.get(address);
await openpons.tokens.trades(address, { limit: 30 });
// quotes
await openpons.quote({ token, side: "buy", amount: "0.02", slippageBps: 100 });
// wallets
await openpons.wallet.get(address);
await openpons.wallet.balance(address, token?);
await openpons.portfolio.get(address);
await openpons.launches.byCreator(address);
await openpons.launches.config();
await openpons.fees.get(address);
await openpons.transactions.get(hash);
// write PREPARATION (unsigned)
await openpons.trade.prepareBuy({ token, amount: "0.02", from, slippageBps: 100 });
await openpons.trade.prepareSell({ token, amount: "1000000", from });
await openpons.launch.prepare({ from, name, symbol, logo: "ipfs://…", creatorTaxBps: 100, devBuyEth: "0.01" });
await openpons.fees.prepareClaim({ from });
await openpons.fees.prepareSweep({ token, from });
Errors throw OpenPonsError { code, status, message, details } using the API error codes.
Example: sell with an exact approval
const tx = await openpons.trade.prepareSell({ token, amount: "500000", from: account });
for (const step of tx.requires ?? []) {
const hash = await provider.request({ method: "eth_sendTransaction", params: [toEip1193Params(step)] });
// wait for the receipt, e.g. poll openpons.transactions.get(hash) until "success"
}
// re-prepare so the sell is simulated against the confirmed allowance
const sell = await openpons.trade.prepareSell({ token, amount: "500000", from: account });
await provider.request({ method: "eth_sendTransaction", params: [toEip1193Params(sell)] });
Types (TokenSummary, TokenDetail, Quote, PreparedTransaction, Portfolio, Launch,
CreatorFees, TxStatus, …) are exported from the package.