Can I make some USDC like magic via the method described as following?

I'll use a keypair to create an account (say account A) with the same space as a token account. Then I'll assign account A to a custom program, and the program will write data to account A. After writing data, now account A just looks like a normal token account.

For example, the token account is defined as following:

pub struct Account {
    pub mint: Pubkey,
    pub owner: Pubkey,
    pub amount: u64,
    pub delegate: COption<Pubkey>,
    pub state: AccountState,
    pub is_native: COption<u64>,
    pub delegated_amount: u64,
    pub close_authority: COption<Pubkey>,

My custom program will make account A into this format, with mint field equal to USDC's mint, owner field equal to my wallet, amount field equal to a fairly large number like $1,000,000,000 USDC.

Then, my custom program will assign account A to Token Program. I'm wondering how Token Program can tell the difference between my fake USDC token account and a real one.

1 Answer 1


You can not assign an account to another program that has data.

Requirements to assign:

  • only the owner of the account may change owner
  • if the account is writable
  • if the account is not executable
  • if the data is zero-initialized or empty

You can read up on it here: https://solana.wiki/zh-cn/docs/account-model/ and here: https://solana.com/docs/core/runtime

  • Could you please share an official link that describes this behavior? This behavior isn't even documented on docs.rs
    – Yan
    Commented Mar 15 at 10:40
  • 1
    I've found it myself. The Solana official doc (here) describes what Solana runtime will check. And it says: Only the owner of the account may change owner. And only if the account is writable. And only if the account is not executable. And only if the data is zero-initialized or empty.
    – Yan
    Commented Mar 15 at 10:52
  • 1
    Thank you i updated the answer and here is some more info: solana.wiki/zh-cn/docs/account-model
    – Jonas H.
    Commented Mar 15 at 10:57
  • nice idea though ;)
    – Jonas H.
    Commented Mar 15 at 10:58

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.