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

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

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

クローズすると、アカウントのrentが資金提供者(ユーザー、またはそれを資金提供した支払者)に返還されます。先にアクティブな委任をすべて解除してください。

クローズしても、SPL Tokenのデリゲート承認はクリアされません。PDAが削除されると承認は無効になりますが、取り消されるまでtoken accountに残り続けます。詳細はデリゲート承認の取り消しを参照してください。

Authorityのクローズ

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();

デリゲート承認の取り消し

RevokeSubscriptionAuthority は、ユーザーのtoken accountに残ったデリゲート承認をクリアします。これはユーザーの署名によってtoken programのRevoke を呼び出すため、Subscription Authorityが存在するかどうかにかかわらず機能します。単独で送信することも、CloseSubscriptionAuthority と組み合わせて送信することも可能です。

ミントを所有するtoken programを渡してください。SPL Tokenミントの場合はTOKEN_PROGRAM_ADDRESS、Token-2022ミントの場合は@solana-program/token-2022 からのTOKEN_2022_PROGRAM_ADDRESS を使用します。

import { TOKEN_PROGRAM_ADDRESS } from '@solana-program/token';
await client.subscriptions.instructions
.revokeSubscriptionAuthority({
user: userSigner,
tokenMint,
tokenProgram: TOKEN_PROGRAM_ADDRESS,
})
.sendTransaction();

注意事項

  • ユーザーがクローズトランザクションに署名します。
  • スポンサーがSubscription Authorityに資金を提供した場合、rentが記録された支払者に返還されるよう、そのスポンサーアカウントをreceiver として渡してください。
  • Subscription Authorityをクローズする前に、固定、定期、およびサブスクリプション委任のPDAをすべてクローズしてください。
  • ユーザーが後で新しい委任を作成する場合は、同じミントに対して新しいSubscription Authorityを初期化してください。
  • クローズしてもtoken delegateの承認はクリアされません。ユーザーのtoken accountから削除するにはRevokeSubscriptionAuthority を使用してください。

Is this page helpful?

目次

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