---
name: bsc-minimal-launch
description: Minimal-capital BEP-20 launch on BSC via PancakeSwap V3.
---

# Minimal-capital BSC token launch (PancakeSwap V3)

Use when planning or executing a minimal-capital BEP-20 launch on BSC/PancakeSwap with price control. Reference implementation: ~/goldcoin-launch (GalaktikusAI/GKAI — contract contracts/GalaktikusAI.sol, sim in scripts/sim_mini.py, plan in pump_plan.md; TGIGold was the earlier gold-themed iteration, contracts/TGIGold.sol.bak).

## Contract baseline (GalaktikusAI.sol pattern)
- Self-contained BEP-20 (no imports): 18 decimals, fixed supply minted to deployer at construction, Ownable, pausable, bonus-tier helper, plus burn mechanics: `burn()`/`burnFrom()` (reduce totalSupply — keep totalSupply mutable, NOT immutable) and a `transferTaxBps` switch (default 0 = OFF; setter onlyOwner, cap 500 bps; fee burned 100%). Enable the tax only AFTER the pump phase or the pump volume pays it.

## Core math
- V2 pump x N costs pool_BNB*(sqrt(N)-1); average fill price = sqrt(start*target). Path-independent: staged vs single buys cost identical (fees are % of volume; only gas differs per tx).
- V3 concentrated position [pa, pb] at start price p0 near the bottom of range: LP posts ~only tokens (free from owner supply) + tiny BNB side y = L*(sqrt(p0)-sqrt(pa)). Same pump cost as V2, ~90% less BNB locked in LP. Price below pa becomes impossible (position holds no BNB) = built-in dump floor.
- Cheaper start (e.g. 0.05->1.00 instead of 0.10->2.00, same x-multiple) halves capital for the same token count — fallback if funding is short.
- BNB-donation+sync() or asymmetric re-mint pump cost ~linear in price (4.5x worse than buying); router buys are cheapest AND safest.

