Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Both algodclient objects are necessary, as the params call is application/json and the SDK does not allow by request header assignment
// The TestNet account in this example is U2VHSZL3LNGATL3IBCXFCPBTYSXYZBW2J4OGMPLTA4NA2CB4PR7AW7C77E - PureStake cannot guarantee any funds will exist to execute this example
// To add Algo's - https://bank.testnet.algorand.network
// Updated for v2 1/20/21
const algosdk = require('algosdk');
const baseServer = "https://testnet-algorand.api.purestake.io/ps2"
const port = "";
const token = {
'X-API-key': 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab',
}
const algodclient = new algosdk.Algodv2(token, baseServer, port);
var mnemonic = "code thrive mouse code badge example pride stereo sell viable adjust planet text close erupt embrace nature upon february weekend humble surprise shrug absorb faint";
var recoveredAccount = algosdk.mnemonicToSecretKey(mnemonic);
console.log(recoveredAccount.addr);
(async () => {
//Get the relevant params from the algod
let params = await algodclient.getTransactionParams().do();
// move the TEAL program into Uint8Array
let program = new Uint8Array(Buffer.from("ASABASI=", "base64"));
let lsig = algosdk.makeLogicSig(program);
lsig.sign(recoveredAccount.sk);
//create a transaction
// Algorand Algod (v2) example
// Send transaction on TestNet
const algosdk = require('algosdk');
const baseServer = "https://testnet-algorand.api.purestake.io/ps2";
const port = "";
const token = {
'X-API-key' : 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab',
}
let algodClient = new algosdk.Algodv2(token, baseServer, port);
(async() => {
let params = await algodClient.getTransactionParams().do();
let amount = Math.floor(Math.random() * 1000);
var mnemonic = "code thrive mouse code badge example pride stereo sell viable adjust planet text close erupt embrace nature upon february weekend humble surprise shrug absorb faint";
var recoveredAccount = algosdk.mnemonicToSecretKey(mnemonic);
let txn = {
"from": recoveredAccount.addr,
"to": "UUOB7ZC2IEE4A7JO4WY4TXKXWDFNATM43TL73IZRAFIFFOE6ORPKC7Q62E",
"fee": 1,
"amount": amount,
"firstRound": params.firstRound,
"lastRound": params.lastRound,