Canonical: https://solanashreds.xyz/docs/programs/pump-fun

# Pump.fun recipe: create, buy and sell instructions

Turn raw Pump.fun instructions into launch, buy and sell events with the program's official IDL: the new mint, its bonding curve and creator for every launch, and the amounts each trader asked for.

To decode the Pump.fun create instruction, match its discriminator against the program's official IDL, then read the token's name, symbol, URI and creator from the arguments and the new mint and bonding curve from the accounts. The same IDL decodes every buy and sell variant. It is all in the raw transaction, visible as soon as shreds arrive.

## Program ID and IDL source

| What | Value |
| --- | --- |
| Program ID | `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P` |
| IDL | `idl/pump.json` in the team's public docs repository, pinned at commit 639b87f |
| Launch instructions | `create`, `create_v2` |
| Buy instructions | `buy`, `buy_v2`, `buy_v3`, `buy_exact_sol_in`, `buy_exact_quote_in_v2`, `buy_exact_quote_in_v3` |
| Sell instructions | `sell`, `sell_v2`, `sell_v3` |

Older and newer variants live side by side because clients upgrade at their own pace; the recipe handles all of them. The discriminators come from the IDL, as the [Anchor decoding guide](https://solanashreds.xyz/docs/decode/anchor-instructions) explains.

## Steps

1. Keep only top-level instructions whose program is the Pump.fun ID. Program IDs are always static keys, so [filtering by program](https://solanashreds.xyz/docs/decode/filter-by-program) needs no lookup tables.
2. Resolve the instruction's accounts, including any from [lookup tables](https://solanashreds.xyz/docs/decode/resolve-lookup-tables).
3. Decode with the IDL: the discriminator picks the instruction, Borsh gives the arguments, position names the accounts.
4. Map each variant to one event shape: a launch, a buy or a sell. The newer variants name the mint `base_mint`; older ones call it `mint`.
5. Emit the event and keep it provisional until you know the transaction succeeded.

## pump.ts

```typescript file="src/pump.ts"
// Pump.fun recipe: one event per top-level create, buy or sell, decoded with the official IDL
// (pump-fun/pump-public-docs idl/pump.json @ 639b87f) through anchor.ts. Field names are the IDL's own.
import { AnchorDecoder } from "./anchor.ts";

export const PUMP_PROGRAM = "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P";

export type PumpEvent =
  | { type: "create"; instruction: string; mint: string; bondingCurve: string; creator: string; payer: string; name: string; symbol: string; uri: string }
  | { type: "buy"; instruction: string; mint: string; bondingCurve: string; user: string; tokensOut?: bigint; maxQuoteIn?: bigint; quoteIn?: bigint; minTokensOut?: bigint }
  | { type: "sell"; instruction: string; mint: string; bondingCurve: string; user: string; tokensIn: bigint; minQuoteOut: bigint };

export class PumpDecoder {
  private dec: AnchorDecoder;
  constructor(idl: object) { this.dec = new AnchorDecoder(idl as any); }

  /** `accounts` are the instruction's resolved addresses. Returns null for anything that is not a create, buy or sell. */
  decode(data: Uint8Array, accounts: string[]): PumpEvent | null {
    const d = this.dec.decodeWithAccounts(data, accounts, PUMP_PROGRAM);
    if (!d) return null;
    const a = d.accounts, x = d.args as Record<string, any>;
    const mint = (a.mint ?? a.base_mint)!, bondingCurve = a.bonding_curve!, user = a.user!;
    if (d.name === "create" || d.name === "create_v2")
      return { type: "create", instruction: d.name, mint, bondingCurve, creator: x.creator, payer: user, name: x.name, symbol: x.symbol, uri: x.uri };
    if (d.name === "buy" || d.name === "buy_v2" || d.name === "buy_v3") // amount = tokens wanted, max_sol_cost = most the user will pay
      return { type: "buy", instruction: d.name, mint, bondingCurve, user, tokensOut: x.amount, maxQuoteIn: x.max_sol_cost };
    if (d.name === "buy_exact_quote_in_v2" || d.name === "buy_exact_quote_in_v3" || d.name === "buy_exact_sol_in")
      // the user fixes what they pay and sets a floor on tokens received
      return { type: "buy", instruction: d.name, mint, bondingCurve, user, quoteIn: x.spendable_quote_in ?? x.spendable_sol_in, minTokensOut: x.min_tokens_out };
    if (d.name === "sell" || d.name === "sell_v2" || d.name === "sell_v3")
      return { type: "sell", instruction: d.name, mint, bondingCurve, user, tokensIn: x.amount, minQuoteOut: x.min_sol_output };
    return null;
  }
}
```

## decode-pump.ts

```typescript file="src/decode-pump.ts"
// Print Pump.fun events for one transaction.
//   node src/decode-pump.ts <pump.json> <transaction-base64> [loaded-writable,...] [loaded-readonly,...]
import fs from "node:fs";
import { decodeTx } from "./tx.ts";
import { PumpDecoder, PUMP_PROGRAM } from "./pump.ts";

const [idlPath, txBase64, loadedW = "", loadedR = ""] = process.argv.slice(2);
const pump = new PumpDecoder(JSON.parse(fs.readFileSync(idlPath, "utf8")));
const tx = decodeTx(Buffer.from(txBase64, "base64"));
const keys = [...tx.staticKeys, ...loadedW.split(",").filter(Boolean), ...loadedR.split(",").filter(Boolean)];

for (const ix of tx.instructions) {
  if (keys[ix.programIndex] !== PUMP_PROGRAM) continue; // top-level calls only; Pump.fun called by another program is a CPI
  const event = pump.decode(ix.data, ix.accounts.map((i) => keys[i]));
  if (event) console.log(JSON.stringify({ signature: tx.signatures[0], ...event }, (_k, v) => (typeof v === "bigint" ? v.toString() : v)));
}
```

`anchor.ts` and `tx.ts` are the decoder and transaction parser from the [Anchor decoding guide](https://solanashreds.xyz/docs/decode/anchor-instructions).

## What a launch looks like

Run on a real `create_v2` from mainnet slot 470,917,278, the recipe prints one launch event. The token's name, symbol and metadata link are shown as placeholders here, the wallet is shortened and the leading `signature` field is left out; the run printed all of them in full.

```json
{"type":"create","instruction":"create_v2","mint":"Ggm2BUZySzFpPFeazYERLuztBsFxprkHgaF3KXtmpump","bondingCurve":"BWPaVcPtbYwmHQ3tckvxR8XnuYLwRyRLs3ZFvagbSJ7P","creator":"AV5w…6uMV","payer":"AV5w…6uMV","name":"<name>","symbol":"<symbol>","uri":"<metadata url>"}
```

The mint is a fresh keypair that signed the transaction, and the bonding curve is a program-derived address of that mint, so both are known before the transaction runs. In this launch the creator and the payer are the same wallet; the IDL keeps them as separate fields because they do not have to be.

## How this code was tested

Every successful top-level Pump.fun create, buy and sell in the fixtures was decoded and checked against facts that come from somewhere other than the decoder:

| Check | Result |
| --- | --- |
| Bonding curve equals the program-derived address of `["bonding-curve", mint]`, computed independently with @solana/kit 8.6.0 | 11 of 11 events |
| A launch's mint signed the transaction and appears in its post-transaction token balances | 4 of 4 `create_v2` |
| A trader signed their own buy or sell | 7 of 7 |
| Variants seen | `create_v2`, `buy`, `buy_v2`, `buy_v3`, `sell`, `sell_v3` |
| Short forms from older clients (absent trailing arguments) | decoded with those arguments marked absent; strict mode rejects them |

The fixtures are real finalized mainnet transactions fetched on 18 November 2026. Many Pump.fun transactions in a block fail or reach the program through another program; neither kind is in the 11.

## What you cannot know yet

The instruction gives the trader's limits, not the result. A `buy` says how many tokens were wanted and the most the trader would pay; a `buy_exact_quote_in_v3` says how much they would pay and the fewest tokens they would accept. The tokens actually received, the price paid and whether the trade went through at all come from execution. So does the moment a curve completes, which the program reports in its `CompleteEvent`, not in any instruction you can see beforehand. [The bonding curve, as data](https://solanashreds.xyz/learn/pump-fun-bonding-curve) covers the curve account and its fields.

## Launches this recipe will not see

A launch or trade made by another program calling Pump.fun is an inner instruction, and inner instructions are not in raw transactions; [inner instructions and CPIs](https://solanashreds.xyz/learn/inner-instructions-and-cpi) explains why. Failed transactions decode just like successful ones, so do not count them as launches until you have reconciled. And if Pump.fun changes its instructions, a pinned IDL stops matching: watch for unknown discriminators from this program as the first sign.

## After the bonding curve

When a curve completes, the token moves to PumpSwap through the program's migrate instructions; the [PumpSwap recipe](https://solanashreds.xyz/docs/programs/pumpswap) picks it up there. For the different ways to spot new tokens, see [detecting new tokens](https://solanashreds.xyz/compare/new-token-data-sources), and for one launch decoded by hand, [a launch byte by byte](https://solanashreds.xyz/blog/a-pump-fun-launch-byte-by-byte). To watch launches on your own feed, [see pricing](https://solanashreds.xyz/pricing).
