How to burn SPL token through other smart contract program and check who and how many?

I am looking for help with how to design the smart contract which should allow people to burn their spl tokens and check how much they burnt.

I have experience with EVM smart contracts but newbie in Solana space and currently learning it. Because of different architecture of Solana it’s very difficult to start off. :cry:

What I am trying to build is some kind of spl token burning contract and it should allow people to burn their tokens when enabled by admin but not allow when disabled. And should be able to see how many tokens have burnt by each address. I really couldn’t figure out how to design the contract for over two weeks and I couldn’t determine if I should use normal account or PDA account to store the status.

Please anyone give me some tips on this. :pray:
Thank you in advance.

Hi @techstreamp and welcome to the forum! :wave:

Sorry for such a late reply. :slight_smile:

Anyway, I don’t have time to research and figure out the exact way you might do that, but here’s some pointers on how you might be able to do it. And if you have more questions feel free to ask. You will find more people who know Solana dev stuff on the Solana Discord, too.

I think the workflow would be something like this:

  • Generate a new keypair. We’ll call it Key A.
  • Create a new SPL token mint with that keypair as the authority. We’ll call your token TOK.
  • Now Key A has the authority to mint and burn TOK tokens
  • Now you’ll have to write your smart contract
  • I think you can setup your smart contract so that you can initialize your “token burn admin” by signing a transaction with Key A
    • Then you smart contract will use a cross-program-invokation to set the mint/burn authority of your TOK token to the address of the smart contract
      • This should work because you signed the transaction with Key A, the previous token authority
    • Also, as part of this transaction, you pass the public key of the admin that will have the right to set which users can burn their own tokens.
  • Now the admin can send transactions to your smart contract that create and store new data accounts with each account containing the address of your Token mint, and the address of a user that is allowed to burn their tokens.
  • Users can also now send transactions to your smart contract to request that their tokens be burned, but the smart contract will only allow the user to burn the tokens if there is a data account that proves that the admin authorized the user to burn their tokens.

Solana is a very different kind of way to think about designing smart contracts compared to Ethereum, I think, and there isn’t a lot to help you get started yet. It’s also a little difficult to explain, so don’t feel bad if it’s a bit of a rough start!