爆发 BaofaBaofa Documentation
中文 Open the App

Integration Guide

Calling Baofa from your own code, from a quote to a buy, a sell, a launch and a graduation, with the units, bounds and events you need.

Updated 2026-11-04Contracts baofa-rewrite-2026-11-04-a727bfe

Everything the app does goes through public functions of the core contract; there is no private API and no signature from Baofa's servers. This page covers the calls an integrator uses most. Full interfaces are on the reference pages.

Units#

Quantity Unit on chain
Coins base units, 6 decimals (1 coin = 1,000,000)
BNB in curve calls quote units of 1e9 wei (1 BNB = 1,000,000,000)
msg.value on payable calls wei; equal to the quote amount × 1e9
Fees and shares basis points (1 percent = 100)
Deadlines unix seconds

Reading a Curve#

curve(coin) returns the curve record: virtual and real reserves, the quote asset, completion state and the creator; curveBalances(coin) returns its custody balances and isCoin(address) tells you whether an address was created by the core. There is no quote function on chain; compute quotes with the formulas on the Bonding Curve page or read them from the indexer, which does the same arithmetic.

Buying#

solidity
core.buyExactIn{value: spendableQuoteIn * 1e9}(
    coin,
    spendableQuoteIn,   // BNB to spend including fees, in quote units
    minTokensOut,       // slippage floor in coin base units
    partialFill,        // true: trim to the remaining supply and refund the rest
    buybackIndex,       // 0 unless you route a buyback recipient
    deadline
);

The call returns (baseOut, quoteSpent), reverts with BuySlippageBelowMinTokensOut if the floor is not met or Expired after the deadline, and refunds any unspent BNB. On the completing buy it emits Complete after Trade.

Selling#

solidity
coin.approve(address(core), amount);
core.sell(coin, amount, minQuoteOut, buybackIndex, deadline);

permit is supported on every coin, so an integrator can batch the approval into the same transaction with the holder's signature. Proceeds are paid in BNB; the call reverts with TooLittleQuoteReceived below the floor.

Launching#

solidity
address predicted = core.predictCoin(creator, salt);
core.create(CreateParams({
    name: "...",          // at most 32 bytes
    symbol: "...",        // at most 13 bytes
    uri: "https://...",   // at most 200 bytes, the metadata document
    creator: creator,
    quoteAsset: address(0),
    frenzy: false,
    creatorFeeBps: 0,
    holderReward: false,
    salt: salt
}));

createAndBuy(p, amount, maxQuoteIn, buybackIndex) performs the same creation followed by a first buy of amount coins for at most maxQuoteIn in one transaction; its msg.value is maxQuoteIn × 1e9 and the difference is refunded. The Create event carries the coin address, the creator and the curve's starting reserves. A non-zero creatorFeeBps is accepted only on token-quoted coins and no token quote is registered at launch; frenzy: true is accepted only while the Frenzy flag is on.

Graduating#

solidity
core.migrate(coin);

Permissionless once the curve is complete. Not payable for BNB-quoted coins. Returns the pair address and emits GraduatedToPancakeV2(coin, pair, quoteToken, coinAmount, quoteAmount, liquidity) and CompleteMigration.

Creator Fees#

Action Call
Move a coin's accrual to the creator's balance sweepCreatorFee(coin)
Read a claimable balance creatorFeeBalance(creator, address(0))
Claim collectCreatorFee(address(0)) from the creator's address

Events to Index#

Event Emitted on
Create every launch
Trade every curve buy and sell
Complete the buy that drains the real coin reserve
GraduatedToPancakeV2, CompleteMigration graduation
CollectCreatorFee creator claims
PancakeSwap Swap and Sync on the pair trades after graduation

Topics are listed on the Core Reference page.

Errors#

The contracts revert with named errors only, each listed with its selector on the reference pages. The most common on the trade path are BuySlippageBelowMinTokensOut, TooLittleQuoteReceived, TooMuchQuoteRequired and Expired; BondingCurveComplete on a buy after completion; BondingCurveNotComplete on an early migrate; and TransferToPairBeforeGraduation from the coin itself.

Safety Notes for Integrators#

  • Always set a deadline and a slippage floor; the curve price moves with every trade.
  • Never send BNB to a diamond address directly: it is outside every ledger and only the owner can return it.
  • Read core() on a coin before trusting it as a Baofa coin, and compare the core address with the Addresses page.
  • The coin's transfer to its pair reverts before graduation by design; do not route pre-graduation coins through PancakeSwap.

Baofa Documentation. Built from the launch contracts package baofa-rewrite-2026-11-04-a727bfe · 2026-11-04

baofa.fun · X @baofadotfun