I got error in this line
let params = await algodclient.getTransactionParams();
console.log(params);
This line returns [object object].
Below is the full code:
const algosdk = require('algosdk');
//Retrieve the token, server, and port values for your installation in the algod.net
//and algod.token files within the data directory or use a standup instance if available
//TestNet
const token = "your token";
const server = "http://your.server";
const port = 8080;
//Recover the account
var mnemonic = "awake used crawl list cruel harvest useful flag essay speed glad salmon camp sudden ride symptom test kind version together project inquiry diet abandon budget";
var recoveredAccount = algosdk.mnemonicToSecretKey(mnemonic);
console.log(recoveredAccount.addr);
//check to see if account is valid
var isValid = algosdk.isValidAddress(recoveredAccount.addr);
console.log("Is this a valid address: " + isValid);
//instantiate the algod wrapper
let algodclient = new algosdk.Algod(token, server, port);
//submit the transaction
(async() => {
//Get the relevant params from the algod
let params = await algodclient.getTransactionParams();
console.log("here" + params);
let endRound = params.lastRound + parseInt(1000);
let fee = await algodclient.suggestedFee();
// create LogicSig object and sign with our secret key
// let program = Uint8Array.from([1, 32, 1, 0, 34]);
// For int 1 use ASABICI=
// int 0 => never transfer money use ASABACI=
let program = new Uint8Array(Buffer.from("ASABICI=", "base64"));
// makeLogicSig method takes the program and parameters
// in this example we have no parameters
// If we did have parameters you would add them like
// let args = [
// Uint8Array.from("123"),
// Uint8Array.from("456")
// ];
// And remember TEAL parameters are order specfic
console.log("program " + program);
let lsig = algosdk.makeLogicSig(program);
// sign the logic with your accounts secret
// key. This is essentially giving your
// key authority to anyone with the lsig
// and if the logic returns true
// exercise extreme care
// If this were a escrow account usage
// you would not do this sign operation
lsig.sign(recoveredAccount.sk);
// At this point you can save the lsig off and share
// as your delegated signature.
// The LogicSig class supports serialization and
// provides the lsig.toByte and fromByte methods
// to easily convert for file saving and
// reconstituting and LogicSig object
//create a transaction
let txn = {
"from": recoveredAccount.addr,
"to": "SOEI4UA72A7ZL5P25GNISSVWW724YABSGZ7GHW5ERV4QKK2XSXLXGXPG5Y",
"fee": params.fee,
"amount": 200000,
"firstRound": params.lastRound,
"lastRound": endRound,
"genesisID": params.genesisID,
"genesisHash": params.genesishashb64
};
// create logic signed transaction.
// Had this been an escrow the lsig would not contain the
// signature but would be submitted the same way
let rawSignedTxn = algosdk.signLogicSigTransaction(txn, lsig);
//Submit the lsig signed transaction
let tx = (await algodclient.sendRawTransaction(rawSignedTxn.blob));
console.log("Transaction : " + tx.txId);
})().catch(e => {
console.log(e);
});
What I have to change?