Pump.fun bot tutorial: catch new tokens in shreds and buy on the bonding curve
A Pump.fun bot watches the Pump.fun program for create instructions, recognised by the 8-byte Anchor discriminator 181ec828051c0777. It takes the mint and the curve account from the instruction's account list, prices the curve from its virtual reserves, and sends a buy capped by a maximum SOL cost. Reading creates from shreds instead of RPC moves first sight of a token into the slot that creates it.
Shredstream.sh Editorial Team · 9 min read · updated

Pump.fun turned token launches into a production line: anyone can create a token in one transaction, and it trades immediately on a bonding curve with no pool to seed. That makes it the busiest hunting ground for Solana bots, and the most crowded one. Thousands of tokens appear a day, and on the ones that matter, dozens of bots arrive in the first few slots.
This tutorial builds the core of a Pump.fun bot in Rust: seeing creates early, decoding them, pricing the curve without asking anyone, sending the buy, and knowing when to sell. For the general architecture of a sniper, including senders and reconciliation, read our sniper architecture walkthrough first. This page goes deep on the Pump.fun specifics.
How a Pump.fun token moves through its life
Every Pump.fun token goes through the same three phases:
- Create. One transaction mints the token, creates its bonding curve account and writes its metadata. Creators very often add their own buy to the same transaction.
- Bonding curve. Buyers and sellers trade against the curve, which holds the tokens and the SOL. The price follows a constant product formula over virtual reserves, so each buy raises the price for the next.
- Migration. When the curve sells out its allotment it is marked complete, trading on the curve stops, and liquidity moves to an AMM pool.
A sniper bot lives in phase one. Its whole edge is buying while the curve is still near its starting price, which means seeing the create transaction before most other buyers do.
Step 1: get create transactions as early as you can
Pump.fun bots on GitHub mostly subscribe to program logs over WebSocket or poll for new signatures. Both report a create only after the slot is processed. A bot reading shreds sees the same create mid-slot, since shreds are the form in which the leader hands its block to the network.
You need three things for that: a shred feed delivered to your server, a receiver that reassembles shreds into entries, and a decoder that turns entries into transactions. Our quickstart gets packets arriving, and the deshredding walkthrough covers the decode. From here on we assume you have a stream of VersionedTransaction values.
Step 2: recognise the create instruction
Pump.fun is an Anchor program, so each instruction's data opens with an eight-byte Anchor discriminator: the first eight bytes of the SHA-256 hash of the string global: plus the instruction name.
You can compute the constants yourself rather than trusting anyone's copy:
python
import hashlibfor name in ["create", "buy", "sell"]: print(name, hashlib.sha256(f"global:{name}".encode()).digest()[:8].hex())# create 181ec828051c0777# buy 66063d1201daebea# sell 33e685a4017f83adThen the parser. It checks the program, checks the discriminator, and reads three Borsh strings, each a little-endian u32 length followed by UTF-8 bytes:
rust
const PUMP: Pubkey = pubkey!("6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P");const CREATE: [u8; 8] = [0x18, 0x1e, 0xc8, 0x28, 0x05, 0x1c, 0x07, 0x77]; fn read_str(data: &[u8], pos: &mut usize) -> Option<String> { let len = u32::from_le_bytes(data.get(*pos..*pos + 4)?.try_into().ok()?) as usize; *pos += 4; let s = std::str::from_utf8(data.get(*pos..*pos + len)?).ok()?.to_owned(); *pos += len; Some(s)} pub struct PumpCreate { pub mint: Pubkey, pub curve: Pubkey, pub name: String, pub symbol: String, pub uri: String } pub fn parse_create(keys: &[Pubkey], program: &Pubkey, accounts: &[u8], data: &[u8]) -> Option<PumpCreate> { if *program != PUMP || !data.starts_with(&CREATE) { return None; } let mut pos = 8; let name = read_str(data, &mut pos)?; let symbol = read_str(data, &mut pos)?; let uri = read_str(data, &mut pos)?; let mint = *keys.get(*accounts.first()? as usize)?; let curve = *keys.get(*accounts.get(2)? as usize)?; Some(PumpCreate { mint, curve, name, symbol, uri })}Two cautions. First, Pump.fun upgrades its program, and an upgrade can add arguments after the URI or change account positions. Pin your layout to the IDL published in Pump.fun's public docs and recheck it whenever creates stop matching. If the current IDL lists a second create variant, for example one for Token-2022 mints, add its discriminator too. Second, look the program up in the transaction's own key list rather than assuming it sits at a fixed index.
Step 3: price the bonding curve without asking an RPC
Here is where a shred-based bot gains a second advantage. A fresh curve always starts from the same virtual reserves, and the create transaction itself tells you the creator's first buy. So you can compute the exact state of the curve after the create transaction using only bytes already in memory, with no account fetch.
The curve is constant product over virtual reserves. Buying with sol_in lamports (after the fee) returns:
rust
/// Tokens out for a given SOL input, constant product over virtual reserves.fn tokens_out(v_sol: u128, v_tok: u128, sol_in: u128) -> u128 { let k = v_sol * v_tok; v_tok - k / (v_sol + sol_in)} /// Inverse: SOL needed to buy a given token amount (round up).fn sol_in_for(v_sol: u128, v_tok: u128, tok_out: u128) -> u128 { let k = v_sol * v_tok; k.div_ceil(v_tok - tok_out) - v_sol}To get the starting reserves, read them once from the program's global config account at start-up and keep them in memory; at the time of writing a new curve starts at 30 virtual SOL against roughly 1.073 billion virtual tokens, with six decimals. Read the trading fee from the same place rather than hard-coding it, because Pump.fun has changed its fee schedule more than once.
Then, for every create you detect, apply the creator's buy from the same transaction to those starting reserves. The result is the price your buy will face if nobody else gets in first. Every other buy that lands ahead of yours in the slot moves the price further up the curve, which is exactly what your slippage cap is for.
Step 4: build and send the buy
The buy instruction data is the buy discriminator followed by two little-endian u64 values: the token amount you want, and the most SOL you are willing to pay for it.
rust
const BUY: [u8; 8] = [0x66, 0x06, 0x3d, 0x12, 0x01, 0xda, 0xeb, 0xea]; fn buy_data(token_amount: u64, max_sol_cost: u64) -> Vec<u8> { let mut d = Vec::with_capacity(24); d.extend_from_slice(&BUY); d.extend_from_slice(&token_amount.to_le_bytes()); d.extend_from_slice(&max_sol_cost.to_le_bytes()); d}Take the account list for buy from the current IDL rather than from an old tutorial: it has grown over time, and a missing account is the most common reason a copied bot suddenly fails every buy. Most of the accounts are fixed for every token (the global config, the fee recipient, the system and token programs), so derive them once at start-up. Only the mint, the bonding curve, the curve's token account, your own token account and the creator-specific accounts change per token, and all of them are either in the create instruction or derivable from it.
Assemble the transaction as described in the sniper architecture guide: compute budget instructions first, then an idempotent ATA creation so the destination token account exists, then the buy. Sign with a recently refreshed blockhash and fan it out over both a staked connection and a tipped relay.
Size max_sol_cost from the price you computed in Step 3, plus the slippage you will tolerate. Too tight and every contested launch fails with a slippage error. Too loose and you buy the top of somebody else's pump.
Step 5: know when you will sell
The sell instruction mirrors the buy: the sell discriminator, the token amount, and the minimum SOL you will accept.
rust
const SELL: [u8; 8] = [0x33, 0xe6, 0x85, 0xa4, 0x01, 0x7f, 0x83, 0xad]; fn sell_data(token_amount: u64, min_sol_output: u64) -> Vec<u8> { let mut d = Vec::with_capacity(24); d.extend_from_slice(&SELL); d.extend_from_slice(&token_amount.to_le_bytes()); d.extend_from_slice(&min_sol_output.to_le_bytes()); d}Most Pump.fun tokens never reach migration, so a bot that only plans to sell at graduation is mostly holding tokens nobody wants. Useful exit triggers, all detectable from the same shred feed:
- The creator sells. Watch sell instructions on your token signed by the creator wallet from the create transaction.
- A large holder sells. Big sells move the curve sharply down, and you can price the move with the same function you used for buys.
- Time. Attention on a new token fades fast. A time stop protects you from slow bleeds.
- The curve completes. Once the curve account's complete flag is set, curve trading is over and your sell route moves to the AMM pool, with different accounts and different pricing.
Filters that keep a Pump.fun bot solvent
Buying every create is a reliable way to lose money. Before you send a buy, reject launches using data already in memory:
- the creator wallet has launched and dumped before (keep your own list; it compounds);
- the creator's first buy takes a large share of the early supply;
- the name or symbol copies a token that is already popular;
- the metadata URI points somewhere unusual or is reused across many launches;
- the same creator is launching several tokens in a short window.
Do not call an RPC endpoint inside these checks. The point of Step 1 was to remove network round trips from the path between seeing a create and sending a buy.
Open-source Pump.fun bots versus building your own
Searching for a Pump.fun bot on GitHub returns plenty of working code, and it is worth reading for the account lists and edge cases. Treat it as reference, not as something to run with real funds: forks that steal private keys are common, layouts in older repositories are often out of date after program upgrades, and almost all of them take their data from RPC or WebSocket, which places them behind every bot reading shreds.
Telegram Pump.fun bots are the easiest path and the least transparent. You give up custody of the key and cannot see which data feed or sender they use.
Building your own is more work, and the work is exactly the five steps above.
Running this on a shred feed
shredstream.sh delivers Solana shreds as raw UDP from Frankfurt to the server you choose, which is the Step 1 input for this bot. Start the two-hour Premium Shreds trial to put the feed on your own server, so you can count how many Pump.fun creates your bot sees before your current data source reports them. The in-browser decoder helps while you are writing the parser.
In practice
A transaction in the shred stream carries three instructions: two compute budget instructions and one call to the Pump.fun program whose data begins 18 1e c8 28 05 1c 07 77. The parser pulls out the token's name, ticker and metadata link, then takes the mint from account zero and the curve from account two.
The same transaction also carries a 0.5 SOL purchase by the launching wallet. The bot applies it to the starting reserves held in memory, computes the price the next buyer will face, and adds a three percent slippage allowance to set the maximum SOL cost for a 0.2 SOL buy.
The creator has no record on the bot's blocklist and the symbol does not match any popular token, so the bot signs the prepared buy and sends it. Its exit rules are armed at the same moment: sell on any creator sell, on a curve drop of thirty percent from entry, or after ten minutes.
Scope of this page
This tutorial covers detecting Pump.fun creates, pricing the bonding curve and building buy and sell instruction data. It does not provide a complete, runnable bot, a full account list for each instruction, or trading advice. Most Pump.fun tokens go to zero, and bots compete against each other on the same launches.
Discriminators are derived from instruction names and are stable while those names stay the same, but account lists, argument lists, fees and starting reserves are set by a program Pump.fun upgrades. Verify every constant against the current IDL before trading. A create seen in shreds is a proposal, not a confirmed event; the leader's slot may never become part of the chain, and the transaction can fail.
Related questions
It watches transactions that call the Pump.fun program, 6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P, and checks whether the instruction data starts with the create discriminator 181ec828051c0777. The mint is the first account of that instruction and the bonding curve is the third. Reading these transactions from shreds rather than RPC lets the bot see them before the slot has finished.
The curve is constant product over virtual reserves: virtual SOL times virtual tokens stays fixed through each trade. Tokens out for a buy equal the virtual tokens minus the constant divided by virtual SOL plus the SOL paid in, after the fee. Starting reserves are fixed for every new curve, so a bot can price a fresh token without fetching any account.
The buy instruction data is the 8-byte discriminator 66063d1201daebea followed by two little-endian 64-bit integers: the number of tokens to buy and the maximum SOL, in lamports, the buyer will pay. The account list has grown with program upgrades, so take it from the current IDL in Pump.fun's public documentation rather than from older tutorials or repositories.
Treat them as reading material. Many are useful references for instruction layouts, but many forks are built to steal the wallet key you load into them, and older repositories often break after Pump.fun upgrades its program. If you run one, read all of it first and use a throwaway wallet funded with a small amount.
When the bonding curve sells its allotment, the program marks the curve complete and stops accepting buys and sells on it. Liquidity moves to an AMM pool, so any tokens the bot still holds must be sold through that pool, with a different instruction, account list and price formula. A bot should detect the complete flag and switch its sell route.
Read next
Ready to build against this? The documentation covers the implementation.