TransactionPool.Remember: transaction MKEODIGHN454…Uint:0 NumByteSlice:0}}, tried to spend {247000}

I am trying to post a test transaction to the chain getting this error. I am using Purestake and Algo SDK for javascript. Here is my code

const legacyServer  = "";
const newServer    = "";
const indexServer   = "";

const port = "";

const token = {
    'X-API-key' : 'b0r9BtPAG64Adngz6DO6e6wo4FhQenSw1OUpXLHT',

let algodClient     = new algosdk.Algod(token, legacyServer, port);
let algodClientV2   = new algosdk.Algodv2(token, newServer, port);
let indexerClient   = new algosdk.Indexer(token, indexServer, port);

async function sendtrx (){
    let params = await algodClientV2.getTransactionParams().do();
    let amount =  1000000;
    var mnemonic = "XXX-XXX-YYY"; 
    var recoveredAccount = algosdk.mnemonicToSecretKey(mnemonic); 
    document.getElementById("examples").value = JSON.stringify(recoveredAccount.addr)
    let txn = {
        "from": recoveredAccount.addr,
        "fee": 1000,
        "amount": amount,
        "firstRound": params.firstRound,
        "lastRound": params.lastRound,
        "genesisID": params.genesisID,
        "genesisHash": params.genesisHash,
        "note": new Uint8Array(0),
        "type": "pay",
    let signedTxn = algosdk.signTransaction(txn2,;
    let sendTx = await algodClientV2.sendRawTransaction(signedTxn.blob).do();
    console.log("Transaction : " + sendTx.txId);

I will appreciate any help

Is the send account funded?

Also, in the signing step you refer to txn2 but are declaring txn above.

As @Tim mentioned, this error most likely indicates that the balance of the the sender is too low.

On TestNet, you can use the dispenser to fund any account:

You can use a block explorer to see the balance of any account:

Side note: I edited your post so that the code is inside triple backquotes ``` which displays the code in a nicer way.