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

# ID del programa Pump.fun, IDL e instrucciones buy y sell

> ID de la bonding curve de Pump.fun 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P, IDL de Anchor, discriminadores y código buy y sell con @solana/web3.js.

El ID del programa de bonding curve de Pump.fun es `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P`. Usa esta referencia para construir o decodificar sus instrucciones. Cubre las cuentas, los discriminadores y el layout de compra y venta. Para los trades posteriores a la graduación, usa la referencia del programa PumpSwap.

> [!NOTE]
>
> ¿Prefieres no construir las instrucciones a mano? La [API de Raptor Swap](https://docs.solanatracker.io/es/raptor/overview.md) enruta compras y ventas entre las bonding curves de Pump.fun y PumpSwap de forma automática.

## IDs oficiales de programa

| Programa | Dirección | Función |
| - | - | - |
| **Pump.fun (bonding curve)** | `6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P` | Crear tokens, comprar y vender en la curva, migrar |
| **Pump.fun AMM (PumpSwap)** | `pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA` | Pools de producto constante posteriores a la graduación |
| **Pump Fees** | `pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ` | Configuración de comisiones usada en compra y venta |

Copia el ID del programa exactamente. Las direcciones Base58 distinguen mayúsculas de minúsculas; la `r` después de `6EF8` es minúscula.

### PDAs conocidas

| Cuenta | Seeds | Dirección |
| - | - | - |
| `global` | `["global"]` | `4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf` |
| `event_authority` | `["__event_authority"]` | PDA del programa Pump |
| `bonding_curve` | `["bonding-curve", mint]` | Cuenta de la curva por token |

Filtros de mercado de Solana Tracker: `pumpfun` (bonding curve), `pumpfun-amm` (graduados / PumpSwap).

## IDL de Anchor

Descarga el IDL oficial de Anchor (réplica de [pump-fun/pump-public-docs](https://github.com/pump-fun/pump-public-docs)):

* **IDL en JSON:** [/idl/pump.json](https://docs.solanatracker.io/idl/pump.json)
* Repositorio original: [idl/pump.json](https://github.com/pump-fun/pump-public-docs/blob/main/idl/pump.json)

```javascript theme={null}
import idl from "./idl/pump.json" assert { type: "json" };
// or: const idl = require("./idl/pump.json");

console.log(idl.address);
// 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P
```

Carga el IDL con `Program` o `BorshInstructionCoder` de Anchor, o usa los discriminadores de abajo para analizar instrucciones sin procesar.

## Discriminadores de instrucciones

Los discriminadores de Anchor son los primeros **8 bytes** de `sha256("global:<instruction_name>")`. Compáralos al analizar transacciones o al construir instrucciones a mano.

| Instrucción | Discriminador (bytes) | Hex |
| - | - | - |
| `buy` | `[102, 6, 61, 18, 1, 218, 235, 234]` | `0x66063d1201daebea` |
| `sell` | `[51, 230, 133, 164, 1, 127, 131, 173]` | `0x33e685a4017f83ad` |
| `create` | `[24, 30, 200, 40, 5, 28, 7, 119]` | `0x181ec828051c0777` |
| `create_v2` | `[214, 144, 76, 236, 95, 139, 49, 180]` | `0xd6904cec5f8b31b4` |
| `buy_exact_sol_in` | `[56, 252, 116, 8, 158, 223, 205, 95]` | `0x38fc74089edfcd5f` |
| `buy_v2` | `[184, 23, 238, 97, 103, 197, 211, 61]` | `0xb817ee6167c5d33d` |
| `sell_v2` | `[93, 246, 130, 60, 231, 233, 64, 178]` | `0x5df6823ce7e940b2` |
| `migrate` | `[155, 234, 231, 146, 236, 158, 162, 30]` | `0x9beae792ec9ea21e` |

`buy` / `sell` en el **AMM** reutilizan los mismos sighashes: comprueba siempre el **ID del programa** (`6EF8rrecth…` frente a `pAMMBay…`) al clasificar trades.

En mainnet, muchos swaps de la curva usan `buy_exact_sol_in` (`0x38fc74089edfcd5f`) en lugar del `buy` clásico. Los parsers deben manejar ambos.

### Detecta compras y ventas en Rust

```rust theme={null}
const BUY: [u8; 8] = [102, 6, 61, 18, 1, 218, 235, 234];
const SELL: [u8; 8] = [51, 230, 133, 164, 1, 127, 131, 173];
const CREATE: [u8; 8] = [24, 30, 200, 40, 5, 28, 7, 119];

fn classify(data: &[u8]) -> Option<&'static str> {
    let disc = data.get(..8)?;
    if disc == BUY { Some("buy") }
    else if disc == SELL { Some("sell") }
    else if disc == CREATE { Some("create") }
    else { None }
}
```

## Instrucción `buy`

**Argumentos**

| Argumento | Tipo | Significado |
| - | - | - |
| `amount` | `u64` | Cantidad de tokens a recibir (unidades base) |
| `max_sol_cost` | `u64` | Tope de slippage en lamports |
| `track_volume` | `OptionBool` | `{ 0 }` = false, `{ 1 }` = true |

**Cuentas**

| # | Cuenta | Escribible | Firmante |
| - | - | - | - |
| 0 | `global` | | |
| 1 | `fee_recipient` | ✓ | |
| 2 | `mint` | | |
| 3 | `bonding_curve` | ✓ | |
| 4 | `associated_bonding_curve` | ✓ | |
| 5 | `associated_user` | ✓ | |
| 6 | `user` | ✓ | ✓ |
| 7 | `system_program` | | |
| 8 | `token_program` | | |
| 9 | `creator_vault` | ✓ | |
| 10 | `event_authority` | | |
| 11 | `program` | | |
| 12 | `global_volume_accumulator` | | |
| 13 | `user_volume_accumulator` | ✓ | |
| 14 | `fee_config` | | |
| 15 | `fee_program` | | |

Lee `fee_recipient` (y el array `fee_recipients`) de la cuenta `global`. Pasa `fee_program` = `pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ`.

## Instrucción `sell`

**Argumentos**

| Argumento | Tipo | Significado |
| - | - | - |
| `amount` | `u64` | Cantidad de tokens a vender (unidades base) |
| `min_sol_output` | `u64` | Mínimo de slippage en lamports |

**Cuentas**

| # | Cuenta | Escribible | Firmante |
| - | - | - | - |
| 0 | `global` | | |
| 1 | `fee_recipient` | ✓ | |
| 2 | `mint` | | |
| 3 | `bonding_curve` | ✓ | |
| 4 | `associated_bonding_curve` | ✓ | |
| 5 | `associated_user` | ✓ | |
| 6 | `user` | ✓ | ✓ |
| 7 | `system_program` | | |
| 8 | `creator_vault` | ✓ | |
| 9 | `token_program` | | |
| 10 | `event_authority` | | |
| 11 | `program` | | |
| 12 | `fee_config` | | |
| 13 | `fee_program` | | |

## Instrucción `create`

**Argumentos:** `name: string`, `symbol: string`, `uri: string`, `creator: pubkey`\
**Discriminador:** `[24, 30, 200, 40, 5, 28, 7, 119]`

Los lanzamientos más recientes suelen usar `create_v2` (campos de Token-2022, Mayhem y cashback). Al integrar flujos de creación, compara con transacciones reales o con el IDL.

## Compra y venta con `@solana/web3.js`

Codifica el discriminador de Anchor y luego los argumentos `u64` en little-endian. `OptionBool` es un solo byte (`0` o `1`).

```javascript theme={null}
import {
  PublicKey,
  TransactionInstruction,
  SystemProgram,
} from "@solana/web3.js";
import { TOKEN_PROGRAM_ID, getAssociatedTokenAddressSync } from "@solana/spl-token";
import bs58 from "bs58";

export const PUMP_PROGRAM_ID = new PublicKey(
  "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"
);
export const PUMP_FEE_PROGRAM_ID = new PublicKey(
  "pfeeUxB6jkeY1Hxd7CsFCAjcbHA9rWtchMGdZ6VojVZ"
);
export const GLOBAL = new PublicKey(
  "4wTV1YmiEkRvAtNtsSGPtUrqRYQMe5SKy2uB4Jjaxnjf"
);

const BUY_DISC = Buffer.from([102, 6, 61, 18, 1, 218, 235, 234]);
const SELL_DISC = Buffer.from([51, 230, 133, 164, 1, 127, 131, 173]);

function u64le(n) {
  const b = Buffer.alloc(8);
  b.writeBigUInt64LE(BigInt(n));
  return b;
}

export function bondingCurvePda(mint) {
  return PublicKey.findProgramAddressSync(
    [Buffer.from("bonding-curve"), mint.toBuffer()],
    PUMP_PROGRAM_ID
  )[0];
}

export function eventAuthorityPda() {
  return PublicKey.findProgramAddressSync(
    [Buffer.from("__event_authority")],
    PUMP_PROGRAM_ID
  )[0];
}

export function creatorVaultPda(creator) {
  return PublicKey.findProgramAddressSync(
    [Buffer.from("creator-vault"), creator.toBuffer()],
    PUMP_PROGRAM_ID
  )[0];
}

export function feeConfigPda() {
  // seeds: ["fee_config", pump_program_id] on the fee program
  return PublicKey.findProgramAddressSync(
    [Buffer.from("fee_config"), PUMP_PROGRAM_ID.toBuffer()],
    PUMP_FEE_PROGRAM_ID
  )[0];
}

/** Build a Pump.fun bonding-curve buy instruction */
export function buildBuyIx({
  mint,
  user,
  feeRecipient,
  creator, // bonding_curve.creator
  amount, // tokens out
  maxSolCost, // lamports
  trackVolume = false,
}) {
  const bondingCurve = bondingCurvePda(mint);
  const associatedBondingCurve = getAssociatedTokenAddressSync(
    mint,
    bondingCurve,
    true
  );
  const associatedUser = getAssociatedTokenAddressSync(mint, user);
  const [globalVolume] = PublicKey.findProgramAddressSync(
    [Buffer.from("global_volume_accumulator")],
    PUMP_PROGRAM_ID
  );
  const [userVolume] = PublicKey.findProgramAddressSync(
    [Buffer.from("user_volume_accumulator"), user.toBuffer()],
    PUMP_PROGRAM_ID
  );

  const data = Buffer.concat([
    BUY_DISC,
    u64le(amount),
    u64le(maxSolCost),
    Buffer.from([trackVolume ? 1 : 0]),
  ]);

  return new TransactionInstruction({
    programId: PUMP_PROGRAM_ID,
    keys: [
      { pubkey: GLOBAL, isSigner: false, isWritable: false },
      { pubkey: feeRecipient, isSigner: false, isWritable: true },
      { pubkey: mint, isSigner: false, isWritable: false },
      { pubkey: bondingCurve, isSigner: false, isWritable: true },
      { pubkey: associatedBondingCurve, isSigner: false, isWritable: true },
      { pubkey: associatedUser, isSigner: false, isWritable: true },
      { pubkey: user, isSigner: true, isWritable: true },
      { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
      { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
      { pubkey: creatorVaultPda(creator), isSigner: false, isWritable: true },
      { pubkey: eventAuthorityPda(), isSigner: false, isWritable: false },
      { pubkey: PUMP_PROGRAM_ID, isSigner: false, isWritable: false },
      { pubkey: globalVolume, isSigner: false, isWritable: false },
      { pubkey: userVolume, isSigner: false, isWritable: true },
      { pubkey: feeConfigPda(), isSigner: false, isWritable: false },
      { pubkey: PUMP_FEE_PROGRAM_ID, isSigner: false, isWritable: false },
    ],
    data,
  });
}

/** Build a Pump.fun bonding-curve sell instruction */
export function buildSellIx({
  mint,
  user,
  feeRecipient,
  creator,
  amount,
  minSolOutput,
}) {
  const bondingCurve = bondingCurvePda(mint);
  const associatedBondingCurve = getAssociatedTokenAddressSync(
    mint,
    bondingCurve,
    true
  );
  const associatedUser = getAssociatedTokenAddressSync(mint, user);

  const data = Buffer.concat([SELL_DISC, u64le(amount), u64le(minSolOutput)]);

  return new TransactionInstruction({
    programId: PUMP_PROGRAM_ID,
    keys: [
      { pubkey: GLOBAL, isSigner: false, isWritable: false },
      { pubkey: feeRecipient, isSigner: false, isWritable: true },
      { pubkey: mint, isSigner: false, isWritable: false },
      { pubkey: bondingCurve, isSigner: false, isWritable: true },
      { pubkey: associatedBondingCurve, isSigner: false, isWritable: true },
      { pubkey: associatedUser, isSigner: false, isWritable: true },
      { pubkey: user, isSigner: true, isWritable: true },
      { pubkey: SystemProgram.programId, isSigner: false, isWritable: false },
      { pubkey: creatorVaultPda(creator), isSigner: false, isWritable: true },
      { pubkey: TOKEN_PROGRAM_ID, isSigner: false, isWritable: false },
      { pubkey: eventAuthorityPda(), isSigner: false, isWritable: false },
      { pubkey: PUMP_PROGRAM_ID, isSigner: false, isWritable: false },
      { pubkey: feeConfigPda(), isSigner: false, isWritable: false },
      { pubkey: PUMP_FEE_PROGRAM_ID, isSigner: false, isWritable: false },
    ],
    data,
  });
}

// Identify buy/sell from a confirmed transaction
export function parsePumpInstructionData(dataBase58) {
  const data = Buffer.from(bs58.decode(dataBase58));
  const disc = data.subarray(0, 8);
  if (disc.equals(BUY_DISC)) {
    return {
      name: "buy",
      amount: data.readBigUInt64LE(8),
      maxSolCost: data.readBigUInt64LE(16),
    };
  }
  if (disc.equals(SELL_DISC)) {
    return {
      name: "sell",
      amount: data.readBigUInt64LE(8),
      minSolOutput: data.readBigUInt64LE(16),
    };
  }
  return null;
}
```

> [!WARNING]
>
> Las instrucciones reales en mainnet suelen añadir **cuentas restantes** después de la lista del IDL (normalmente +2 en `buy` / `buy_exact_sol_in` / `sell` para flujos de cashback o bonding-curve-v2). Los mints Token-2022 usan `TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb` en lugar del token program heredado. Antes de publicar, compara siempre con una transacción reciente exitosa y con la última versión de [/idl/pump.json](https://docs.solanatracker.io/idl/pump.json). Para flujos Token-2022 o multi-quote, usa preferentemente `buy_v2` / `sell_v2` del IDL.

### Alternativa más sencilla: API de swap de Raptor

```javascript theme={null}
const res = await fetch("https://swap-v2.solanatracker.io/swap", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    wallet: "YOUR_WALLET_ADDRESS",
    from: "So11111111111111111111111111111111111111112",
    to: "TOKEN_MINT_ADDRESS",
    amount: 0.1,
    slippage: 15,
    priorityFee: 0.0005,
  }),
});
const { txn } = await res.json();
// Sign and send txn
```

Consulta [Swap API](https://docs.solanatracker.io/es/guides/swap-api.md) y el [resumen de Raptor](https://docs.solanatracker.io/es/raptor/overview.md).

## Streaming e indexación con Solana Tracker

Elige la interfaz que corresponda al nivel de datos que necesitas:

| Producto | Para qué sirve |
| - | - |
| [Pump.fun API](https://www.solanatracker.io/pumpfun-api) | Lanzamientos, curvas, trades y holders indexados |
| [Data API](https://www.solanatracker.io/data-api) | REST: `/tokens/latest`, `/search?launchpad=pumpfun`, graduating y graduated |
| [Datastream](https://www.solanatracker.io/data-api) | Salas WebSocket: `latest`, `graduating:pumpfun:50`, `pumpfun:curve:50` |
| [Memescope](https://www.solanatracker.io/memescope) | UI en vivo de lanzamientos, tramo final y migrados |
| [Raptor](https://www.solanatracker.io/raptor) | Routing de compra y venta en curva + AMM |
| [Yellowstone gRPC](https://www.solanatracker.io/yellowstone-grpc) | Streams sin procesar de transacciones y cuentas del programa |
| [Solana RPC](https://www.solanatracker.io/solana-rpc) | `getTransaction` / `getProgramAccounts` con estos IDs de programa |

Documentación:

* [Pump.fun y bonding curves](https://docs.solanatracker.io/es/guides/pumpfun.md) — ciclo de vida con Data API + Datastream
* [Detección de compras y ventas con gRPC](https://docs.solanatracker.io/es/yellowstone-grpc/examples/pumpfun-transactions.md) — decodificación con el IDL
* [Streaming de cuentas con gRPC](https://docs.solanatracker.io/es/yellowstone-grpc/examples/pumpfun-accounts.md) — estado de la bonding curve
* [Programa AMM de Pump.fun](https://docs.solanatracker.io/es/guides/pumpfun-amm.md) — `buy` / `sell` de PumpSwap

> [card] [Programa PumpSwap](https://docs.solanatracker.io/es/guides/pumpfun-amm.md)
>
> ID del programa PumpSwap, IDL y discriminadores de compra y venta.

> [card] [Lanzamientos y graduación](https://docs.solanatracker.io/es/guides/pumpfun.md)
>
> Encuentra tokens, sigue curvas y graduaciones, y haz swaps con Solana Tracker.

> [card] [Compras y ventas con Yellowstone](https://docs.solanatracker.io/es/yellowstone-grpc/examples/pumpfun-transactions.md)
>
> Análisis de instrucciones en tiempo real por gRPC.

> [card] [Raptor Swap](https://docs.solanatracker.io/es/raptor/overview.md)
>
> Ejecuta swaps de Pump.fun y PumpSwap sin construir instrucciones.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.