Quantcast
Channel: Recent Questions - Solana Stack Exchange
Viewing all articles
Browse latest Browse all 7969

why "Transaction references a signature that is unnecessary" warning, and value of 'isSigner' is false in IDL?

$
0
0

I was playing with counter program in program-example repo.

When run test, I got warning: Transaction references a signature that is unnecessary, only the fee payer and instruction signer accounts should sign a transaction., even though the contract method executed as expected.

The on-chain code is:

#[program]pub mod counter_anchor {    use super::*;        ...    pub fn increment(ctx: Context<Increment>) -> Result<()> {        msg!(" call increment +  ...");                ctx.accounts.counter.count = ctx.accounts.counter.count.checked_add(1).unwrap();        Ok(())    }    ....}    ...#[derive(Accounts)]pub struct Increment<'info> {    #[account(mut)]    pub counter: Account<'info, Counter>,}#[account]#[derive(InitSpace)]pub struct Counter {    count: u64,}

And my client js code is:

async function test_call_increase() {  let tx = await program.methods    .increment()    .accounts({      counter: counterKeypair.publicKey,    })    // .signers([payer.payer, counterKeypair])        .transaction();    let txHash = await sendAndConfirmTransaction(      provider.connection,      tx,      [wallet.payer, counterKeypair],  // <== Here, two signer, first one for pay gas.      { skipPreflight: true }      );}

Also , in target/types/counter_anchor.ts , its isSigner is false.

    {"name": "increment","accounts": [        {"name": "counter","isMut": true,"isSigner": false        }      ],"args": []    },

AFAIK, I should let counter account to participate signing as to change its account data.

Why it say that counter shouldn't appear in signer list? How to fix it?

Thanks.


Viewing all articles
Browse latest Browse all 7969

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>