Skip to content

project-9 error: Reached maximum depth for account resolution #35

@miaomiaowu0428

Description

@miaomiaowu0428

in the test file: TokenLottery.spec.ts

async function buyTicket() {
    console.log("buying ticket");
    const buyTicket = program.methods.buyTicket()
      .accounts({
        tokenProgram: TOKEN_PROGRAM_ID,
      });
    console.log("buy ticket ", buyTicket);
    const buyTicketIX = await buyTicket.instruction(); // error when building instruction: Reached maximum depth for account resolution
    console.log("buy ticket ix ", buyTicketIX);

    const blockhashContext = await provider.connection.getLatestBlockhash();

    const computeIx = anchor.web3.ComputeBudgetProgram.setComputeUnitLimit({
      units: 300000,
    });

    const priorityIx = anchor.web3.ComputeBudgetProgram.setComputeUnitPrice({
      microLamports: 1,
    });

    const tx = new anchor.web3.Transaction({
      blockhash: blockhashContext.blockhash,
      lastValidBlockHeight: blockhashContext.lastValidBlockHeight,
      feePayer: wallet.payer.publicKey,
    }).add(buyTicketIx)
      .add(computeIx)
      .add(priorityIx);

    const sig = await anchor.web3.sendAndConfirmTransaction(
      provider.connection,
      tx,
      [wallet.payer],
    );
    console.log("buy ticket ", sig);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions