SDK

JavaScript SDK

Last updated March 10, 2026

Genesis JavaScript SDKのAPIリファレンスです。完全なチュートリアルについては、Launch PoolまたはPresaleを参照してください。

NPMパッケージ

@metaplex-foundation/genesis

TypeDoc

自動生成されたAPIドキュメント

インストール

npm install @metaplex-foundation/genesis @metaplex-foundation/umi \
@metaplex-foundation/umi-bundle-defaults @metaplex-foundation/mpl-toolbox \
@metaplex-foundation/mpl-token-metadata

セットアップ

import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { genesis } from '@metaplex-foundation/genesis';
import { mplTokenMetadata } from '@metaplex-foundation/mpl-token-metadata';
const umi = createUmi('https://api.mainnet-beta.solana.com')
.use(genesis())
.use(mplTokenMetadata());

完全な実装例については、Launch PoolまたはPresaleを参照してください。


インストラクションリファレンス

コア

関数説明
initializeV2()Genesis Accountの作成とトークンの発行
finalizeV2()設定のロックとローンチの有効化

バケット

関数説明
addLaunchPoolBucketV2()比例配分バケットの追加
addPresaleBucketV2()固定価格販売バケットの追加
addUnlockedBucketV2()トレジャリー/受取人バケットの追加

Launch Pool操作

関数説明
depositLaunchPoolV2()Launch PoolにSOLを入金
withdrawLaunchPoolV2()SOLの出金(入金期間中)
claimLaunchPoolV2()トークンの請求(入金期間終了後)

Presale操作

関数説明
depositPresaleV2()PresaleにSOLを入金
claimPresaleV2()トークンの請求(入金期間終了後)

管理者

関数説明
triggerBehaviorsV2()終了動作の実行
revokeV2()ミントおよびフリーズ権限の永久取り消し

関数シグネチャ

initializeV2

await initializeV2(umi, {
baseMint, // Signer - new token keypair
quoteMint, // PublicKey - deposit token (wSOL)
fundingMode, // number - use 0
totalSupplyBaseToken, // bigint - supply with decimals
name, // string - token name
symbol, // string - token symbol
uri, // string - metadata URI
}).sendAndConfirm(umi);

finalizeV2

await finalizeV2(umi, {
baseMint, // PublicKey
genesisAccount, // PublicKey
}).sendAndConfirm(umi);

addLaunchPoolBucketV2

await addLaunchPoolBucketV2(umi, {
genesisAccount, // PublicKey
baseMint, // PublicKey
baseTokenAllocation, // bigint - tokens for this bucket
depositStartCondition, // TimeCondition
depositEndCondition, // TimeCondition
claimStartCondition, // TimeCondition
claimEndCondition, // TimeCondition
minimumDepositAmount, // bigint | null
endBehaviors, // EndBehavior[]
}).sendAndConfirm(umi);

addPresaleBucketV2

await addPresaleBucketV2(umi, {
genesisAccount, // PublicKey
baseMint, // PublicKey
baseTokenAllocation, // bigint
allocationQuoteTokenCap, // bigint - SOL cap (sets price)
depositStartCondition, // TimeCondition
depositEndCondition, // TimeCondition
claimStartCondition, // TimeCondition
claimEndCondition, // TimeCondition
minimumDepositAmount, // bigint | null
depositLimit, // bigint | null - max per user
endBehaviors, // EndBehavior[]
}).sendAndConfirm(umi);

addUnlockedBucketV2

await addUnlockedBucketV2(umi, {
genesisAccount, // PublicKey
baseMint, // PublicKey
baseTokenAllocation, // bigint - usually 0n
recipient, // PublicKey - who can claim
claimStartCondition, // TimeCondition
claimEndCondition, // TimeCondition
}).sendAndConfirm(umi);

depositLaunchPoolV2

await depositLaunchPoolV2(umi, {
genesisAccount, // PublicKey
bucket, // PublicKey
baseMint, // PublicKey
amountQuoteToken, // bigint - lamports
}).sendAndConfirm(umi);

depositPresaleV2

await depositPresaleV2(umi, {
genesisAccount, // PublicKey
bucket, // PublicKey
baseMint, // PublicKey
amountQuoteToken, // bigint - lamports
}).sendAndConfirm(umi);

withdrawLaunchPoolV2

await withdrawLaunchPoolV2(umi, {
genesisAccount, // PublicKey
bucket, // PublicKey
baseMint, // PublicKey
amountQuoteToken, // bigint - lamports
}).sendAndConfirm(umi);

claimLaunchPoolV2

await claimLaunchPoolV2(umi, {
genesisAccount, // PublicKey
bucket, // PublicKey
baseMint, // PublicKey
recipient, // PublicKey
}).sendAndConfirm(umi);

claimPresaleV2

