Created
April 4, 2023 09:00
-
-
Save lorisleiva/d4a69d5fe7dcaf73d8f6855c0e0bfd1f to your computer and use it in GitHub Desktop.
Clear the closeAuthority on a token account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createSetAuthorityInstruction, AuthorityType } from '@solana/spl-token'; | |
import { Transaction } from '@solana/web3.js'; | |
const instruction = createSetAuthorityInstruction( | |
token.publicKey, | |
closeAuthority.publicKey, | |
AuthorityType.CloseAccount, | |
null | |
); | |
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), | |
}).sendAndConfirm(umi); | |
// See a working example in the following test: | |
// https://github.com/metaplex-foundation/mpl-essentials/blob/0650eeda9d7b25bc78f80387859c166ce2232103/clients/js/test/setAuthority.test.ts#L33-L59 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment