That is what am i doing, transferring my NFTs to TokenAccount
with authority
as stake_account
which is a PDA. How can I tranfer NFTs back to a certian wallet in anchor-lang
.
use anchor_spl::token::{ Token, TokenAccount, Transfer }
Token Account:
#[account(
init_if_needed,
seeds = [mint.key().as_ref(), b"nfts_vault_seed", from.key().as_ref()],
bump,
//space = 82,
payer = from,
token::mint = mint,
token::authority = stake_account, //THIS authority is PDA
)]
pub nfts_vault: Account<'info, TokenAccount>,
Transfer NFT to TokenAccount
:
token::transfer(
CpiContext::new(
ctx.accounts.token_program.to_account_info(),
token::Transfer {
from: ctx.accounts.from.to_account_info(),
to: ctx.accounts.nfts_vault.to_account_info(),
authority: ctx.accounts.from.to_account_info(),
}
), 1
)?;