5

I'm getting an error while executing an initialise code in my smart contract. I'm using Anchor Framework for my code. Below is the struct and the account:

#[derive(Accounts)]
pub struct InitializeAdminList<'info> {
    // Admin list PDA Account
    #[account(
        init,
        seeds = [b"adminlist".as_ref()],
        bump,
        payer = authority,
        space = 16 + AdminListAccount::MAX_SIZE
    )]
    pub admin_list_pda: Account<'info, AdminListAccount>,
    #[account(mut)]
    pub authority: Signer<'info>,
    pub system_program: Program<'info, System>,
}

#[account]
pub struct AdminListAccount {
    // Admin address List
    pub admin_list: Vec<Pubkey>,
}

impl AdminListAccount {
    pub const MAX_SIZE: usize = 4 + (10 * 32);
}

Below is the code in React app:

async function initializeAdminList() {
    const provider = await getProvider();
    /* create the program interface combining the idl, program ID, and provider */
    const program = new Program(idl, programID, provider);
    try {
      const [adminList, bumpAdmin] =
          await web3.PublicKey.findProgramAddress(
            [utf8.encode("adminlist")],
            program.programId
          );

      console.log("adminListPDA", adminList.toString(), "bump", bumpAdmin);

      const trans = await program.methods
        .initializeAdminList()
        .accounts({
          adminListPda: adminList,
          authority: provider.wallet.publicKey,
          systemProgram: web3.SystemProgram.programId,
        })
        .rpc();

      console.log("trans", trans);

    } catch (err) {
      console.log("Transaction error: ", err);
    }
  }

When I run this code, I get the below error:

"Program failed to complete: Instruction passed to inner instruction is too large (12884933924 > 1280)"

Can someone explain what am I doing wrong? Thanks in advance for your help.

2
  • Can you share more on the logs or link to the explorer with this tx
    – Pratik.js
    Commented Jun 6, 2023 at 18:13
  • Logs: 0 : "Program 8weVzacVFidiqk1cJxezhLrqayHpFtKi7qyA76d7oLab invoke [1]" 1 : "Program log: Instruction: InitializeAdminList" 2 : "Program 8weVzacVFidiqk1cJxezhLrqayHpFtKi7qyA76d7oLab consumed 7816 of 200000 compute units" 3 : "Program failed to complete: Instruction passed to inner instruction is too large (12884933924 > 1280)" 4 : "Program 8weVzacVFidiqk1cJxezhLrqayHpFtKi7qyA76d7oLab failed: Program failed to complete" Commented Jun 7, 2023 at 8:15

3 Answers 3

3

Found the resolution:

I was using Solana version 1.16.0 which was causing the issue. I downgraded to 1.14.18 and it solved the problem.

1
1

"Program 8weVzacVFidiqk1cJxezhLrqayHpFtKi7qyA76d7oLab consumed 7816 of 200000 c.rpc( Found the resolution:

I was using Solana version 1.16.0 which was causing the issue. I downgraded to 1.14.18 and it solved the problem.);

  console.log("trans", trans);Logs: 0 : "Program 8weVzacVFidiqk1cJxezhLrqayHpFtKi7qyA76d7oLab invoke [1]" 1 : "Program log: Instruction: InitializeAdminList"

} catch (err) {
   console.log("adminListPDA", adminList.toString(), "bump", bumpAdmin);

  const trans = await program units"
1
  • InitializeAdminList" } catch (err) { console.log("adminListPDA", adminList.toString(), "bump", bumpAdmin);"Program 8weVzacVFidiqk1cJxezhLrqayHpFtKi7qyA76d7oLab invoke [1]" 1 : "Program log: Instruction: InitializeAdminList"[Buffer.from("adminlist", "utf-8")], program.programId ); Commented Jun 8, 2023 at 8:10
0

You get this error sometimes when you accidentally pass a String or other object instead of a pubkey in your accounts args. The combined size of the bytes for accounts + args must be < 1280 in legacy txes.

Make sure SystemProgram is imported correctly and check the wallet is what you expect.

    try {
      const [adminList, bumpAdmin] =
          PublicKey.findProgramAddressSync(
            [Buffer.from("adminlist", "utf-8")],
            program.programId
          );

      console.log("adminListPDA", adminList.toString(), "bump", bumpAdmin);

      const trans = await program.methods
        .initializeAdminList()
        .accounts({
          adminListPda: adminList,
          authority: provider.wallet.publicKey,
          systemProgram: SystemProgram.programId,
        })
        .rpc();

      console.log("trans", trans);

    } catch (err) {
      console.log("Transaction error: ", err);
    }

If that's not it, then Solana is having troubling serializing your struct as given. You didn't pass a Vec to the init ix, so it doesn't know what size to give the Vec. Try initializing the Vec with PubKey default placeholders instead of just specifying the size.

1
  • Thanks for your answer. Let me reply 1 by 1 on the questions asked: 1. I am passing only pubkeys in the account args. 2. There are no args to this method, and only 3 accounts, so the combined size must be less than 1280 characters. 3. SystemProgram and wallet are correct. 4. I removed the Vector in my struct to check if that's causing the issue. I now have a single pubkey field and even that is throwing same error. I don't understand what's the issue. Any further help will be highly appreciated. Commented Jun 7, 2023 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.