await claimPresaleV2(umi, {
genesisAccount, // PublicKey
bucket, // PublicKey
baseMint, // PublicKey
recipient, // PublicKey
}).sendAndConfirm(umi);

triggerBehaviorsV2

プライマリーbucketに設定された End Behavior を処理し、収集した資金を endBehaviors で指定されたデスティネーションbucketに移動します。

await triggerBehaviorsV2(umi, {
genesisAccount, // PublicKey
primaryBucket, // PublicKey
baseMint, // PublicKey
})
.addRemainingAccounts([/* destination bucket + its quote token account */])
.sendAndConfirm(umi);

revokeV2

ベーストークンのミントおよびフリーズ権限を恒久的に取り消します。

await revokeV2(umi, {
genesisAccount, // PublicKey
baseMint, // PublicKey
revokeMintAuthority, // boolean
revokeFreezeAuthority, // boolean
}).sendAndConfirm(umi);

PDAヘルパー

関数シード
findGenesisAccountV2Pda()baseMint, genesisIndex
findLaunchPoolBucketV2Pda()genesisAccount, bucketIndex
findPresaleBucketV2Pda()genesisAccount, bucketIndex
findUnlockedBucketV2Pda()genesisAccount, bucketIndex
findLaunchPoolDepositV2Pda()bucket, recipient
findPresaleDepositV2Pda()bucket, recipient
const [genesisAccountPda] = findGenesisAccountV2Pda(umi, { baseMint: mint.publicKey, genesisIndex: 0 });
const [bucketPda] = findLaunchPoolBucketV2Pda(umi, { genesisAccount: genesisAccountPda, bucketIndex: 0 });
const [depositPda] = findLaunchPoolDepositV2Pda(umi, { bucket: bucketPda, recipient: wallet });

フェッチ関数

Genesisアカウント

Genesisアカウントはローンチタイプを含むトップレベルのローンチ状態を保存します。バックエンドクランクがsetLaunchTypeV2インストラクションを介して作成後にオンチェーンでlaunchTypeフィールドを設定するため、クランクが処理するまで値はUninitialized(0)のままの場合があります。

関数戻り値
fetchGenesisAccountV2()Genesisアカウントの状態(存在しない場合はエラーをスロー)
safeFetchGenesisAccountV2()Genesisアカウントの状態またはnull
fetchGenesisAccountV2FromSeeds()PDAシード(baseMintgenesisIndex)で取得
safeFetchGenesisAccountV2FromSeeds()上記と同じ、存在しない場合はnullを返す
fetchAllGenesisAccountV2()複数のGenesisアカウントを一括取得
import {
fetchGenesisAccountV2,
fetchGenesisAccountV2FromSeeds,
findGenesisAccountV2Pda,
LaunchType,
} from '@metaplex-foundation/genesis';
// PDAアドレスで取得
const [genesisAccountPda] = findGenesisAccountV2Pda(umi, {
baseMint: mintAddress,
genesisIndex: 0,
});
const account = await fetchGenesisAccountV2(umi, genesisAccountPda);
console.log(account.data.launchType); // 0 = Uninitialized, 1 = Project, 2 = Meme
// シードから直接取得
const account2 = await fetchGenesisAccountV2FromSeeds(umi, {
baseMint: mintAddress,
genesisIndex: 0,
});
// ローンチタイプの確認
if (account2.data.launchType === LaunchType.Meme) {
console.log('This is a memecoin launch');
} else if (account2.data.launchType === LaunchType.Project) {
console.log('This is a project launch');
}

Genesisアカウントのフィールド: authority, baseMint, quoteMint, totalSupplyBaseToken, totalAllocatedSupplyBaseToken, totalProceedsQuoteToken, fundingMode, launchType, bucketCount, finalized

GPAビルダー — ローンチタイプで照会

getGenesisAccountV2GpaBuilder()を使用して、オンチェーンフィールドでフィルタリングされた全Genesisアカウントを照会します。SolanaのバイトレベルフィルターによるgetProgramAccounts RPCメソッドを使用して効率的な検索を行います。

import {
getGenesisAccountV2GpaBuilder,
LaunchType,
} from '@metaplex-foundation/genesis';
// すべてのミームコインローンチを取得
const memecoins = await getGenesisAccountV2GpaBuilder(umi)
.whereField('launchType', LaunchType.Meme)
.getDeserialized();
// すべてのプロジェクトローンチを取得
const projects = await getGenesisAccountV2GpaBuilder(umi)
.whereField('launchType', LaunchType.Project)
.getDeserialized();
// 複数フィールドでフィルタリング
const finalizedMemecoins = await getGenesisAccountV2GpaBuilder(umi)
.whereField('launchType', LaunchType.Meme)
.whereField('finalized', true)
.getDeserialized();
for (const account of memecoins) {
console.log(account.publicKey, account.data.baseMint, account.data.launchType);
}

