npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@predexon/trade-sdk

v0.0.7

Published

Predexon Trade SDK for Polymarket and Kalshi

Readme

Predexon Trade SDK

TypeScript SDK for trading on Polymarket (Polygon) and Kalshi (Solana) prediction markets.

Installation

npm install @predexon/trade-sdk

Requires Node.js 20.18+.

Get an API Key

Request access from Predexon to receive an API key.

Important: The SDK is designed for server-side use. Never expose your API key in browser code.

Quick Start: Polymarket with Viem

Works with any viem WalletClient — local accounts, Turnkey, or custom signers. This example shows server-side usage with a local account.

import { PredexonSDK, createViemAdapter } from '@predexon/trade-sdk';
import { createWalletClient, http } from 'viem';
import { polygon } from 'viem/chains';
import { privateKeyToAccount } from 'viem/accounts';

// Create a viem wallet client (this example uses a local account)
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const walletClient = createWalletClient({
  account,
  chain: polygon,
  transport: http(process.env.POLYGON_RPC_URL),
});

const wallet = createViemAdapter(walletClient);

const sdk = new PredexonSDK({
  apiKey: process.env.PREDEXON_API_KEY!,
  wallet,
});

// Enable trading (one-time setup)
await sdk.enableTrading({
  core: { venue: 'polymarket', wallet: account.address },
  approvals: 'sign', // Use 'broadcast' if wallet doesn't support signTransaction
});

// Place a market buy order
const order = await sdk.placeOrder({
  core: {
    venue: 'polymarket',
    wallet: account.address,
    side: 'buy',
    amount: '10', // $10 USDC
    type: 'market',
  },
  flags: { tokenId: 'your-token-id' },
});

console.log('Order placed:', order);

Quick Start: Polymarket with Turnkey

import { PredexonSDK } from '@predexon/trade-sdk';
import { createTurnkeyAdapter } from '@predexon/trade-sdk/server';

const wallet = createTurnkeyAdapter({
  apiPublicKey: process.env.TURNKEY_API_PUBLIC_KEY!,
  apiPrivateKey: process.env.TURNKEY_API_PRIVATE_KEY!,
  organizationId: process.env.TURNKEY_ORGANIZATION_ID!,
  signWith: process.env.TURNKEY_SIGN_WITH!, // wallet address or wallet ID
  rpcUrl: process.env.POLYGON_RPC_URL,
});

const sdk = new PredexonSDK({
  apiKey: process.env.PREDEXON_API_KEY!,
  wallet,
});

await sdk.enableTrading({
  core: { venue: 'polymarket', wallet: process.env.TURNKEY_SIGN_WITH! },
  approvals: 'sign',
});

const order = await sdk.placeOrder({
  core: {
    venue: 'polymarket',
    wallet: process.env.TURNKEY_SIGN_WITH!,
    side: 'buy',
    amount: '10',
    type: 'market',
  },
  flags: { tokenId: 'your-token-id' },
});

Install Turnkey peer dependencies:

npm install @turnkey/api-key-stamper @turnkey/http @turnkey/viem

Quick Start: Polymarket with Privy

For apps using Privy embedded wallets. Requires server-side Privy credentials and a P256 authorization key configured in the Privy dashboard.

import { PredexonSDK } from '@predexon/trade-sdk';
import { createPrivyServerAdapter } from '@predexon/trade-sdk/server';

// userWalletAddress is the Privy embedded wallet address for a specific user
const wallet = createPrivyServerAdapter({
  appId: process.env.PRIVY_APP_ID!,
  appSecret: process.env.PRIVY_APP_SECRET!,
  authorizationPrivateKey: process.env.PRIVY_AUTHORIZATION_PRIVATE_KEY!,
  walletAddress: userWalletAddress, // user's Privy embedded wallet
});

const sdk = new PredexonSDK({
  apiKey: process.env.PREDEXON_API_KEY!,
  wallet,
});

await sdk.enableTrading({
  core: { venue: 'polymarket', wallet: userWalletAddress },
  approvals: 'broadcast', // Privy handles gas internally
});

const order = await sdk.placeOrder({
  core: {
    venue: 'polymarket',
    wallet: userWalletAddress,
    side: 'buy',
    size: '100',
    price: '0.55',
    type: 'limit',
  },
  flags: { tokenId: 'your-token-id' },
});

Install Privy peer dependency:

npm install @privy-io/node

Quick Start: Kalshi

import { PredexonSDK, createSolanaAdapter } from '@predexon/trade-sdk';
import { Keypair, VersionedTransaction } from '@solana/web3.js';
import nacl from 'tweetnacl';

const keypair = Keypair.fromSecretKey(/* your secret key bytes */);

const solanaSigner = createSolanaAdapter({
  signSolanaTransaction: async (base64Tx) => {
    const tx = VersionedTransaction.deserialize(Buffer.from(base64Tx, 'base64'));
    tx.sign([keypair]);
    return Buffer.from(tx.serialize()).toString('base64');
  },
  signSolanaMessage: async (message) => {
    const messageBytes = new TextEncoder().encode(message);
    const signature = nacl.sign.detached(messageBytes, keypair.secretKey);
    return Buffer.from(signature).toString('base64');
  },
});

const sdk = new PredexonSDK({
  apiKey: process.env.PREDEXON_API_KEY!,
  solanaSigner,
});

await sdk.enableTrading({
  core: { venue: 'kalshi', wallet: keypair.publicKey.toBase58() },
});

const order = await sdk.placeOrder({
  core: {
    venue: 'kalshi',
    wallet: keypair.publicKey.toBase58(),
    side: 'buy',
    amount: '10',
    type: 'market',
  },
  flags: { ticker: 'MARKET-TICKER', outcome: 'Yes' },
});

Market Identifiers

  • Polymarket tokenId: https://docs.predexon.com/api-reference/markets/list-markets
  • Kalshi ticker: https://docs.predexon.com/api-reference/kalshi/list-markets

Documentation

Full API reference, guides, and examples: docs.predexon.com/sdk

Server Adapters

The SDK provides server-side adapters via @predexon/trade-sdk/server:

| Adapter | Use Case | Peer Dependencies | |---------|----------|-------------------| | createTurnkeyAdapter | Turnkey-managed wallets | @turnkey/api-key-stamper, @turnkey/http, @turnkey/viem | | createPrivyServerAdapter | Privy embedded wallets | @privy-io/node | | createRawKeyAdapter | Dev/test only | None |

Support

Contact Predexon for access and support.