Commit
A commitment is always credited to the transaction sender. A relayer cannot commit for someone else, but sponsored gas works because the user stays the sender.
Every commit returns a Coin<Quote>, either the part a hard cap could not accept or a zero coin. It has no drop, so transfer it back to the sender.
Which function
Section titled “Which function”| Sale | Call |
|---|---|
| Open policy, any phase | commit_open(presale, coin, clock) |
| Allowlist, any phase | commit_allowlisted(presale, coin, index, wallet_cap, proof, clock) |
| Wallet not eligible, during an uncapped phase for anyone | commit_uncapped(presale, coin, clock) |
Under an allowlist the proof is checked even during an uncapped phase; only the cap stops applying.
Open sale
Section titled “Open sale”import { Transaction } from "@mysten/sui/transactions";
const tx = new Transaction();const [payment] = tx.splitCoins(tx.gas, [amount]); // amount in atomic units of SUIconst [unused] = tx.moveCall({ target: `${PKG}::blast_presale::commit_open`, typeArguments: [MEME, SUI], arguments: [tx.object(PRESALE), payment, tx.object.clock()],});tx.transferObjects([unused], sender);Splitting from tx.gas works when the quote is SUI and the user pays gas. Under sponsored gas, or for another quote type, split from a coin the user owns instead.
Allowlisted sale
Section titled “Allowlisted sale”index and wallet_cap are the wallet’s leaf in the allowlist, and proof its sibling digests. See Allowlist proofs.
import { bcs } from "@mysten/sui/bcs";
const [unused] = tx.moveCall({ target: `${PKG}::blast_presale::commit_allowlisted`, typeArguments: [MEME, SUI], arguments: [ tx.object(PRESALE), payment, tx.pure.u64(index), tx.pure.u64(walletCap), tx.pure(bcs.vector(bcs.vector(bcs.u8())).serialize(proof.map((p) => Array.from(p)))), tx.object.clock(), ],});tx.transferObjects([unused], sender);- The window is
start_ms ≤ now < end_ms. Earlier aborts withEPresaleNotStarted, at or after the end withEPresaleEnded. - A wallet’s first commit takes a participant slot. Later commits top it up by any positive amount.
- The minimum applies to the wallet’s total after the commit, so the first commit must reach it. The commit that exactly fills a hard cap may be below it.
- Before the uncapped phase, the wallet’s total must stay within its cap (
EWalletCapExceeded). - Under an allowlist, later commits must present the same cap as the first one.
- Once the sale’s hard cap is in force (
now ≥ start_ms + starts_after_ms), a commit takes only what is left of the raise and returns the rest. When the raise is full, commits abort withEPresaleFilled. Before that point, and in a sale without a hard cap, commitments may pass the raise. - A hard cap does not lift wallet caps; only the uncapped phase does.
- After a sale settles, including an early close, it is no longer
Open, and commits abort withEInvalidLifecycle.
Each accepted commit emits Committed. It has no wallet field, so read the wallet from the transaction sender.