-
Notifications
You must be signed in to change notification settings - Fork 224
Open
Description
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
Labels
No labels