when i try the following code, my transaction is already get rejected by the logic. I don’t know where is the mistake
let teal= “#pragma version 4\n” +
“txn TxID\n” +
“arg 0\n” +
“addr BJRLVGSFC4IDXEB2B3GJ62QRJAHDDZW7JBWLSUFQ2DUD3IRNC4DHX6XELM\n” +
“ed25519verify”;
let results = await algodClient.compile(teal).do();
const program = new Uint8Array(Buffer.from(results.result , "base64"));
let m ="manage erode connect disagree scene auction close oil assume yard ride rapid brush assume gossip match find south deposit snake access endless stove absent ski"
let hp = algosdk.mnemonicToSecretKey(m);
// Use PureStake API V2 server
const x_api_key = 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab';
const token =
{
'X-API-Key': x_api_key
};
const server = "https://testnet-algorand.api.purestake.io/ps2";
const serverIdx = "https://testnet-algorand.api.purestake.io/idx2";
const port = "";
// Instantiate the algod wrapper
let algodClient = new algosdk.Algodv2(token, server, port);
let indexerClient = new algosdk.Indexer(token, serverIdx, port);
// Function used to wait for a tx confirmation
async function waitForConfirmation(algodclient, txId) {
let response = await algodclient.status().do();
let lastround = response["last-round"];
while (true) {
const pendingInfo = await algodclient.pendingTransactionInformation(txId).do();
if (pendingInfo["confirmed-round"] !== null && pendingInfo["confirmed-round"] > 0) {
//Got the completed Transaction
console.log("Transaction " + txId + " confirmed in round " + pendingInfo["confirmed-round"]);
break;
}
lastround++;
await algodclient.statusAfterBlock(lastround).do();
}
};
// Sample program for ed25519verify
async function ed25519verify_sample() {
let teal= `
#pragma version 3
txn TxID
arg 0
addr BJRLVGSFC4IDXEB2B3GJ62QRJAHDDZW7JBWLSUFQ2DUD3IRNC4DHX6XELM
ed25519verify
`;
let results = await algodClient.compile(teal).do();
//const program = new Uint8Array(Buffer.from(results.result , "base64"));
let buff = base64js.toByteArray(results.result);
let program = new Uint8Array(buff);
let m ="manage erode connect disagree scene auction close oil assume yard ride rapid brush assume gossip match find south deposit snake access endless stove absent ski"
let hp = algosdk.mnemonicToSecretKey(m);
let lsig = algosdk.makeLogicSig(program);
let sender = lsig.address();
let receiver = "6MNC6JZIQLEDRAPGGTO464O4HQ6B5KAF6YXIX52MSVODE2DC33LOI3NY7M";
let amount = 0;
let closeToRemaninder = undefined;
let note = undefined;
let params = await algodClient.getTransactionParams().do();
let txn = algosdk.makePaymentTxnWithSuggestedParams(sender, receiver, amount, closeToRemaninder, note, params);
console.log("transaction id", txn.txID());
let signature = algosdk.tealSignFromProgram(hp.sk, new Uint8Array(txn.rawTxID()), program);
let args = [signature];
let lsig2 = algosdk.makeLogicSig(program, args);
let rawSignedTxn = algosdk.signLogicSigTransactionObject(txn, lsig2);
let tx = await algodClient.sendRawTransaction(rawSignedTxn.blob).do();
console.log('transaction id: ', tx.txId);
await waitForConfirmation(algodClient, tx.txId);
}
ed25519verify_sample();