集成API

CHAINFetch Deposit State

Last updated January 31, 2026

使用 Genesis JavaScript SDK 直接从区块链获取用户存款状态。检查存款金额、领取状态以及用户是否已存款。

链上获取需要 UmiGenesis SDK

方法

方法发行类型行为
fetchLaunchPoolDepositV2Launch Pool未找到时抛出异常
safeFetchLaunchPoolDepositV2Launch Pool返回 null
fetchPresaleDepositV2Presale未找到时抛出异常
safeFetchPresaleDepositV2Presale返回 null

Launch Pool 存款

import {
fetchLaunchPoolDepositV2,
safeFetchLaunchPoolDepositV2,
} from '@metaplex-foundation/genesis';
// Throws if not found — use when you expect the deposit to exist
const deposit = await fetchLaunchPoolDepositV2(umi, depositPda);
console.log('Amount:', deposit.amountQuoteToken);
console.log('Claimed:', deposit.claimed);
// Returns null if not found — use for optional lookups
const maybeDeposit = await safeFetchLaunchPoolDepositV2(umi, depositPda);
if (maybeDeposit) {
console.log('Amount:', maybeDeposit.amountQuoteToken);
}

Presale 存款

import {
fetchPresaleDepositV2,
safeFetchPresaleDepositV2,
} from '@metaplex-foundation/genesis';
// Throws if not found — use when you expect the deposit to exist
const deposit = await fetchPresaleDepositV2(umi, depositPda);
console.log('Amount deposited:', deposit.amountQuoteToken);
console.log('Amount claimed:', deposit.amountClaimed);
console.log('Fully claimed:', deposit.claimed);
// Returns null if not found — use for optional lookups
const maybeDeposit = await safeFetchPresaleDepositV2(umi, depositPda);
if (maybeDeposit) {
console.log('Amount deposited:', maybeDeposit.amountQuoteToken);
}

检查用户是否已存款

使用 safeFetch 变体来检查用户是否已存款,而不会抛出错误:

import {
safeFetchLaunchPoolDepositV2,
safeFetchPresaleDepositV2,
findLaunchPoolDepositV2Pda,
findPresaleDepositV2Pda,
} from '@metaplex-foundation/genesis';
// Launch Pool
const [lpDepositPda] = findLaunchPoolDepositV2Pda(umi, {
bucket: launchPoolBucket,
recipient: userPublicKey,
});
const lpDeposit = await safeFetchLaunchPoolDepositV2(umi, lpDepositPda);
const hasLpDeposit = lpDeposit !== null;
// Presale
const [psDepositPda] = findPresaleDepositV2Pda(umi, {
bucket: presaleBucket,
recipient: userPublicKey,
});
const psDeposit = await safeFetchPresaleDepositV2(umi, psDepositPda);
const hasPsDeposit = psDeposit !== null;