Skip to main content
Use this SDK to add Precommit and Deposit buttons to your website. Connect the user’s Solana wallet, then use the examples below. Only need to show totals and dates? Use the display guide; no SDK required.

Install

Using @starfun/sdk-vault? Every function keeps its name; import from @starfun/sdk/raise instead.

Set up

The examples use a connected wallet with publicKey and signTransaction.
Amounts use quote-token base units: for a six-decimal mint, 25 tokens is new BN('25000000'). Read mint.decimals; keep amounts as decimal strings or BN, never floating-point numbers. Users also need SOL for transaction fees and account rent.

Show the right action

Read the raise status with getVaultStatusKey(vault.account.status) after every refresh, then show the matching action:
  • Precommits are binding. Users can only withdraw them if the raise is cancelled.
  • A countdown reaching zero doesn’t mean the status changed. Refresh and let the program decide.
  • The table says which button to offer. The program still checks each user’s eligibility, so handle rejections.

Precommit

Refresh the vault before showing an action. Precommits lock funds until conversion or cancellation; users cannot withdraw at will.
Conversion into a deposit is a separate transaction after the live raise starts. Star or your integration operator submits it using buildConvertCommitmentTx.

Deposit during the live raise

Also check the start and end times when displaying the deposit button. The program enforces the live window. For SOL raises, automatic wrapping requires the atom amount to fit within Number.MAX_SAFE_INTEGER. Read positions with fetchCommitmentRecord(connection, vaultAddress, wallet.publicKey, programId) and StarVault.fetchDepositorRecord(...) using the same arguments. Their null result can mean a missing account or a read error.

Withdrawals and refunds

An unconverted commitment is withdrawable only after cancellation:
For eligible cancelled or failed deposits, use claimRefund. After accepted launch allocation, use claimExcessRefund for unclaimed excess:
These return quote tokens. Project-token claims after launch use buildClaimTransaction from the same @starfun/sdk/raise import, or the project’s claim link on Star.

Handle errors

Disable repeat submissions while signing/sending. Refresh the position and fundraise totals after confirmation.
Never build a new deposit until you’ve checked the last saved signature. A send can fail with an error and still land, so a blind retry can charge the user twice.
Test the package in your production browser bundle; its CommonJS dependencies may require bundler configuration.