## Pitfalls
- LETHAL (cost: 0.0723 BNB lost 17.11.2026): NEVER write router/WBNB addresses from memory — a plausible-looking hallucinated router (0x10ED43C7EA53… instead of the REAL 0x10ED43C718714eb63d5aA57B78B54704E256024E) has NO code; a value-tx to it succeeds (status 1, ~25k gas, ZERO logs) and the BNB is unrecoverable. Before ANY send: `w3.eth.get_code(router)` must be non-empty AND cross-check the address against the Verified-addresses list below. If a swap tx shows status 1 with 0 logs and low gas, the value went to a codeless address — check get_code first.
- Raw `eth_call` hex parsing of multi-word returns (getReserves 0x0902f1ac): after stripping `0x`, word N is `r[64*N:64*N+64]` — an off-by-one-BYTE offset (`r[2:66]` for word 0) silently inflates every value by exactly 256x while keeping the reserve RATIO (and thus the price) correct, so the reading looks plausible and wrecks only the pump sizing (a $469 pool read as $60k makes the target look unreachable). Prefer decoding via web3 contract calls with a typed ABI over hand-slicing; if hand-slicing, cross-check ONE word against `token.balanceOf(pair)` before trusting the numbers.
- Measure deployment gas with a dry-run/`eth_estimateGas` BEFORE broadcasting and set the gas limit ≥ measured+30% — a hardcoded limit below actual cost reverts on-chain and the fee is still burned (full-featured BEP-20 with burn/tax logic deploys at ~1.0–1.3M gas, not the ~105k of a bare ERC-20; a fresh-pair V2 `addLiquidityETH` runs ~3.5M gas, so a 1M limit reverts while the calldata is perfectly valid).
- Hand-encoded router calldata MUST encode dynamic arrays properly: `address[]` = offset word (0x40) + array length word (2) + elements. Omitting the length word reverts with a bare `execution reverted: 0x` and no revert reason — diagnose ENCODING first when eth_call/estimate_gas fails on a known-good router call, and isolate with `getAmountsOut` (same selector style, simpler return).
- web3.py raw transactions need explicit `gas` AND `gasPrice` — always set both for hand-built txs. Run BSC scripts with `~/goldcoin-launch/.venv/bin/python` (web3 8.x preinstalled there; the session interpreter and `/usr/bin/python3` lack it) and inject `ExtraDataToPOAMiddleware` (layer 0) or BSC eth_call/get_block reverts on extra-data with a giant-hex error. `w3.from_wei(...)` returns `Decimal` — cast `float()` before ANY arithmetic with floats (TypeError otherwise). Fetch BNB/USD with a retry loop plus a hardcoded fallback (e.g. ~680 $) — CoinGecko `simple/price` 429s from the VPS; print which value was used so the report is honest about drift.
- Price-to-target math (V2 constant product k = token_reserve × BNB_reserve): required BNB reserve for price P is `sqrt(k × P / BNB_USD)` — buy the difference from the current reserve. Fetch BNB_USD LIVE at script start (DEXScreener WBNB token page via curl with a `-A Mozilla/5.0` User-Agent — plain urllib gets 403) and NEVER hardcode it: older pump scripts hardcoded the BNB price and any drift since skews the reached target by the same percentage. Tiny pools mean tens of dollars move the displayed price 3–10x; the spent BNB stays in YOUR liquidity, so it is repositioning, not spend. Keep ALL reserve math in raw wei integers end-to-end (`math.sqrt(g*b*P/BNB_USD) - b` with wei reserves, cast the result `int()`): converting to ether mid-formula or passing a float as tx `value` raises "Transaction had invalid fields" only at signing time. Stage the push as 4–6 buys (e.g. 40/25/18/10 % of need) plus micro-buys fine-tuning to ±2 % — one huge buy is visible and fragile. When the owner wants buys from SEPARATE wallets ("farklı farklı cüzdanlardan", organic look), the pump script must FIRST distribute BNB from the funded wallet to the buy wallets (plain-value txs, 21k gas) and then fire one staged buy per wallet — a buy wallet with zero BNB aborts mid-run (working template: `~/goldcoin-launch/push_to_15_multiwallet.py`, dry-run without `--send`). After the staged buys, land the exact target with one final micro-buy computed as `bnb_needed(target)` from the CURRENT reserves.
- DEXScreener and GeckoTerminal index a new PancakeSwap pair automatically within minutes (price/chart/txns, no submission needed) — only token-info/logo updates require requests. GoPlus `creator_balance` is CACHED from mint time (before distribute-transfers) and can show "Creator holds 100%" / a DEXScreener "Security issue" flag on a healthy token — verify balances on-chain before acting on scanner flags.
- Quick price verification without a wallet: `curl -s "https://api.dexscreener.com/latest/dex/tokens/<CA>"` and GeckoTerminal `api/v2/networks/bsc/tokens/<CA>` are open (no key, VPS-friendly) — use them to confirm on-chain price. Wallet USD displays (MetaMask/Trust) stay frozen or blank for UNLISTED tokens because they read CoinGecko/CMC feeds, not DEX pools — a live DEXScreener price with a stale wallet display is expected until the CoinGecko/CMC listing lands, so queue that listing when the owner asks why "the price doesn't change in MetaMask".
- Finding a wallet's token TX by event logs: `bsc-dataseed.*` RPCs rate-limit `eth_getLogs` hard (`-32005 limit exceeded`, even for 200-block windows). Use `https://bsc.publicnode.com` with hex block numbers — but its responses return topics/data as BYTES, so parse with `int.from_bytes(log["data"], "big")` and `topics[2].hex()` instead of `int(x, 16)`.
- V3 ticks run over the RAW price (token1/token0, e.g. BNB per token), NOT the EUR/USD price — convert first (p_eur / BNB_EUR). A EUR-price tick range is off by ln(price ratio).
- token0 is the lower address; if token0=WBNB the price inverts (TGIG per BNB): EUR-low = tick-high, swap tick_lo/tick_hi sources.
- PCS V3 fee tier 500 = 0.05% (display: FEE_TIER/1_000_000), tickSpacing 10. Use SwapRouter exactInputSingle (not aggregators) so buys hit OUR pool.
- BSC gas: live often 0.05 gwei; 0.1 gwei floor is safe, saves ~90% vs 1-gwei planning.

## Verified BSC mainnet addresses (2026-11)
- PCS V3 Factory 0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865, NPM 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364, V3 SwapRouter 0x1b81D678ffb9C0263b24A97847620C99d213eB14, WBNB 0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c. (V2: factory 0xcA143Ce32Fe78f1f7019d7d551a6402fC5350c73, router 0x10ED43C718714eb63d5aA57B78B54704E256024E.)

