# Pure stake API service in javascript

**URL:** <https://forum.algorand.co/t/pure-stake-api-service-in-javascript/3747>\
**Category:** General\
**Tags:** testnet\
**Created:** [July 12, 2021, 6:59am UTC](https://forum.algorand.co/t/pure-stake-api-service-in-javascript/3747 "2021-07-12T06:59:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![harish](https://avatars.discourse-cdn.com/v4/letter/h/47e85d/32.png) [@harish](https://forum.algorand.co/u/harish)\
**Post date:** [July 12, 2021, 6:59am UTC](https://forum.algorand.co/t/pure-stake-api-service-in-javascript/3747/1 "2021-07-12T06:59:48Z")

</div>

I got error in this line  
let params = await algodclient.getTransactionParams();  
console.log(params);  
This line returns [object object].  
Below is the full code:

```auto
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?

​

---

<div class="post-metadata">

**Author:** ![fabrice](https://avatars.discourse-cdn.com/v4/letter/f/5fc32e/32.png) [@fabrice](https://forum.algorand.co/u/fabrice)\
**Post date:** [July 12, 2021, 2:20pm UTC](https://forum.algorand.co/t/pure-stake-api-service-in-javascript/3747/2 "2021-07-12T14:20:17Z")

</div>

If you are using PureStake API, you need to use the code samples there:  
[https://developer.purestake.io/code-samples](https://developer.purestake.io/code-samples)

The way the token is sent in PureStake API is slightly different.
