-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathlaunch.py
More file actions
73 lines (63 loc) · 2.49 KB
/
launch.py
File metadata and controls
73 lines (63 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
"""Token launch command."""
import asyncio
import typer
from pumpfun_cli.core.launch import launch_token
from pumpfun_cli.output import error, render
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"),
image: str | None = typer.Option(None, "--image", help="Path to token image"),
buy: float | None = typer.Option(None, "--buy", help="Initial buy amount in SOL"),
mayhem: bool = typer.Option(False, "--mayhem", help="Enable mayhem mode"),
):
"""Launch a new token on pump.fun (create_v2 + extend_account)."""
state = ctx.obj
if not name or not name.strip():
error("Token name cannot be empty.")
if not ticker or not ticker.strip():
error("Token ticker cannot be empty.")
if not desc or not desc.strip():
error("Token description cannot be empty.")
if not state or not state.rpc:
error("RPC endpoint not configured.", hint="Run: pumpfun config set rpc <url>")
from pathlib import Path
from pumpfun_cli.commands.wallet import _get_keystore_path, _get_password
keyfile = _get_keystore_path(ctx)
if not Path(keyfile).exists():
error("No wallet found.", hint="Run: pumpfun wallet create")
password = _get_password(ctx)
overrides = {}
if state.priority_fee is not None:
overrides["priority_fee"] = state.priority_fee
if state.compute_units is not None:
overrides["compute_units"] = state.compute_units
try:
result = asyncio.run(
launch_token(
state.rpc,
keyfile,
password,
name,
ticker,
desc,
image,
buy,
mayhem,
**overrides,
)
)
except (ValueError, RuntimeError) as exc:
error(str(exc))
if result.get("error"):
error(result["message"])
if not render(result, state.json_mode):
typer.echo("Token launched!")
typer.echo(f" Name: {result['name']}")
typer.echo(f" Ticker: {result['ticker']}")
typer.echo(f" Mint: {result['mint']}")
typer.echo(f" TX: {result['explorer']}")
typer.echo(f" Pump.fun: {result['pump_url']}")
if result.get("initial_buy_sol"):
typer.echo(f" Buy: {result['initial_buy_sol']} SOL")