## Funding USDT(TRC20)->BNB(BSC) without KYC
- Best no-KYC instant exchanger by tracked quote quality: Exolix (~0.5-1% all-in); ChangeNOW/StealthEX ~0.5-0.9%; FixedFloat 0.5% floating. CEX with existing KYC: ~0.1% + ~$0.02 withdrawal.
- Tron side: rent energy (~1.1-2.6 TRX per 65k-131k energy via Netts/TEnergy/TronBid) instead of burning 6.5/13.1 TRX — ~80% cheaper per USDT transfer. One bulk transfer needed only.
- Exchanger APIs are often Cloudflare-blocked from the VPS (Exolix /api/v2/transaction returns 403 to curl) — drive the web UI with the browser instead; see references/exchanger-ui-automation.md for the working DOM recipe.
- SideShift is the exception: its FULL API works from the VPS via curl (no Cloudflare block) — use it as the fallback when ChangeNOW's vip-api errors (it has full-outage days returning 502 for every amount/pair) or other UIs are bot-walled. Recipe: references/sideshift-api.md. For the price-push itself keep a reusable staged-buy script template (`~/goldcoin-launch/push_to_13_5usd.py`: fetches live BNB/USD, dry-run without `--send`, splits the need into 4 buys, micro-fine-tunes to ±2 %, prints price after every buy) fed by `~/goldcoin-launch/price_math.py <target_usd>` for the pre-check.
- When re-pumping a token whose buyback program is LIVE: the pump wallet and the buyback payout wallet are often the same key — size the funding swap so the POST-pump balance still covers ≥110% of the max buyer payout (pump need + payout reserve + gas), or buyer payouts break mid-program. Check the wallet's current BNB BEFORE quoting the shift.
- **Vor jedem Kurs-Push: (a) WELCHEN Pool zeigt der Owner?** Mehrere Pairs desselben Tokens haben sehr verschiedene Preise — GeckoTerminal/DEXScreener zeigen den liquidesten, also Live-API fragen (`api/v2/networks/bsc/tokens/<CA>/pools`) und genau DIESEN Pool hochkaufen, sonst steigt der angezeigte Kurs nicht. (b) **V2- vs V3-Mathematik nicht raten**: `factory()` am Pool per eth_call pruefen (PCS-V2 0xcA143Ce32... vs V3 0x0BFbCF9fa...) — die V2-Formel pool_BNB*(sqrt(N)-1) gilt NUR fuer echte V2-Pools. (c) **Exchanger-Minimum gegen Wallet-Saldo rechnen, bevor dem Owner ein Ziel genannt wird**: TRC20->BSC-Swaps haben Paar-Minima (z. B. ~26 USDT) — ein Live-Quote mit absichtlich kleinem Betrag liefert `QUOTE_UNAVAILABLE` + `depositRangeMin` und verhindert, dass eine zugesagte Kurssteigerung mangels tauschbarem Geld platzt. Verfuegbares Guthaben live ueber ALLE Wallets scannen ( `.key`-Files via tronpy `PrivateKey(...).public_key.to_base58check_address()`, System-Python) und AML-geflaggte/gesperrte Wallets abziehen.

## Token logo & wallet visibility
- Wallets do NOT read the logo from the chain: they render icons from token lists (BscScan token-info update, Trust Wallet assets repo, Bitbond/Solidified lists). After deploy: host the logo PNG (256/512 px) at a stable public HTTPS URL, keep a token-info.json (name/symbol/decimals/logo/website), then submit to BscScan + token lists — only then does the icon appear "everywhere".
- Design logos to survive 32 px: one bold shape + high contrast; verify by rendering 32 px, not by viewing the 512 px master.
- Explorer/aggregator submissions (BscScan token info, DEXScreener update, CoinGecko/CMC listing) all require an EXISTING trading pair — queue them right after LP creation, not right after deploy. Trust Wallet icons come from a PR to the trustwallet/assets repo (contract + 256px logo). Full post-launch trust package (source verification, LP lock, audit provider ranking, CoinGecko/CMC/DEXScreener submission requirements, circulating-supply decision): references/token-trust-listings.md.

