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  = "https://testnet-algorand.api.purestake.io/ps1";
const newServer    = "https://testnet-algorand.api.purestake.io/ps2";
const indexServer   = "https://testnet-algorand.api.purestake.io/idx2";

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,
        "to": "AXTW46L6EPL4V7XSJAR7X24ATUM4N43BA6HQT3IBG3RS6GZCOBJNR735NI",
        "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, recoveredAccount.sk);
    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: https://bank.testnet.algorand.network/

You can use a block explorer to see the balance of any account: https://developer.algorand.org/docs/community/#block-explorers

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