@gala-chain/launchpad-sdk
The SDK signs with @gala-chain/api and ethers; it does not depend on @gala-chain/connect.
The TypeScript SDK for Gala Launchpad (9.0; latest is 9.0.0). It provides read APIs for launchpad data, typed launchpad submissions and gateway-backed token transactions. Version 9.0 is launchpad-only: the DEX is a separate SDK, @gala-chain/gswap-sdk (this package has no DEX client and does not depend on it), and the gateway-generic pieces (signers, wallet helpers and providers, React hooks, the bridge) are @gala-chain/gala-core-sdk's. See MIGRATING-TO-9.0.md for every removed export and where it went.
Install
pnpm add @gala-chain/launchpad-sdk @gala-chain/gala-core-sdk @gala-chain/api axios bignumber.js ethers socket.io-client zod
A plain install gets 9.0.0, and a range on the major (^9) works. Pin the exact versions in an app build.
@gala-chain/gala-core-sdk and the others are peer dependencies: install them next to this package. An app that bridges or wraps tokens installs the bridge's own peers (ethers, @solana/web3.js, @solana/spl-token) and hands the bridge module to the SDK: new LaunchpadSDK({ ..., bridge: () => import('@gala-chain/gala-core-sdk/bridge') }) (loaded at the first bridge or wrap call). This package never loads that module or Solana itself, so an app that does not bridge bundles and installs neither; without the loader the bridge and wrap methods throw a ConfigurationError naming the bridge option.
For the DEX, install @gala-chain/gswap-sdk 2.0 next to this package: pnpm add @gala-chain/gswap-sdk.
launchpad sdk configuration error
Configure
import { createLaunchpadSDK } from '@gala-chain/launchpad-sdk';
const sdk = createLaunchpadSDK({ env: 'stage' });
const pools = await sdk.fetchPools({ pageSize: 10 });
console.log(pools);
Environment is 'prod' | 'stage'. The SDK defaults to prod; it does not infer an environment from a custom baseUrl. Use gatewayBaseUrl for the chain gateway override.
base url gateway
Launchpad writes
Launchpad buys, sells, and sale creation are submitted to the bundler. The result exposes bundleId, uniqueKey, and wait():
const submission = await sdk.launchpad.buyWithNative({
vaultAddress: 'client|example-token',
quantity: '1',
expectedAmount: '1',
});
const result = await submission.wait();
console.log(submission.bundleId, result);
bundle id unique key
Token writes
Token transfers, burns, locks and unlocks go straight to the GalaChain gateway (signed and sent by
@gala-chain/gala-core-sdk's GatewayWrites) and report the chain transaction id and block from the
gateway's x-transaction-id and x-block-number headers. They are made as the SDK's wallet, or, for an
SDK configured with { signer, walletAddress }, as that identity (an eth| account or a client| alias):
const { transactionId, blockNumber } = await sdk.transferToken({
to: 'eth|9876543210987654321098765432109876543210',
tokenId: 'GALA|Unit|none|none', // or tokenName: 'anime' for a launchpad token
amount: '1', // whole tokens, sent as written
});
const locked = await sdk.lockTokens({ tokens: [{ tokenName: 'anime', amount: '100' }] });
console.log(locked.transactionId, locked.blockNumber);
To send to a client| recipient, or to write without a launchpad SDK, use GatewayWrites from
@gala-chain/gala-core-sdk directly.
Never place a private key in source control. For a write-capable SDK, provide a signer through the supported wallet configuration.
gateway writes wallet address
GSwap DEX
DEX calls use @gala-chain/gswap-sdk's GSwap client. An app that trades on both builds both
clients from the same key (sdk.dex is gone, and so are fetchAllDexSeasons,
fetchCurrentDexSeason, fetchDexLeaderboardBySeasonId, fetchCurrentDexLeaderboard,
fetchDexAggregatedVolumeSummary and onDexPoolCreation: they are gSwap.leaderboard.*,
gSwap.market.getVolumeSummary() and gSwap.pools.watchNewPools()):
import BigNumber from 'bignumber.js';
import { PrivateKeySigner } from '@gala-chain/gala-core-sdk';
import { GSwap } from '@gala-chain/gswap-sdk';
const gSwap = new GSwap({
env: 'stage',
signer: new PrivateKeySigner(process.env.PRIVATE_KEY!),
walletAddress: sdk.getAddress(), // the launchpad SDK built with the same key
});
const quote = await gSwap.quoting.quoteExactInput(
'GALA|Unit|none|none',
'GUSDC|Unit|none|none',
'100',
);
const swap = await gSwap.swaps.swap(
'GALA|Unit|none|none',
'GUSDC|Unit|none|none',
quote.feeTier,
// The least you accept: a swap is applied seconds after the quote, so a bound equal to the quote
// is rejected whenever the price moves in between.
{ exactIn: '100', amountOutMinimum: new BigNumber(quote.amountOut).multipliedBy('0.99').toFixed() },
);
// The swap is queued (swap.mode === 'queued'); confirm() resolves the applied trade
// or throws the chain's rejection.
const applied = await swap.confirm();
console.log(applied.transactionId, applied.result);
Use gSwap.pools, gSwap.positions, gSwap.symbols, gSwap.assets, gSwap.market and gSwap.leaderboard for pool discovery, liquidity, token identifiers, user assets, prices and volume, and the trading competition. DEX reads are unsigned; state-changing DEX calls require the client's signer. Runnable DEX demos and guides live in packages/gswap-sdk/examples/demos.
fetch all dex seasons current season leaderboard by id aggregated volume summary on pool creation get watch new pools
Prices
sdk.fetchTokenPrice({ tokenName }) prices a launchpad token (the bonding curve, or the swap backend once graduated). It takes tokenName only: fetchGalaPrice, fetchTokenPrice({ tokenId }), fetchPriceHistory and fetchAllPriceHistory are gone. Prices and price series for any token by class key are gswap-sdk's gSwap.market.getPrice(tokenId) and gSwap.market.getPriceSeries(key, timeframe); sdk.resolveTokenClassKey(name) gives a launchpad token's key. The MCP tools of the same names still work.
fetch token price name gala id history all get series resolve class key
Hosts
env: 'stage' selects the Gala staging backends for launchpad reads and DEX reads, and gateway-testnet.galachain.com for gateway operations. Production host values are selected by env: 'prod'; baseUrl overrides the launchpad host.
base url
Further reading
- Migrating to 9.0
- Changelog:
CHANGELOG.mdin the package root - API reference
- Examples
- gswap-sdk: the DEX SDK, with its own runnable demos