1

I cloned this repo: solana-movie-program and deployed it on Solana Playground.

I also cloned solana-movie-client and tried it but I get the error: "Transaction simulation failed: Error processing Instruction 0: insufficient account keys for instruction"

Also here are the logs:

[
    'Program AJBhcFoWMtxWpmtkjfftKpiBBxXnVKo7y4jFVpAfmfQQ invoke [1]',
    'Program log: process_instruction: AJBhcFoWMtxWpmtkjfftKpiBBxXnVKo7y4jFVpAfmfQQ: 3 accounts, data=[0, 27, 0, 0, 0, 66, 114, 97, 118, 101, 104, 101, 97, 114, 116, 57, 48, 54, 56, 57, 54, 46, 54, 53, 55, 48, 52, 49, 48, 54, 57, 53, 5, 13, 0, 0, 0, 65, 32, 103, 114, 101, 97, 116, 32, 109, 111, 118, 105, 101]',
    'Program log: Adding movie review...',
    'Program log: Title: Braveheart906896.6570410695',
    'Program log: Rating: 5',
    'Program log: Description: A great movie',
    'Program AJBhcFoWMtxWpmtkjfftKpiBBxXnVKo7y4jFVpAfmfQQ consumed 27607 of 200000 compute units',
    'Program AJBhcFoWMtxWpmtkjfftKpiBBxXnVKo7y4jFVpAfmfQQ failed: insufficient account keys for instruction'
  ]
}

Does anyone know how to fix it? Thanks!

1 Answer 1

1

Try using code from the starter branch: https://github.com/Unboxed-Software/solana-movie-program/tree/starter

That client code builds the instruction like this: https://github.com/Unboxed-Software/solana-movie-client/blob/main/src/index.ts#L61

const instruction = new web3.TransactionInstruction({
        programId: programId,
        data: buffer,
        keys: [
            {
                pubkey: signer.publicKey,
                isSigner: true,
                isWritable: false
            },
            {
                pubkey: pda,
                isSigner: false,
                isWritable: true
            },
            {
                pubkey: web3.SystemProgram.programId,
                isSigner: false,
                isWritable: false
            }
        ]
    })

Which matches these three accounts in the starter branch: https://github.com/Unboxed-Software/solana-movie-program/blob/starter/src/processor.rs#L53

let  initializer = next_account_info(account_info_iter)?; 
let  pda_account = next_account_info(account_info_iter)?; 
let  system_program = next_account_info(account_info_iter)?;

However, if you used the main branch, there's four accounts, which might be the cause for the error you're seeing: https://github.com/Unboxed-Software/solana-movie-program/blob/main/src/processor.rs#L55

let initializer = next_account_info(account_info_iter)?;
let pda_account = next_account_info(account_info_iter)?;
let pda_counter = next_account_info(account_info_iter)?;
let system_program = next_account_info(account_info_iter)?;

Here is the written content for this example program (the branches are for different sections): https://soldev.app/course

1
  • That is the correct answer. However I get the error: "RangeError: Trying to access beyond buffer length" Commented Jan 6, 2023 at 2:06

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.