I need a program owned token account to hold WSOL. I am creating it like thus

   pub struct InitializeProgramTokenAccount<'info> {                     
       ///CHECK: only read from, address checked in function                                                                                                                                             
       pub authority_pda: UncheckedAccount<'info>,                                                                                                                 
           payer = payer,                                                                                                                                          
           token::mint = mint,                                                                                                                                     
           token::authority = authority_pda,                                                                                                                       
       pub token_account: Account<'info, TokenAccount>,                                                                                                            
       pub mint: Account<'info, Mint>,                                                                                                                             
       pub payer: Signer<'info>,                                                                                                                                   
       pub system_program: Program<'info, System>,                                                                                                                 
       pub token_program: Program<'info, Token>,                                                                                                                   
       pub associated_token_program: Program<'info, AssociatedToken>,                                                                                              
       pub rent: Sysvar<'info, Rent>,

The authority_pda address is found using

let (auth_pk, bump) = Pubkey::find_program_address(&[AUTH_SEED.as_bytes().as_ref()], &crate::ID);

I am trying to do transfer, create_account, close_account using anchor spl_token cpis. Eg:

   let seeds = &[AUTH_SEED.as_bytes().as_ref(), &[bump]];
   let program_unwrap_wsol_context = CpiContext::new(
       anchor_spl::token::CloseAccount {
           account: ctx.accounts.program_wsol_account.to_account_info(),
           destination: ctx.accounts.pda_authority.to_account_info(),
           authority: ctx.accounts.pda_authority.to_account_info(),

When I pass in seeds as &[AUTH_SEED.as_bytes().as_ref(), [bump]], I get the error

> Instruction references an unknown account ....
> > Program returned error: An account required by the instruction is missing

If I pass in the seeds as &[AUTH_SEED.as_bytes().as_ref()] then I get the error

> > Program returned error: Could not create program address with signer seeds provided seeds do not result in a valid address

I assume this is because I am not using the off-the-shelf token::authority?

How to fix?

1 Answer 1


Use this.


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.