3

I have been recently started to play around the transfer hook and explored the Anchor tutorial on the website. My question is if the transfer hook reflects the end state of the transfer is there any way to alter that amount without requiring a delegate from the receiver?

Example: I want to implement a custom tax token, with a progressive transfer fee depending on the user current balance that works out of the box with current swaps, in my mind i would need to check the transferred amount on my hook and dynamically split it (e.g. 95% - 5%), is there an intended way to do that without having to prepare that split beforehand and transferring only the supposed 95% and then taking the extra 5% using a signer delegate?

I hope the question is clear, thank you very much for the support!

1 Answer 1

1

This won't be possible with a transfer hook.

Remember that only a program that owns an account can modify its contents. In the case of token-2022, this means that only token-2022 can modify the balances of its accounts.

A transfer hook, being a separate program, will not be able to modify those balances, so it's not possible to change the transfer amount in a transfer hook.

If you want to take a fee denominated in the same token type, you'll need to use the "transfer fee" extension: https://spl.solana.com/token-2022/extensions#transfer-fees -- this wouldn't be a progressive fee, but you can create an off-chain worker that periodically collects fees and rebates a certain amount to users.

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.