支払いサブスクリプション

サブスクリプション権限のクローズ

サブスクリプション権限は、プログラムがユーザーのトークンアカウントのSPLトークンデリゲートとして使用するPDAです。ユーザーがそのミントに対してアクティブな固定デリゲーション、定期デリゲーション、またはサブスクリプションデリゲーションを持っていない場合にクローズします。

アカウントをクローズすると、そのrentがアカウントのlamportファンダーに返還され、プログラムが所有するトークンデリゲートの承認が取り消されます。ファンダーは通常ユーザーですが、サブスクリプション権限アカウントに資金を提供した任意のペイヤーである可能性があります。アクティブなデリゲーションが依然としてその権限に依存している場合は、まずそれらのデリゲーションをクローズしてください。

権限のクローズ

import { address, createClient } from '@solana/kit';
import { solanaLocalRpc } from '@solana/kit-plugin-rpc';
import { signer } from '@solana/kit-plugin-signer';
import {
findSubscriptionAuthorityPda,
subscriptionsProgram,
} from '@solana/subscriptions';
const client = createClient()
.use(signer(userSigner))
.use(solanaLocalRpc({ rpcUrl: 'http://127.0.0.1:8899' }))
.use(subscriptionsProgram());
const tokenMint = address('TOKEN_MINT_ADDRESS_HERE');
const [subscriptionAuthorityPda] = await findSubscriptionAuthorityPda({
user: userSigner.address,
tokenMint,
});
await client.subscriptions.instructions
.closeSubscriptionAuthority({
user: userSigner,
tokenMint,
// Include this only when a sponsor funded the Subscription Authority.
receiver: sponsorSigner.address,
})
.sendTransaction();

注意事項

  • ユーザーがクローズトランザクションに署名します。
  • スポンサーがサブスクリプション権限に資金を提供した場合は、そのスポンサーアカウントをreceiverとして渡し、rentが記録されたペイヤーに返還されるようにします。
  • サブスクリプション権限をクローズする前に、固定、定期、およびサブスクリプションデリゲーションPDAをクローズしてください。
  • ユーザーが後で新しいデリゲーションを作成する場合は、同じミントに対して新しいサブスクリプション権限を初期化します。

Is this page helpful?

目次

ページを編集
© 2026 Solana Foundation. 無断転載を禁じます。