Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// DEPRECATED 12/30/20 with Algod v1 API Shutdown
const algosdk = require('algosdk');
const baseServer = "https://testnet-algorand.api.purestake.io/ps1"
const port = "";
const token = {
'X-API-key' : 'B3SU4KcVKi94Jap2VXkK83xx38bsv95K5UZm2lab',
}
const algodclient = new algosdk.Algod(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() => {
let params = await algodclient.getTransactionParams();
let endRound = params.lastRound + parseInt(1000);
let txn = {
"from": recoveredAccount.addr,
"to": "AEC4WDHXCDF4B5LBNXXRTB3IJTVJSWUZ4VJ4THPU2QGRJGTA3MIDFN3CQA",
"fee": 10,
"amount": 2,
"firstRound": params.lastRound,
"lastRound": endRound,
"genesisID": params.genesisID,
// 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
let txn = {
"from": recoveredAccount.addr,
"to": "SOEI4UA72A7ZL5P25GNISSVWW724YABSGZ7GHW5ERV4QKK2XSXLXGXPG5Y",
(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,
"genesisID": params.genesisID,
"genesisHash": params.genesisHash,
"note": new Uint8Array(0),
};
let signedTxn = algosdk.signTransaction(txn, recoveredAccount.sk);
let sendTx = await algodClient.sendRawTransaction(signedTxn.blob).do();