본문 바로가기

블록체인/솔라나

[Solana] PDA가 가진 ATA Transfer시 "signer privilege escalated" 에러

 

 

프로그램이 가지고 있는 토큰을 사용자에게 전송할 때 "signer privilege escalated ..." 에러가 발생하였다.

 

 #[account(init, seeds = [b"pool", config.key().as_ref(), mint.key().as_ref()], bump, payer = signer, space = 8 + std::mem::size_of::<Pool>())]
    pub pool: Box<Account<'info, Pool>>,
 #[account(init,seeds=[pool.key().as_ref(), mint.key().as_ref()], bump, payer = signer, token::mint = mint, token::authority = pool)]
    pub pool_vault: Box<Account<'info, TokenAccount>>,

ata의 authority를 pool로 지정 한 후 cpi를 호출하기 위해 signer seeds를 만들 때 pool을 init 할 때 지정한 seeds 이외에 bump도 추가적으로 포함시켜주어야 한다.

 

에러 발생

        let seeds = &[
            b"pool".as_ref(),
            ctx.accounts.config.to_account_info().key.as_ref(),
            ctx.accounts.mint.to_account_info().key.as_ref(),
        ];

 

변경 후

        let seeds = &[
            b"pool".as_ref(),
            ctx.accounts.config.to_account_info().key.as_ref(),
            ctx.accounts.mint.to_account_info().key.as_ref(),
            &[ctx.accounts.pool.bump]
        ];

 

seeds가 달라 해당 시드를 가지고 findProgramAddress를 하면 다른 pda가 반환되지만 cpi는 정상적으로 작동된다.