0

This is the error info:

Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Program failed to complete
      at Connection.sendEncodedTransaction (node_modules/@solana/web3.js/src/connection.ts:4465:13)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at Connection.sendRawTransaction (node_modules/@solana/web3.js/src/connection.ts:4424:20)
      at sendAndConfirmRawTransaction (node_modules/@project-serum/anchor/src/provider.ts:284:21)
      at AnchorProvider.sendAndConfirm (node_modules/@project-serum/anchor/src/provider.ts:144:14)
      at Object.rpc [as claimVestment] (node_modules/@project-serum/anchor/src/program/namespace/rpc.ts:29:16)

Could there be a problem with this:

token::transfer(
            CpiContext::new_with_signer(
                ctx.accounts.token_program.to_account_info(),
                token::Transfer {
                    from: ctx.accounts.vested_tokens.to_account_info(),
                    to: ctx.accounts.beneficiary_token_account.to_account_info(),
                    authority: ctx.accounts.vested_tokens.to_account_info(),
                },
                &[&[
                    b"vested-tokens",
                    vestment.key().as_ref(), //probably the problem
                    &[*ctx.bumps.get("vested-tokens").unwrap()],
                ]],
            ),
            *amount_to_claim,
        )?;

        vestment.amount_claimed = vestment.amount_claimed.checked_add(*amount_to_claim).unwrap();

        if vestment.amount_vested-vestment.amount_claimed==0 {
            vestment.is_active=false;
        }

In tests, this is how I call this instruction:

const txClaim1 = await program.rpc.claimVestment({
            accounts: {
                ledger: ledger,
                vestment: newVestment,
                beneficiary: beneficiary.publicKey,
                beneficiaryTokenAccount: beneficiaryTokenAccount,
                vestedTokens: vestedTokens,
                vestedTokensMint: tokenMint,
                tokenProgram: TOKEN_PROGRAM_ID,
                systemProgram: anchor.web3.SystemProgram.programId,
            },
            signers: [beneficiary],
        });

        await connection.confirmTransaction(txClaim1);

Any ideas?

1 Answer 1

5

without knowing anything about this bumps feature, i assume the error is unwrapping ctx.bumps.get("vested-tokens") and that the string is supposed to be snake case

but more broadly to debug this sort of issue, "Program failed to complete" means a panic. i would:

  • disable preflight checks on your connection object (i dont know offhand how this is done in anchor, Provider tries to hide a lot of details like this)
  • run solana-test-validator yourself
  • run solana logs -u l alongside it
  • run anchor test with --skip-local-validator

and look at the logs produced to find the actual error. msg! can be used to print whatever you need inside the program

2
  • Thanks a lot, very useful info, will update you once I check your tips out!
    – zazzz
    Commented Aug 11, 2022 at 11:56
  • Unfortunately, none of that works for me :/ By debugging I've come to the conclusion that my program doesn't even run the const txClaim1 line, as it for some reason breaks before that.
    – zazzz
    Commented Aug 11, 2022 at 13:23

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.