Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Every command that sends a transaction waits for it to land and reports what hap
pumpfun launch --name "MyToken" --ticker "MTK" --uri https://example.com/mytoken.json --buy 0.1
```

pump.fun no longer accepts anonymous metadata uploads, so `launch` takes the URI of a metadata JSON you host (`name`, `symbol`, `description`, `image`). Without `--uri` it still tries the upload and says so when it is refused. `--buy` buys in the same transaction as the create, so nobody buys first.
pump.fun no longer accepts anonymous metadata uploads, so `launch` requires `--uri`: the URI of a metadata JSON you host (`name`, `symbol`, `description`, `image`), for example on IPFS or any static host. `--buy` buys in the same transaction as the create, so nobody buys first.

## Commands

Expand All @@ -106,7 +106,7 @@ Transaction inspection (requires RPC):
pumpfun tx-status <signature> Confirmation status, slot, fee, errors

Token launch (requires RPC + wallet):
pumpfun launch --name X --ticker Y [--uri U | --desc D --image P] [--buy N]
pumpfun launch --name X --ticker Y --uri U [--buy N]
[--quote-mint M] [--creator-fee-bps N] [--holder-reward]
[--mayhem] [--slippage N] [--fast]

Expand Down Expand Up @@ -191,7 +191,7 @@ A pump.fun bonding curve pays a sell out of its real reserves, which on some coi
| `info` | Solana RPC (`getAccountInfo` for bonding curve PDA; LaunchLab: `getMultipleAccounts`, `getProgramAccounts`) | JSON-RPC |
| `buy` | Solana RPC (`getAccountInfo`, `getLatestBlockhash`, `sendTransaction`; LaunchLab adds `getMultipleAccounts`, `getProgramAccounts`) | JSON-RPC |
| `sell` | Solana RPC (`getAccountInfo`, `getTokenAccountBalance`, `getLatestBlockhash`, `sendTransaction`; LaunchLab as `buy`) | JSON-RPC |
| `launch` | Solana RPC (`sendTransaction`); `pump.fun/api/ipfs` only without `--uri` | JSON-RPC (+ HTTPS) |
| `launch` | Solana RPC (`sendTransaction`) | JSON-RPC |
| `tx-status` | Solana RPC (`getTransaction`) | JSON-RPC |
| `migrate` | Solana RPC (`sendTransaction`) | JSON-RPC |
| `claim-cashback` | Solana RPC (`sendTransaction`) | JSON-RPC |
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pumpfun-cli"
version = "0.4.0"
version = "0.5.0"
description = "CLI for pump.fun and Raydium LaunchLab on Solana — trade, launch, and browse tokens"
readme = "README.md"
license = {text = "Apache-2.0"}
Expand Down
2 changes: 1 addition & 1 deletion src/pumpfun_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""pumpfun-cli — CLI for pump.fun on Solana."""

__version__ = "0.4.0"
__version__ = "0.5.0"
14 changes: 6 additions & 8 deletions src/pumpfun_cli/commands/launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ def launch(
ctx: typer.Context,
name: str = typer.Option(..., "--name", help="Token name"),
ticker: str = typer.Option(..., "--ticker", help="Token ticker/symbol"),
desc: str = typer.Option("", "--desc", help="Token description (for the metadata upload)"),
image: str | None = typer.Option(None, "--image", help="Path to token image"),
uri: str | None = typer.Option(
None,
uri: str = typer.Option(
...,
"--uri",
help="Metadata JSON URI you already host; skips the pump.fun upload (--desc and --image are then unused)",
help="URI of the metadata JSON you host (name, symbol, description, image)",
),
buy: float | None = typer.Option(
None,
Expand Down Expand Up @@ -52,6 +50,8 @@ def launch(
error("Token name cannot be empty.", exit_code=2)
if not ticker.strip():
error("Token ticker cannot be empty.", exit_code=2)
if not uri.strip():
error("Metadata URI cannot be empty.", hint="Pass --uri <url>", exit_code=2)
if not state or not state.rpc:
error("RPC endpoint not configured.", hint="Run: pumpfun config set rpc <url>")
if slippage < 0 or slippage > 100:
Expand Down Expand Up @@ -84,16 +84,14 @@ def launch(
password,
name,
ticker,
desc,
image,
uri,
initial_buy=buy,
is_mayhem=mayhem,
quote_mint_str=quote_mint,
creator_fee_bps=creator_fee_bps,
is_holder_reward=holder_reward,
slippage=slippage,
confirm=confirm,
uri=uri,
**overrides,
)
)
Expand Down
54 changes: 5 additions & 49 deletions src/pumpfun_cli/core/launch.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"""Token launch — create_v2 with IPFS metadata upload."""
"""Token launch — create_v2 with metadata the caller hosts."""

import os
from pathlib import Path

import httpx
from solders.keypair import Keypair
from spl.token.instructions import create_idempotent_associated_token_account

Expand All @@ -13,7 +11,6 @@
from pumpfun_cli.protocol.address import derive_bonding_curve, find_ata, find_holder_rewards
from pumpfun_cli.protocol.client import RpcClient, TransactionFailedError
from pumpfun_cli.protocol.contracts import (
HTTP_HEADERS,
LAUNCH_COMPUTE_UNITS,
TOKEN_2022_PROGRAM,
TOKEN_DECIMALS,
Expand All @@ -39,34 +36,6 @@
_BPS = 10_000


async def upload_metadata(
name: str,
symbol: str,
description: str,
image_path: str | None = None,
) -> str:
"""Upload token metadata to pump.fun's IPFS endpoint. Returns metadata URI."""
async with httpx.AsyncClient(timeout=30.0, headers=HTTP_HEADERS) as client:
files = {}
data = {
"name": name,
"symbol": symbol,
"description": description,
"showName": "true",
}
if image_path and os.path.exists(image_path):
files["file"] = (os.path.basename(image_path), open(image_path, "rb"), "image/png")
resp = await client.post(
"https://pump.fun/api/ipfs",
data=data,
files=files if files else None,
)
if resp.status_code != 200:
raise RuntimeError(f"Metadata upload to pump.fun failed (HTTP {resp.status_code})")
result = resp.json()
return result.get("metadataUri") or result.get("metadata_uri") or result.get("uri", "")


def opening_buy_tokens(
global_state: dict, amount_raw: int, opening_reserves: int, creator_fee_bps: int | None
) -> int:
Expand Down Expand Up @@ -94,8 +63,7 @@ async def launch_token(
password: str,
name: str,
ticker: str,
description: str,
image_path: str | None = None,
uri: str,
initial_buy: float | None = None,
is_mayhem: bool = False,
quote_mint_str: str | None = None,
Expand All @@ -105,12 +73,11 @@ async def launch_token(
confirm: bool = False,
priority_fee: int | None = None,
compute_units: int | None = None,
uri: str | None = None,
) -> dict:
"""Launch a new coin with create_v2, optionally buying it in the same transaction.

`uri` is a metadata JSON already hosted elsewhere; without it the metadata
is uploaded to pump.fun, which may refuse an unauthenticated upload.
`uri` points at a metadata JSON the caller hosts; pump.fun accepts no
anonymous uploads.

With `initial_buy`, create and buy go out as one transaction (v1, since
together they exceed v0), so nobody can buy in between.
Expand All @@ -132,7 +99,7 @@ async def launch_token(
client = RpcClient(rpc_url)
try:
# Refuse anything the program would reject or silently ignore before
# uploading metadata or spending a fee.
# spending a fee.
check_mayhem_quote(quote_mint, is_mayhem)
global_state = await fetch_global(client)
if is_holder_reward and not global_state.get("is_holder_reward_enabled", False):
Expand Down Expand Up @@ -162,17 +129,6 @@ async def launch_token(
),
}

if not uri:
try:
uri = await upload_metadata(name, ticker, description, image_path)
except (RuntimeError, httpx.HTTPError) as exc:
return {
"error": "ipfs_failed",
"message": f"{exc}. Host the metadata JSON yourself and pass --uri.",
}
if not uri:
return {"error": "ipfs_failed", "message": "Failed to get metadata URI from IPFS."}

mint_keypair = Keypair()
mint = mint_keypair.pubkey()
bonding_curve = derive_bonding_curve(mint)
Expand Down
26 changes: 16 additions & 10 deletions tests/test_commands/test_human_output.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Human-readable output for the reshaped results, labelled by the coin's quote asset."""

import re
from unittest.mock import AsyncMock, patch

import pytest
Expand Down Expand Up @@ -200,8 +201,8 @@ def test_launch_forwards_options(wallet):
"N",
"--ticker",
"T",
"--desc",
"d",
"--uri",
"u",
"--buy",
"2",
"--quote-mint",
Expand Down Expand Up @@ -231,8 +232,8 @@ def test_launch_rejects_negative_fee(wallet):
"N",
"--ticker",
"T",
"--desc",
"d",
"--uri",
"u",
"--creator-fee-bps",
"-1",
],
Expand All @@ -251,7 +252,9 @@ def test_buy_rejects_non_positive_amount(wallet, amount):
def test_launch_rejects_negative_buy(wallet):
with patch("pumpfun_cli.commands.launch.launch_token", new_callable=AsyncMock) as launch:
result = runner.invoke(
app, ["--rpc", "http://rpc", "launch", "--name", "N", "--ticker", "T", "--buy", "-1"]
app,
["--rpc", "http://rpc", "launch", "--name", "N", "--ticker", "T", "--uri", "u"]
+ ["--buy", "-1"],
)
assert result.exit_code != 0
launch.assert_not_called()
Expand All @@ -277,13 +280,16 @@ def test_launch_rejects_blank_name_or_ticker(wallet, name, ticker, message):
launch.assert_not_called()


def test_launch_with_uri_needs_no_desc(wallet):
@pytest.mark.parametrize("uri_args", [[], ["--uri", " "]])
def test_launch_requires_a_metadata_uri(wallet, uri_args):
with patch("pumpfun_cli.commands.launch.launch_token", new_callable=AsyncMock) as launch:
launch.return_value = {"error": "stop", "message": "stop"}
runner.invoke(
app, ["--rpc", "http://rpc", "launch", "--name", "N", "--ticker", "T", "--uri", "u"]
result = runner.invoke(
app,
["--rpc", "http://rpc", "launch", "--name", "N", "--ticker", "T", *uri_args],
)
launch.assert_called_once()
assert result.exit_code == 2
assert "--uri" in re.sub(r"\x1b\[[0-9;]*m", "", result.output)
launch.assert_not_called()


def test_tokens_table_names_quote_and_survives_missing_chain_data():
Expand Down
Loading
Loading