project-8-token-lottery: Error InvalidSecpSignature when run anchor test
project-8-token-lottery: Error InvalidSecpSignature when run anchor test
Loading saved threads...
Linh Hồ · External communityPost link
External question — Solana Stack Exchange
Author: Linh Hồ
Original post: https://solana.stackexchange.com/questions/15906
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
I am very grateful for your knowledge to be shared. Through the knowledge you share I learn many new and very interesting things.
while practicing project-8-token-lottery. I get an error when running Anchor test. It is the error: "Program log: AnchorError occurred. Error Code: InvalidSecpSignature. Error Number: 6016. Error Message: InvalidSecpSignature". I have tried many ways but have not fixed it. Please give me advice. Thank you so much!
my code in Anchor test
it("Is committing and revealing a winner",async()=>{
const queue = new anchor.web3.PublicKey("FfD96yeXs4cxZshoPPSKhSPgVQxLAJUT3gefgh84m1Di"); //devnet
const queueAccount = new sb.Queue(switchboardProgram, queue);
const rngKp = anchor.web3.Keypair.generate();
try {
await queueAccount.loadData();
} catch (err) {
console.log("Queue account not found");
process.exit(1);
}
const [randomness, ix] = await sb.Randomness.create(switchboardProgram, rngKp, queue);
console.log("Created randomness account..");
console.log("Randomness account", randomness.pubkey.toBase58());
console.log("rkp account", rngKp.publicKey.toBase58());
const createRandomnessTx = await sb.asV0Tx({
connection:provider. connection,
ixs: [ix],
payer: wallet.publicKey,
signers: [wallet.payer,rngKp],
computeUnitPrice: 75_000,
computeUnitLimitMultiple: 1.3,
});
const blockhashContext = await provider.connection.getLatestBlockhashAndContext();
const createRandomnessSignature = await provider.connection.sendTransaction(createRandomnessTx);
await provider.connection.confirmTransaction({ //sign the transaction
signature: createRandomnessSignature,
blockhash: blockhashContext.value.blockhash,
lastValidBlockHeight: blockhashContext.value.lastValidBlockHeight
});
console.log(
"Transaction Signature for randomness account creation: ",
createRandomnessSignature
);
const sbCommitIx = await randomness.commitIx(queue);
// commint a winer on chain.
const commitIx = await program.methods.commitAWinner()
.accounts(
{
randomnessAccountData: randomness.pubkey
}
)
.instruction();
const commitTx = await sb.asV0Tx({
connection: switchboardProgram.provider.connection,
ixs: [sbCommitIx, commitIx],
payer: wallet.publicKey,
signers: [wallet.payer],
computeUnitPrice: 75_000,
computeUnitLimitMultiple: 1.3,
});
const commitSignature = await provider.connection.sendTransaction(commitTx);
await provider.connection.confirmTransaction({
signature: commitSignature,
blockhash: blockhashContext.value.blockhash,
lastValidBlockHeight: blockhashContext.value.lastValidBlockHeight
});
console.log(
"Transaction Signature for commit: ",
commitSignature
);
// choose a winer
const sbRevealIx = await randomness.revealIx();
const revealIx = await program.methods.choseWiner()
.accounts({
randomnessAccountData: randomness.pubkey
})
.instruction();
const revealTx = await sb.asV0Tx({
connection: switchboardProgram.provider.connection,
ixs: [sbRevealIx,revealIx],
payer: wallet.publicKey,
signers: [wallet.payer],
computeUnitPrice: 75_000,
computeUnitLimitMultiple: 1.3,
});
const revealSignature = await provider.connection.sendTransaction(revealTx);
await provider.connection.confirmTransaction({
signature: revealSignature,
blockhash: blockhashContext.value.blockhash,
lastValidBlockHeight: blockhashContext.value.lastValidBlockHeight
});
// await provider.connection.confirmTransaction(revealSignature,"confirmed");
console.log("Transaction Signature revealTx: ", revealSignature);
});
Quote
Report
Edinaldo Junior · External communityPost link
External answer — Solana Stack Exchange
Author: Edinaldo Junior
Original post: https://solana.stackexchange.com/a/16262
License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/
Adaptation: HTML converted to plain text; contact email addresses removed.
Apparently the signature is wrong.
You can checkout how to make a lottery program here:
https://medium.com/@edinaldo-jr/beyond-simple-tutorials-building-a-lottery-game-on-solana-blockchain-with-anchor-and-rust-7c3d5fe3963a
Quote
Report
Post Reply
Quoted from Forex.com.bd-Editorial External question — Solana Stack Exchange Author: Linh Hồ Source score (net votes, not local likes): 0 Original post: https://solana.stackexchange.com/questions/15906 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I am very grateful for your knowledge to be shared. Through the knowledge you share I learn many new and very interesting things. while practicing project-8-token-lottery. I get an error when running Anchor test. It is the error: "Program log: AnchorError occurred. Error Code: InvalidSecpSignature. Error Number: 6016. Error Message: InvalidSecpSignature". I have tried many ways but have not fixed it. Please give me advice. Thank you so much! my code in Anchor test it("Is committing and revealing a winner",async()=>{ const queue = new anchor.web3.PublicKey("FfD96yeXs4cxZshoPPSKhSPgVQxLAJUT3gefgh84m1Di"); //devnet const queueAccount = new sb.Queue(switchboardProgram, queue); const rngKp = anchor.web3.Keypair.generate(); try { await queueAccount.loadData(); } catch (err) { console.log("Queue account not found"); process.exit(1); } const [randomness, ix] = await sb.Randomness.create(switchboardProgram, rngKp, queue); console.log("Created randomness account.."); console.log("Randomness account", randomness.pubkey.toBase58()); console.log("rkp account", rngKp.publicKey.toBase58()); const createRandomnessTx = await sb.asV0Tx({ connection:provider. connection, ixs: [ix], payer: wallet.publicKey, signers: [wallet.payer,rngKp], computeUnitPrice: 75_000, computeUnitLimitMultiple: 1.3, }); const blockhashContext = await provider.connection.getLatestBlockhashAndContext(); const createRandomnessSignature = await provider.connection.sendTransaction(createRandomnessTx); await provider.connection.confirmTransaction({ //sign the transaction signature: createRandomnessSignature, blockhash: blockhashContext.value.blockhash, lastValidBlockHeight: blockhashContext.value.lastValidBlockHeight }); console.log( "Transaction Signature for randomness account creation: ", createRandomnessSignature ); const sbCommitIx = await randomness.commitIx(queue); // commint a winer on chain. const commitIx = await program.methods.commitAWinner() .accounts( { randomnessAccountData: randomness.pubkey } ) .instruction(); const commitTx = await sb.asV0Tx({ connection: switchboardProgram.provider.connection, ixs: [sbCommitIx, commitIx], payer: wallet.publicKey, signers: [wallet.payer], computeUnitPrice: 75_000, computeUnitLimitMultiple: 1.3, }); const commitSignature = await provider.connection.sendTransaction(commitTx); await provider.connection.confirmTransaction({ signature: commitSignature, blockhash: blockhashContext.value.blockhash, lastValidBlockHeight: blockhashContext.value.lastValidBlockHeight }); console.log( "Transaction Signature for commit: ", commitSignature ); // choose a winer const sbRevealIx = await randomness.revealIx(); const revealIx = await program.methods.choseWiner() .accounts({ randomnessAccountData: randomness.pubkey }) .instruction(); const revealTx = await sb.asV0Tx({ connection: switchboardProgram.provider.connection, ixs: [sbRevealIx,revealIx], payer: wallet.publicKey, signers: [wallet.payer], computeUnitPrice: 75_000, computeUnitLimitMultiple: 1.3, }); const revealSignature = await provider.connection.sendTransaction(revealTx); await provider.connection.confirmTransaction({ signature: revealSignature, blockhash: blockhashContext.value.blockhash, lastValidBlockHeight: blockhashContext.value.lastValidBlockHeight }); // await provider.connection.confirmTransaction(revealSignature,"confirmed"); console.log("Transaction Signature revealTx: ", revealSignature); });
Checking account access…