launchTypeはローンチ作成後にバックエンドクランクによって遡及的に設定されます。最近作成されたローンチは、クランクが処理するまでLaunchType.Uninitialized(0)を表示する場合があります。

バケットと入金

関数戻り値
fetchLaunchPoolBucketV2()バケットの状態(存在しない場合はエラーをスロー)
safeFetchLaunchPoolBucketV2()バケットの状態またはnull
fetchPresaleBucketV2()バケットの状態(存在しない場合はエラーをスロー)
safeFetchPresaleBucketV2()バケットの状態またはnull
fetchLaunchPoolDepositV2()入金の状態(存在しない場合はエラーをスロー)
safeFetchLaunchPoolDepositV2()入金の状態またはnull
fetchPresaleDepositV2()入金の状態(存在しない場合はエラーをスロー)
safeFetchPresaleDepositV2()入金の状態またはnull
const bucket = await fetchLaunchPoolBucketV2(umi, bucketPda);
const deposit = await safeFetchLaunchPoolDepositV2(umi, depositPda); // null if not found

バケットの状態フィールド: quoteTokenDepositTotal, depositCount, claimCount, bucket.baseTokenAllocation

入金の状態フィールド: amountQuoteToken, claimed


LaunchType

バックエンドクランクがsetLaunchTypeV2インストラクションを介して遡及的に設定するオンチェーンのローンチカテゴリです。

enum LaunchType {
Uninitialized = 0, // クランクによってまだ設定されていない
Project = 1, // 構造化されたプロジェクトトークンローンチ
Meme = 2, // コミュニティミームコインローンチ
}

Integration APIsでは文字列('project''memecoin''custom')として返されますが、オンチェーンSDKでは上記の数値列挙型を使用します。

GenesisAccountV2

Genesisローンチのトップレベルオンチェーンアカウントです。トークンミントごと、ローンチインデックスごとに1つのアカウントが存在します。

{
key: Key;
bump: number;
index: number; // Genesisインデックス(通常は0)
finalized: boolean; // finalizeV2()後にtrue
authority: PublicKey; // ローンチ作成者
baseMint: PublicKey; // ローンチされるトークン
quoteMint: PublicKey; // 入金トークン(例:wSOL)
totalSupplyBaseToken: bigint; // トークン総供給量
totalAllocatedSupplyBaseToken: bigint; // バケットに割り当てられた供給量
totalProceedsQuoteToken: bigint; // 収集された総入金額
fundingMode: number; // ファンディングモード(0)
launchType: number; // 0 = 未初期化, 1 = プロジェクト, 2 = ミーム
bucketCount: number; // バケット数
}

アカウントサイズ:136バイト。PDAシード:["genesis_v2", baseMint, genesisIndex]

TimeCondition

{
__kind: 'TimeAbsolute',
padding: Array(47).fill(0),
time: bigint, // Unix timestamp (seconds)
triggeredTimestamp: null,
}

EndBehavior

{
__kind: 'SendQuoteTokenPercentage',
padding: Array(4).fill(0),
destinationBucket: PublicKey,
percentageBps: number, // 10000 = 100%
processed: false,
}

定数

定数
WRAPPED_SOL_MINTSo11111111111111111111111111111111111111112

よくあるエラー

エラー原因
insufficient funds手数料に必要なSOLが不足
already initializedGenesis Accountが既に存在
already finalizedファイナライズ後は変更不可
deposit period not active入金期間外
claim period not active請求期間外

FAQ

Umiとは何ですか?なぜ必要ですか?

UmiはMetaplexのSolana向けJavaScriptフレームワークです。トランザクションの構築、署名者の管理、Metaplexプログラムとのやり取りに一貫したインターフェースを提供します。

Genesis SDKをブラウザで使用できますか?

はい。SDKはNode.jsとブラウザの両方の環境で動作します。ブラウザでは、キーペアファイルの代わりにウォレットアダプターを使用して署名を行います。

fetchとsafeFetchの違いは何ですか?

fetchはアカウントが存在しない場合にエラーをスローします。safeFetchは代わりにnullを返すため、アカウントの存在確認に便利です。

トークンのローンチタイプを取得するにはどうすればいいですか?

トークンのミントアドレスを使用してfetchGenesisAccountV2FromSeeds()GenesisAccountV2アカウントを取得します。launchTypeフィールドは0(未初期化)、1(プロジェクト)、2(ミーム)を返します。特定のタイプの全ローンチを照会するには、GPAビルダーを使用します。または、Integration APIsがREST応答で文字列としてローンチタイプを返します。

トランザクションエラーはどのように処理しますか?

sendAndConfirmの呼び出しを try/catch ブロックで囲みます。エラーメッセージで具体的な失敗理由を確認してください。


次のステップ

完全な実装チュートリアルについて: