I have the following accounts in an instruction:
#[derive(Accounts)]
pub struct CreatePixel<'info> {
#[account(init, payer=user, space=Pixel::LEN)]
pub pixel: Account<'info, Pixel>,
#[account(mut)]
pub user: Signer<'info>,
pub system_program: Program<'info, System>,
}
When I build, the generated IDL has these accounts, note pixel
is a signer:
"accounts": [
{
"name": "pixel",
"isMut": true,
"isSigner": true
},
{
"name": "user",
"isMut": true,
"isSigner": true
},
{
"name": "systemProgram",
"isMut": false,
"isSigner": false
}
],
If I send a transaction in a unit test, I get "Error: Signature verification failed":
await program.methods
.createPixel(posX, posY, 0, 0, 255)
.accounts({
pixel: pixelAddress,
user: anchorProvider.wallet.publicKey,
systemProgram: web3.SystemProgram.programId,
})
.rpc()
Is it correct that pixel
needs to be a signer?
I'm aware that the correct thing to do here is to use a PDA, and that's the end-point of this code. But I thought I'd used code like this before without needing pixel
to be a signer so just want to double-check that the behaviour I'm seeing is expected.