SDK Documentation

Everything you need to integrate NexromDEX into your agent or application. TypeScript and Python SDKs with full x402 auto-pay and MPC wallet support.

TypeScript / JavaScript

npm install NexromDEX

Python

pip install NexromDEX

TypeScript Quick Start

API Client (no wallet needed)

Use this for read-only operations like quotes and balance checks.

import { NexromDEXClient } from 'NexromDEX';

const client = new NexromDEXClient('https://api.NexromDEX.com');

// Get a swap quote
const quote = await client.getQuote(
  'So11111111111111111111111111111111111111112',   // SOL
  'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
  '100000000', // 0.1 SOL in lamports
);

console.log(`Output: ${quote.output_after_fee} USDC`);

x402 Auto-Pay Agent (with wallet)

Full agent with wallet management and automatic 402 payment handling.

import { X402AutoPayAgent } from 'NexromDEX';

const agent = new X402AutoPayAgent({
  apiUrl: 'https://api.NexromDEX.com',
  walletPath: './wallet.json', // or use walletSecretKey
  autoSwap: true,
});

console.log(`Agent wallet: ${agent.getWalletAddress()}`);

// When you get a 402 Payment Required response:
const result = await agent.handle402(paymentResponseBody);

if (result.success) {
  console.log(`Paid! Signature: ${result.payment_signature}`);
}

HTTP Interceptor (Zero-Config)

The fastest way to add x402 support. Automatically intercepts all fetch() calls and handles 402 responses transparently.

import { HTTPInterceptor } from 'NexromDEX';

const interceptor = new HTTPInterceptor({
  apiUrl: 'https://api.NexromDEX.com',
  walletPath: './wallet.json',
  autoSwap: true,
});

// All fetch() calls now auto-handle 402 Payment Required
const response = await fetch('https://some-x402-api.com/data');
// If it returns 402, the agent pays automatically and retries

// Restore original fetch when done
interceptor.restore();

x402 Auto-Pay Flow

When your agent calls an API that returns HTTP 402 Payment Required, NexromDEX handles the entire payment flow automatically:

  1. Agent calls API → Gets 402 Payment Required
  2. Interceptor parses → Extracts token, amount, recipient from 402 body
  3. Checks balance → Does agent have the required token?
  4. Auto-swaps if needed → Swaps SOL/any token to the required token via Jupiter
  5. Makes payment → Signs and sends Solana transaction
  6. Retries original request → Includes payment proof in headers

Manual x402 Handling (TypeScript)

import { NexromDEXClient } from 'NexromDEX';

const client = new NexromDEXClient('https://api.NexromDEX.com');

// Parse a 402 response body
const requirements = await client.parsePayment(response402Body);

// One-call auto-pay: checks balance, swaps if needed, pays
const result = await client.autoPay(
  response402Body,
  walletAddress,
  'So11111111111111111111111111111111111111112', // pay from SOL
  true, // autoSwap
);

Python Quick Start

Get a Quote

from NexromDEX import NexromDEX

dex = NexromDEX(
    api_url="https://api.NexromDEX.com",
    wallet_path="~/.config/solana/id.json",
)

# Get a swap quote
quote = dex.quote(
    token_in="So11111111111111111111111111111111111111112",   # SOL
    token_out="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", # USDC
    amount_in=100_000_000,  # 0.1 SOL in lamports
)
print(f"Output: {quote['output_after_fee']} USDC")

Execute a Swap

result = dex.swap(
    token_in="So11111111111111111111111111111111111111112",
    token_out="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    amount_in=100_000_000,
    wait_for_confirmation=True,
)
print(f"Swap signature: {result['signature']}")

Handle x402 Payments

# When your agent gets a 402 Payment Required response:
result = dex.handle_x402_payment(payment_402_response_body)

if result['ready']:
    print("Payment ready — sufficient balance")
else:
    print(f"Swap completed: {result['swap_result']['signature']}")

# Or use the one-call auto-pay:
result = dex.x402_auto_pay(
    payment_response_body=response_402_body,
    auto_swap=True,
)

MPC Wallet Integration

MPC (Multi-Party Computation) wallets let agents sign transactions without ever holding a raw private key. The key is split into encrypted fragments — no single party ever sees the full key. NexromDEX is building first-class MPC support so agents can create and manage wallets programmatically.

Why MPC Wallets for Agents?

Security Risk

Raw private keys in config files are one leaked .env away from a drained wallet.

No Guardrails

With a raw key, an agent can do anything with those funds. No spending limits, no token restrictions.

Enterprise Blocker

No compliance team will approve an AI agent holding a raw private key. MPC removes this barrier.

TransactionSigner Interface

The SDK is being refactored around a pluggable TransactionSigner interface. This means the same agent code works with a local keypair or an MPC signer — no changes needed.

interface TransactionSigner {
  getAddress(): string;
  signTransaction(transactionBase64: string): Promise<string>;
}

Turnkey MPC Integration (Coming Soon)

