2

I can't tell how safe it is to arbitrarily support transfers on "transfer hook" enabled tokens via CPI from my program.

At the moment i am setting is_signer and is_writable to false on all remaining accounts before forwarding them to the transfer CPI.

    remaining_accounts.iter().for_each(|meta| {
        ix.accounts.push(AccountMeta { pubkey: meta.key(), is_signer: false, is_writable: false })
    });

I know that all the core accounts are set to immutable by the token pogram but i'm concerned about the Extra account metas.

1 Answer 1

2

It's a completely valid concern, but changing all of the extra account metas will likely make transfer hooks fail.

Keep in mind that only a program can modify its accounts, so your concern is about the transfer hook program doing a CPI into some other program. That might be totally valid behavior though!

For example, a transfer hook might want to deduct a fee in USDC for a royalty payment, which requires token accounts, program, and a separate signer.

If you wanted to be defensive, you could simply check to make sure that it's not requesting any of the accounts required by your program. For example, downgrade any signer that your program is using that's also part of the extra accounts meta.

Or just downgrade signers, and break fewer transfer hooks.

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.