getting started with parasoldex in 5 minutes
most dex integrations take hours. config files, authentication layers, token registries, route management. it adds up.
parasoldex was built for the opposite experience. five minutes from npm install to your first swap. automatic x402 payment handling so your AI agents can pay for services on solana without manual intervention.
this guide walks through everything — prerequisites, installation, first swap, and handling x402 payment flows. by the end, you'll have a working integration in whichever language you prefer.
---
what you'll need
before writing any code, make sure you have these ready:
if you're testing, use Solana devnet first. you can get free devnet SOL from faucet.solana.com. there's no reason to risk real funds while experimenting.
a note on wallets
parasoldex signs transactions client-side. your private key never leaves your machine, never touches our servers. if you're building production agents, consider using an MPC wallet like Turnkey for key management instead of raw keypairs. more on that later.
---
installation
typescript / javascript
``bash
npm install moltydex
`
or with yarn:
`bash
yarn add moltydex
`
or pnpm, if that's your thing:
`bash
pnpm add moltydex
`
the sdk has minimal dependencies. it wraps the parasoldex api and handles transaction construction, signing, and submission. no heavy frameworks, no peer dependency headaches.
python
`bash
pip install moltydex
`
the python sdk mirrors the typescript api surface almost exactly. same method names, same parameter shapes. if you know one, you know both.
---
quick start — typescript
here's the minimum viable integration. initialize the client, get a quote, done. for full swap execution see parasol.so/sdk.
`typescript
import { MoltyDEXClient } from "moltydex";
const client = new MoltyDEXClient("https://api.parasol.so");
async function main() {
const quote = await client.getQuote(
"So11111111111111111111111111111111111111112", // SOL
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", // USDC
"1000000000", // 1 SOL in lamports
50 // 0.5% slippage
);
console.log(expected output: ${quote.output_after_fee} USDC);
}
main();
`
for a full swap including signing and submission, use X402AutoPayAgent or buildSwapTransaction + sendTransaction. the SDK docs have the complete flow.
what's happening under the hood
hits the parasoldex api at api.parasol.so, which queries jupiter for optimal routing across all solana dex pools builds the unsigned tx, you sign locally, then sendTransaction() submits itif the transaction fails (slippage exceeded, insufficient balance, network congestion), nothing happens. your funds stay put.
---
quick start — python
the python equivalent:
`python
from moltydex import MoltyDEX
dex = MoltyDEX(
api_url="https://api.parasol.so",
wallet_path="~/.config/solana/id.json",
)
quote = dex.quote(
token_in="So11111111111111111111111111111111111111112",
token_out="EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
amount_in=100_000_000, # 0.1 SOL in lamports
)
print(f"expected output: {quote['output_after_fee']} USDC")
for full swap: result = dex.swap(token_in, token_out, amount_in, wait_for_confirmation=True)
`
same flow, same logic. the python sdk mirrors the typescript api. see parasol.so/sdk for the complete reference.
---
handling x402 payments
this is where parasoldex becomes more than just another swap api. the x402 protocol is an emerging standard for machine-to-machine payments on the web. when an api returns HTTP 402 Payment Required, it's saying "pay me and I'll give you what you asked for."
parasoldex can detect, process, and fulfill these payment requests automatically.
what is x402
the short version: an AI agent makes an api call. the server responds with a 402 status code and headers specifying what token to pay, how much, and where to send it. the agent pays, retries the request, and gets the data.
without parasoldex, your agent needs custom logic for each payment scenario — checking balances, finding swap routes if it holds the wrong token, constructing payment transactions, retrying requests. it's a lot of plumbing.
with parasoldex, it's one method call.
automatic x402 handling in typescript
`typescript
import { HTTPInterceptor } from "moltydex";
const interceptor = new HTTPInterceptor({
apiUrl: "https://api.parasol.so",
walletPath: "./wallet.json",
autoSwap: true,
});
// all fetch() calls now auto-handle 402 — no wrapper needed
const response = await fetch("https://some-paid-api.com/data");
const data = await response.json();
async function fetchPaidData() {
const response = await parasol.fetch("https://api.example.com/premium-data", {
method: "GET",
headers: {
"Content-Type": "application/json",
},
});
if (response.paymentMade) {
console.log(paid ${response.paymentAmount} ${response.paymentToken});
console.log(tx: ${response.paymentTxId});
}
return response.data;
}
`
once the interceptor is active, the standard fetch() api automatically handles 402 responses:
all of this happens transparently. your agent code doesn't need to know any of this is happening.
automatic x402 handling in python
`python
from moltydex import MoltyDEX
dex = MoltyDEX(
api_url="https://api.parasol.so",
wallet_path="~/.config/solana/id.json",
)
when your agent gets a 402 response body:
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 one-call auto-pay:
result = dex.x402_auto_pay(
payment_response_body=response_402_body,
auto_swap=True,
)
`
---
configuration options
the moltydex sdk (used by parasoldex) accepts apiUrl, walletPath or walletSecretKey, autoSwap, rpcUrl, and more. see the full reference at parasol.so/sdk.
recommended settings for ai agents
if you're building autonomous agents that make unsupervised payments:
— agents shouldn't need to manage token balances manually---
testing on devnet
always test on devnet first. free tokens, no risk. use rpcUrl to point at devnet:
`typescript
const client = new MoltyDEXClient("https://api.parasol.so");
const quote = await client.getQuote(
"So11111111111111111111111111111111111111112",
"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU", // devnet USDC
"100000000",
100
);
console.log(quote);
`
devnet has limited liquidity. you're testing the integration, not the routing.
---
error handling
things fail. networks get congested. rpcs go down. balances change between quote and execution. wrap your calls in try/catch and handle errors gracefully. the moltydex sdk surfaces structured errors — see parasol.so/sdk for the full error reference.
---
common patterns
http interceptor for fetch
the HTTPInterceptor from moltydex patches the global fetch. once active, any fetch() call that receives a 402 is handled automatically — swap if needed, pay, retry. no axios wrapper required. see the SDK docs for the full interceptor API.
spending limits
for production agents, use a dedicated wallet with limited funds. consider MPC wallets (Turnkey) for policy-based spending limits. the moltydex sdk supports webhookUrl` for transaction notifications — hook that into your monitoring.
---
next steps
you've got a working parasoldex integration. from here:
the full api reference is available in the sdk package and on our documentation site.
---
get access
parasoldex is currently in invite-only access. if you're building agents on solana and want to integrate automatic payment handling, request access at parasol.so/access.
it takes about 30 seconds. no wallet connection required.
---
parasol — it sees what you can't.