everyone, I have a question about signers.
In https://www.rareskills.io/post/anchor-signer
(No need to view),
The Signer
of the contract and the.signers([newKeypair])
of ts are in one-to-one correspondence.
but in https://github.com/solana-developers/program-examples/blob/main/tokens/transfer-tokens/anchor/programs/transfer-tokens/src/instructions/create.rs
,
the main code is
#[derive(Accounts)]
pub struct CreateToken<'info> {
#[account(mut)]
pub payer: Signer<'info>,
#[account(
init,
payer = payer,
mint::decimals = 9,
mint::authority = payer.key(),
mint::freeze_authority = payer.key(),
)]
pub mint_account: Account<'info, Mint>,
}
we know payer: Signer<'info>
, and mint_account: Account<'info, Mint>
,
Why does ts call with.signers([mintKeypair])
?
const transactionSignature = await program.methods
.createToken(metadata.name, metadata.symbol, metadata.uri)
.accounts({
payer: payer.publicKey,
mintAccount: mintKeypair.publicKey,
})
.signers([mintKeypair])
.rpc();
In
https://github.com/solana-developers/program-examples/blob/main/tokens/transfer-tokens/anchor/tests/test.ts
.
I think it must need the signature of pay, but it doesn't need pay.