> ## Documentation Index
> Fetch the complete documentation index at: https://pond.dflow.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Buy Outcome Tokens

> How to buy outcome tokens with USDC, CASH, or any SPL token

<Info>
  During development, you can use the [developer endpoints](/get-started/endpoints)
  without an API key. For production use, [request an API key](/get-started/api-key)
  for higher rate limits.
</Info>

There are two ways to buy outcome tokens:

1. Using the settlement mint (USDC or CASH) is the direct path.
2. Any other SPL token adds a swap leg first and roughly **50ms** of latency.

## With USDC or CASH

Every market supports both USDC and CASH as settlement mints. Pass your chosen mint as `inputMint` and the outcome token as `outputMint`.

<Steps>
  <Step title="Set up">
    Imports, env config, and the wallet/connection used across every step.

    <AccordionGroup>
      <Accordion title="Imports, env, and wallet">
        ```typescript theme={null}
        import "dotenv/config";

        import { Connection, Keypair, VersionedTransaction } from "@solana/web3.js";
        import bs58 from "bs58";

        const DFLOW_TRADE_API_URL = process.env.DFLOW_TRADE_API_URL ?? "https://dev-quote-api.dflow.net";
        const DFLOW_API_KEY = process.env.DFLOW_API_KEY; // optional; not needed for dev endpoints
        const DFLOW_SETTLEMENT_MINT = process.env.DFLOW_SETTLEMENT_MINT ?? "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC
        const SOLANA_RPC_URL = process.env.SOLANA_RPC_URL ?? "https://api.mainnet-beta.solana.com";

        const connection = new Connection(SOLANA_RPC_URL, "confirmed");
        const keypair = Keypair.fromSecretKey(
          bs58.decode(process.env.SOLANA_PRIVATE_KEY ?? "")
        );

        const headers: HeadersInit = {};
        if (DFLOW_API_KEY) headers["x-api-key"] = DFLOW_API_KEY;
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Request an order">
    <AccordionGroup>
      <Accordion title="Request an order">
        ```typescript theme={null}
        const outcomeMint = "OUTCOME_TOKEN_MINT_ADDRESS"; // yesMint or noMint
        const amount = 1_000_000; // 1 USDC (6 decimals). Contracts can't be bought fractionally, so the amount must be at least the price of one contract.

        const params = new URLSearchParams({
          inputMint: DFLOW_SETTLEMENT_MINT,
          outputMint: outcomeMint,
          amount: amount.toString(),
          userPublicKey: keypair.publicKey.toBase58(),
        });

        const order = await fetch(
          `${DFLOW_TRADE_API_URL}/order?${params}`,
          { headers }
        ).then((r) => r.json());
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Sign and submit">
    <AccordionGroup>
      <Accordion title="Sign and submit">
        ```typescript theme={null}
        const txBuffer = Buffer.from(order.transaction, "base64");
        const transaction = VersionedTransaction.deserialize(txBuffer);

        transaction.sign([keypair]);

        const signature = await connection.sendRawTransaction(transaction.serialize(), {
          skipPreflight: true,
          maxRetries: 2,
        });
        console.log(`  Tx: https://orbmarkets.io/tx/${signature}`);

        await connection.confirmTransaction({
          signature,
          blockhash: transaction.message.recentBlockhash,
          lastValidBlockHeight: order.lastValidBlockHeight,
        });
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Check order status">
    <AccordionGroup>
      <Accordion title="Check order status">
        ```typescript theme={null}
        const status = await fetch(
          `${DFLOW_TRADE_API_URL}/order-status?signature=${signature}`,
          { headers }
        ).then((r) => r.json());

        console.log(status.status, status.fills);
        ```
      </Accordion>
    </AccordionGroup>
  </Step>
</Steps>

## With any SPL token

The `/order` endpoint accepts any SPL token as `inputMint`. It automatically routes through the settlement mint: **Input Token → Settlement Mint → Outcome Token**. The transaction returned covers both legs.

Set `amount` in the input token's native decimals (9 for SOL, 6 for USDC).

<Steps>
  <Step title="Request an order">
    <AccordionGroup>
      <Accordion title="Request an order">
        ```typescript theme={null}
        // Reuses DFLOW_TRADE_API_URL, headers, and keypair from the setup above.
        const splInputMint = "So11111111111111111111111111111111111111112"; // SOL
        const splOutcomeMint = "OUTCOME_TOKEN_MINT_ADDRESS"; // yesMint or noMint
        const splAmount = 1_000_000_000; // 1 SOL (9 decimals)

        const splParams = new URLSearchParams({
          inputMint: splInputMint,
          outputMint: splOutcomeMint,
          amount: splAmount.toString(),
          userPublicKey: keypair.publicKey.toBase58(),
        });

        const splOrder = await fetch(
          `${DFLOW_TRADE_API_URL}/order?${splParams}`,
          { headers }
        ).then((r) => r.json());
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Sign and submit">
    <AccordionGroup>
      <Accordion title="Sign and submit">
        ```typescript theme={null}
        const splTxBuffer = Buffer.from(splOrder.transaction, "base64");
        const splTransaction = VersionedTransaction.deserialize(splTxBuffer);

        splTransaction.sign([keypair]);

        const splSignature = await connection.sendRawTransaction(splTransaction.serialize(), {
          skipPreflight: true,
          maxRetries: 2,
        });
        console.log(`  Tx: https://orbmarkets.io/tx/${splSignature}`);

        await connection.confirmTransaction({
          signature: splSignature,
          blockhash: splTransaction.message.recentBlockhash,
          lastValidBlockHeight: splOrder.lastValidBlockHeight,
        });
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Check order status">
    <AccordionGroup>
      <Accordion title="Check order status">
        ```typescript theme={null}
        const splStatus = await fetch(
          `${DFLOW_TRADE_API_URL}/order-status?signature=${splSignature}`,
          { headers }
        ).then((r) => r.json());

        console.log(splStatus.status, splStatus.fills);
        ```
      </Accordion>
    </AccordionGroup>
  </Step>
</Steps>

## Market initialization

The first trade into a market that has not yet been tokenized incurs a one-time fee of approximately **0.02 SOL**, paid in SOL. The `/order` endpoint detects this automatically and includes the initialization instruction in the transaction. No code changes are required.

## Related Resources

<CardGroup cols={2}>
  <Card title="Prediction Market Quickstart" href="/prediction-markets/recipes/quickstart" icon="rocket">
    Build a Kalshi prediction market integration end-to-end.
  </Card>

  <Card title="Change Position Size" href="/prediction-markets/recipes/change-position-size" icon="arrows-up-down">
    Increase or decrease an existing prediction market position.
  </Card>

  <Card title="KYC for Kalshi" href="/prediction-markets/kyc" icon="shield-check">
    Verify wallets before they receive Kalshi outcome tokens.
  </Card>

  <Card title="Authenticate Requests" href="/resources/recipes/api-keys" icon="key">
    Authenticate requests for production rate limits.
  </Card>
</CardGroup>

## API Routes

* [`GET /order`](/resources/trading-api/order/order)
* [`GET /order-status`](/resources/trading-api/order/order-status)