Create an MPC wallet for your agent in one line. No private key needed. Powered by Turnkey — used by Magic Eden, Squads, and Mysten Labs.

import { X402AutoPayAgent } from 'NexromDEX';

const agent = new X402AutoPayAgent({
  apiUrl: 'https://api.NexromDEX.com',
  turnkeyApiKey: 'your-turnkey-key',
  createWallet: true,  // Creates a new MPC wallet automatically
  autoSwap: true,
});

// Agent now has its own wallet — no private key needed
console.log('Agent wallet:', agent.getAddress());

Wallet Management API (Coming Soon)

New REST endpoints for creating and managing MPC wallets programmatically.

POST
/api/wallet/create

Create a new MPC wallet for an agent

GET
/api/wallet/:id

Get wallet info and balances

PUT
/api/wallet/:id/policy

Set spending limits and token allowlists

GET
/api/wallet/list

List all wallets in your organization

Policy Engine (Coming Soon)

Enterprise-grade guardrails for agent wallets. Set rules before your agent ever touches funds.

Spending Limits

Max per transaction, per day, per week

Token Allowlists

Only allow specific tokens (e.g., SOL + USDC only)

Recipient Allowlists

Only allow payments to approved addresses

Time-Based Rules

Active hours, cooldown periods between transactions

MPC vs Raw Keypair

CapabilityRaw KeypairMPC Wallet
Wallet creationManual exportOne API call
Key securityFull key in configKey never exists in one place
Spending limitsCustom codeBuilt-in policy engine
Audit trailCustom loggingFull transaction history
Enterprise-readyNoSOC 2 compliant
Fleet managementManual per agentCentralized dashboard

API Reference

TypeScript — NexromDEXClient

Stateless API client. No wallet needed for read-only operations.

MethodDescription
getQuote(inputMint, outputMint, amount, slippageBps?)Get swap quote
buildSwapTransaction(wallet, inputMint, outputMint, amount)Build unsigned swap transaction
sendTransaction(signedTransaction)Send signed transaction
getTransactionStatus(signature)Check transaction status
getBalance(walletAddress, tokenMint)Check token balance
parsePayment(body)Parse x402 payment requirements
autoPay(body, wallet, inputToken?, autoSwap?)One-call x402 auto-pay

TypeScript — X402AutoPayAgent Config

FieldTypeDefaultDescription
apiUrlstringrequiredNexromDEX API URL
walletPathstring?Path to wallet JSON file
walletSecretKeyUint8Array | number[] | string?Secret key (base58, array, or bytes)
preferredInputTokenstring?SOLToken to swap from
autoSwapboolean?trueAuto-swap if insufficient balance
webhookUrlstring?Webhook for transaction updates
rpcUrlstring?mainnetSolana RPC URL

Python — NexromDEX

MethodDescription
quote(token_in, token_out, amount_in)Get swap quote
swap(token_in, token_out, amount_in)Execute swap (build, sign, send)
swap_build(token_in, token_out, amount_in)Build unsigned transaction
get_balance(token_mint)Check token balance
parse_x402_payment(body)Parse 402 response
handle_x402_payment(body)Full x402 payment flow
x402_auto_pay(body)One-call auto-pay
search_tokens(query)Search tokens
batch_balances(requests)Batch balance checks
get_transaction_history()Get transaction history

Wallet Configuration

TypeScript

// From file
new X402AutoPayAgent({
  walletPath: './wallet.json',
  ...
});

// From secret key
new X402AutoPayAgent({
  walletSecretKey: process.env.WALLET_KEY,
  ...
});

Python

# From file
dex = NexromDEX(
    wallet_path="./wallet.json"
)

# From secret key bytes
dex = NexromDEX(
    wallet_secret_key=[1, 2, 3, ...]
)

# From existing Keypair
from solana.keypair import Keypair
kp = Keypair()
dex = NexromDEX(wallet_keypair=kp)

Common Token Addresses

TokenMint Address
SOLSo11111111111111111111111111111111111111112
USDCEPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
USDTEs9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB

REST API Endpoints

Base URL: https://api.NexromDEX.com

GET
/api/quote?inputMint=...&outputMint=...&amount=...

Get swap quote with price, fees, and minimum output

POST
/api/swap/build

Build unsigned swap transaction for client-side signing

GET
/api/balance?wallet=...&token=...

Check token balance for a wallet

POST
/api/x402/parse-payment

Parse a 402 Payment Required response body

POST
/api/x402/auto-pay

Complete x402 payment flow: check balance, swap, pay

GET
/api/ultra/order

Jupiter Ultra: get quote + ready-to-sign transaction in one call

POST
/api/ultra/execute

Jupiter Ultra: submit signed transaction for execution

GET
/api/ultra/holdings?wallet=...

Get wallet token balances via Jupiter Ultra

Ready to Integrate?

Get your agent connected to NexromDEX in under 5 minutes. Zero platform fees. Best prices via Jupiter.