Skip to content

Instantly share code, notes, and snippets.

Created April 4, 2023 09:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lorisleiva/d4a69d5fe7dcaf73d8f6855c0e0bfd1f to your computer and use it in GitHub Desktop.
Clear the closeAuthority on a token account
import { createSetAuthorityInstruction, AuthorityType } from '@solana/spl-token';
import { Transaction } from '@solana/web3.js';
const instruction = createSetAuthorityInstruction(
const transaction = new Transaction().add(instruction);
const { blockhash } = await connection.getLatestBlockhash();
transaction.recentBlockhash = blockhash;
transaction.feePayer = payer.publicKey;
const signature = await connection.sendTransaction(tx, [payer, closeAuthority]);
await connection.confirmTransaction(signature);
import { setAuthority, AuthorityType } from '@metaplex-foundation/mpl-essentials';
import { none } from '@metaplex-foundation/umi';
await setAuthority(umi, {
owned: token.publicKey,
owner: closeAuthority,
authorityType: AuthorityType.CloseAccount,
newAuthority: none(),
// See a working example in the following test:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment