2

I'm creating a Token-2022 token with a transfer hook that burns some of the token on transfer. However, the token I want to use I want to create in the CLI. However, in order the burn a token, I need to pass down the authority from the mint account within the burn instruction. So I created a BurnToken account to do that, but that account won't have authority to burn tokens because it won't have ownership of the Token-2022 token I'll create. So I decided to create an Approve instruction to make the BurnToken account a delegate, but I need the Delegate and Authority of the mint account in question and I'm not sure how to access that within a program and it was created outside of the program.

POTENTIAL SOLUTION

The one solution I can think of involves me writing a CreateMint instruction that creates the Token2022 mint inside the program itself and just storing that data within the program itself which would allow me to pass it to the Approve instruction. But I'd really like to avoid that because I'll only use this instruction once (this goes beyond the functionality of the program I'm writing) and it increases the cost to deploy the program itself.

Is there a way to access the ATA account maybe?

1 Answer 1

2

Since you're trying to burn tokens of the same type as the one transferred, another approach is the use the TransferFee extension instead.

The TransferFee extension allows you to configure a transfer fee directly on the Mint Account. Every time tokens are transferred, the fee is set aside in the recipient's Token Account. This fee is untouchable by the recipient and can only be accessed by the Withdraw Authority. You (as the Withdraw Authority), can then periodically collect the accumulated fees and burn the tokens.

Here is a Solana Playground example of how to create a Mint with the TransferFee extension enabled.

Currently, with the transfer hook interface, the accounts from the inital transfer are converted to read-only accounts before making the CPI into your custom transfer hook program. This means you are not able to easily use the token accounts from the initial transfer within your custom instruction logic, other than reading from the accounts.

3
  • The transfer fee idea is one I like. Do you think it's possible to write a Solana instruction that passively watches the current epoch and burns a set of tokens every epoch? Without that being triggered by a user since it'll be a PDA?
    – Brian M.
    Dec 14, 2023 at 22:15
  • 1
    You can try using clockwork (which allows to configure automated transactions on-chain), github.com/open-clockwork/clockwork As an example, here is a demo of a game created by Jonas using clockwork youtube.com/watch?v=ax0Si3Vkvbo&ab_channel=Solana
    – john
    Dec 14, 2023 at 23:19
  • Thanks! I wasn't aware of this. This is exactly what I'm looking for and has implementations that'll allow me to either take a program approach or clientside approach using Typescript
    – Brian M.
    Dec 15, 2023 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.