A Subscription Authority is the PDA that the program uses as the SPL Token delegate for a user's token account. Close it when the user no longer has active fixed delegations, recurring delegations, or subscription delegations for that mint.
Closing returns the account's rent to its funder (the user, or whichever payer funded it). Close any active delegations first.
Closing does not clear the SPL Token delegate approval. Once the PDA is gone the approval is inert, but it stays on the token account until revoked — see Revoke The Delegate Approval.
Close The 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();
Revoke The Delegate Approval
RevokeSubscriptionAuthority clears the leftover delegate approval from the
user's token account. It calls the token program's Revoke, signed by the user,
so it works whether or not the Subscription Authority still exists. Send it
standalone or alongside CloseSubscriptionAuthority.
Pass the token program that owns the mint: TOKEN_PROGRAM_ADDRESS for SPL Token
mints, or TOKEN_2022_PROGRAM_ADDRESS (from @solana-program/token-2022) for
Token-2022 mints.
import { TOKEN_PROGRAM_ADDRESS } from '@solana-program/token';await client.subscriptions.instructions.revokeSubscriptionAuthority({user: userSigner,tokenMint,tokenProgram: TOKEN_PROGRAM_ADDRESS,}).sendTransaction();
Notes
- The user signs the close transaction.
- If a sponsor funded the Subscription Authority, pass that sponsor account as
receiverso rent returns to the recorded payer. - Close fixed, recurring, and subscription delegation PDAs before closing the Subscription Authority.
- If the user creates a new delegation later, initialize a new Subscription Authority for the same mint.
- Closing does not clear the token delegate approval. Use
RevokeSubscriptionAuthorityto remove it from the user's token account.
Is this page helpful?