## Serving the project website from the agent VPS (Caddy)
- Caddy runs as user `caddy` and cannot traverse `/home/marcel7364` (mode 0700) — a root pointing there serves 403. Copy the site to `/var/www/<name>` and root there; deploy via `sudo tee -a /etc/caddy/Caddyfile` + `systemctl reload caddy`. Instant HTTPS hostnames: `<label>.<ip>.sslip.io` resolves automatically; new blocks fetch Let's Encrypt certs on first request (first curl may 000 — wait a few seconds, then re-check).
- After the initial copy, `sudo -n chown -R <agentuser>:caddy /var/www/<name> && sudo -n chmod -R g+rwX /var/www/<name>` once — a tree owned `caddy:caddy` makes every later agent-side `write_file` fail with permission denied, while caddy keeps read access via the group. Do this before the first edit, not after the first refusal.
- Single-language buyer/marketing pages (e.g. Turkish for the owner's Turkish-first audience): build them self-contained (inline CSS, no i18n dict entries, copy brand assets by relative path) instead of adding dictionary keys for all site languages — then link them statically in nav AND footer of every existing page with a fixed label + flag emoji. Static links work in any active language; dict-based nav links would require all-language translations.
- Mobile check is mandatory on every public page (owner rule): emulate `cdp('Emulation.setDeviceMetricsOverride', width=390, height=844, deviceScaleFactor=3, mobile=True)`, then fail on `document.body.scrollWidth > window.innerWidth` (horizontal overflow); also confirm images report `naturalWidth` > 0 and section/card counts match the source. Verify the language switcher (or GeoIP default) actually renders the target language before reporting done.
- PHP apps (no php-fpm needed): run `/usr/bin/php -S 127.0.0.1:<port>` as a systemd unit (User=agent, WorkingDirectory=/var/www/<name>, Restart=always — copy the existing tgigold-spiel.service pattern) and `reverse_proxy 127.0.0.1:<port>` in the Caddyfile. Instant sslip.io preview hostnames get a buyer-facing page online minutes after build while the real domain is still unregistered. Seed test data through the app's own web admin (curl with cookie jar + the CSRF token scraped from the form) rather than CLI PHP — CLI runs of the same app can die with exit 255 and no output even with display_errors on.

## Buyer buyback program (110% payout loop)

Use when the owner wants buyers who purchase via the PancakeSwap link to sell the tokens BACK for a guaranteed premium (e.g. buy $20, get 110% in BNB). Reference implementation: GKAI buyback (`~/gkai-buyback-bot/`, `/var/www/gkai/satin-al-rehberi.html`).

1. **Dedicated buyback wallet** (own key in ~/.secrets, e.g. `buyback.key`), separate from the LP/empfang wallet — it holds only gas + payout BNB, not LP tokens. Fund it via the SideShift recipe (references/sideshift-api.md); budget ≥ 110% of the max buyer amount in BNB.
2. **Buy link**: `https://pancakeswap.finance/swap?outputCurrency=<token>&inputCurrency=BNB` — give buyers THIS, never a raw pair address.
3. **Turkish step-by-step guide page** (satin-al-rehberi.html pattern): numbered to wallet setup, purchase, sending tokens to the buyback address, copy-paste TX hash; one self-contained HTML page per the site rules above.
4. **Bot handles the return flow** (see telegram-mini-apps "Bot-only flows"): verifies the TX hash on-chain, registers the payout, alerts the owner chat. A wallet-balance cron watcher (script in ~/.hermes/scripts/, relative path) double-checks incoming tokens.
4a. **One-click web sell-back page** (geri-sat.html pattern) beats manual "send to address" instructions: connect button → `wallet_watchAsset` (make the token visible; custom tokens are invisible in MetaMask until imported) → prefilled ERC20 `transfer` of the user's FULL balance via `eth_sendTransaction` (data = `0xa9059cbb` + padded recipient + padded amount read from `balanceOf` through `eth_call`). On page load try SILENT auto-connect via `eth_accounts` (no popup if previously authorized); when `window.ethereum` is absent (normal mobile browser) render wallet deep-links instead of an error: MetaMask `https://metamask.app.link/dapp/<host>/<path>`, Trust `https://link.trustwallet.com/open_url?coin_id=20000714&url=<urlencoded>`. Listen to `accountsChanged`/`chainChanged` to refresh state.
5. **Owner rules that always apply**: min/max per buyer (e.g. $20–$100) stated on every page; ONLY real humans in the program — no bots/fake accounts; payout notified to owner instead of fully automatic; a referral/level system (more friends → higher %) is added later, friends must be real.

## Always
- Dry-run only by default (--send to broadcast); keys only from ~/.secrets; grep artifacts for key strings before finishing.
- Payment/send scripts MUST take recipient+amount from argv and hard-fail without them — a script with hardcoded TO_ADDR/AMOUNT silently sends to the OLD recipient when called with args (cost: 25 USDT double-paid to a domain vendor). Assert argv length before signing.
- When the owner renames the token/project mid-preparation: sed-rename the contract file, contract name, compile.py SRC/OUT/key, and deploy.py TOKEN_NAME/TOKEN_SYMBOL/ARTIFACT_PATH in one pass, then recompile AND re-run the deploy dry-run — stale build artifacts under the old name silently keep getting signed.