Skip to content

Instantly share code, notes, and snippets.

@aheckmann
Last active November 5, 2024 08:55
Show Gist options
  • Save aheckmann/df6fdf795bb0843b4aea112b2b98a97e to your computer and use it in GitHub Desktop.
Save aheckmann/df6fdf795bb0843b4aea112b2b98a97e to your computer and use it in GitHub Desktop.
How to get rid of Solana spam NFTs
  1. Open a private tab
  2. Create a completely new wallet by visiting https://www.sollet.io
  3. You will see a screen displaying "Create new wallet" and a list of seed words
  4. Copy the seed words
  5. Check the box next to "I have saved these words in a safe place."
  6. Click "DOWNLOAD BACKUP MNEMONIC FILE (REQUIRED)". This downloads your seed phrase. Delete this file.
  7. Click "continue"
  8. Paste the seed words when it asks you to, then click continue
  9. Click "Main Account" at the top of the screen to copy the new wallet address. This address is where you'll send your spam NFTs.
  10. Open your Phantom wallet (assuming you are using Phantom)
  11. Visit the Collections tab
  12. Click the spam NFT
  13. Click Send
  14. Paste the address you copied
  15. Click "Next" and follow any additional instructions Phatom presents

You can also get rid of NFTs (or any token) by using the spl-token burn command available in your terminal after installing Solana.

First, using the spl-token accounts command, list the account data in your wallet. You'll see your NFT (in this case 9w9Qe8GxkrFnSJYKfQMJug9k8ufpfzxW6o7kXTFKpXrK) as well as it's token Account address.

spl-token accounts
Token                                         Account                                       Balance
----------------------------------------------------------------------------------------------------------
9w9Qe8GxkrFnSJYKfQMJug9k8ufpfzxW6o7kXTFKpXrK  wZj7agA6CWN99A5GEsTsitAqfPUfGhvJgLKdXBpxHDN   1

We need the value in the Account column to burn the given token using the burn command.

> spl-token burn --help

spl-token-burn
Burn tokens from an account

USAGE:
    spl-token burn [FLAGS] [OPTIONS] <SOURCE_TOKEN_ACCOUNT_ADDRESS> <TOKEN_AMOUNT>

FLAGS:
        --dump-transaction-message    Display the base64 encoded binary transaction message in sign-only mode
    -h, --help                        Prints help information
        --sign-only                   Sign the transaction offline
    -V, --version                     Prints version information
    -v, --verbose                     Show additional information

OPTIONS:
        --blockhash <BLOCKHASH>                   Use the supplied blockhash
    -C, --config <PATH>
            Configuration file to use [default: /Users/aaron/.config/solana/cli/config.yml]

        --fee-payer <KEYPAIR>
            Specify the fee-payer account. This may be a keypair file, the ASK keyword
            or the pubkey of an offline signer, provided an appropriate --signer argument
            is also passed. Defaults to the client keypair.
    -u, --url <URL_OR_MONIKER>
            URL for Solana's JSON RPC or moniker (or their first letter): [mainnet-beta, testnet, devnet, localhost]
            Default from the configuration file.
        --with-memo <MEMO>                        Specify a memo string to include in the transaction.
        --mint-address <MINT_ADDRESS>
            Address of mint that token account is associated with. Required by --sign-only

        --mint-decimals <MINT_DECIMALS>
            Decimals of mint that token account is associated with. Required by --sign-only

        --multisig-signer <MULTISIG_SIGNER>...    Member signer of a multisig account
        --nonce <PUBKEY>
            Provide the nonce account to use when creating a nonced
            transaction. Nonced transactions are useful when a transaction
            requires a lengthy signing process. Learn more about nonced
            transactions at https://docs.solana.com/offline-signing/durable-nonce
        --nonce-authority <KEYPAIR>
            Provide the nonce authority keypair to use when signing a nonced transaction

        --output <FORMAT>
            Return information in specified output format [possible values: json, json-compact]

        --owner <SOURCE_TOKEN_OWNER_KEYPAIR>
            Specify the source token owner account. This may be a keypair file, the ASK keyword. Defaults to the client
            keypair.
        --signer <PUBKEY=SIGNATURE>...            Provide a public-key/signature pair for the transaction

ARGS:
    <SOURCE_TOKEN_ACCOUNT_ADDRESS>    The token account address to burn from
    <TOKEN_AMOUNT>                    Amount to burn, in tokens

Example

> spl-token burn -v wZj7agA6CWN99A5GEsTsitAqfPUfGhvJgLKdXBpxHDN 1

Burn 1 tokens
  Source: wZj7agA6CWN99A5GEsTsitAqfPUfGhvJgLKdXBpxHDN

Signature: 4hAbU8NcXNF9XGtfqkLKY2hqpuF2EDqWSNFrrydKeQNH74ufBcG8JLnNCuKZJ8w66wWRhxsRLKjCC6JrYkPQuqfP

That's it. To confirm, rerun the spl-token accounts command to show the Balance is now zero.

spl-token accounts -v
Token                                         Account                                       Balance
----------------------------------------------------------------------------------------------------------
9w9Qe8GxkrFnSJYKfQMJug9k8ufpfzxW6o7kXTFKpXrK  wZj7agA6CWN99A5GEsTsitAqfPUfGhvJgLKdXBpxHDN   0
@tarunsharma19
Copy link

tarunsharma19 commented Aug 16, 2022

An alternate option, using Avana wallet:

  1. Import your existing wallet to Avana.
  2. Simply go to the NFT Gallery and select the NFT you want to remove.
  3. From the dropdown, click on the burn NFT option.

transaction will take a few seconds to confirm, then you'll receive the storage fee released.

You can get avana wallet from https://www.avanawallet.com/download/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment