Solana mainnet block height exceeded for transactions with `TransactionExpiredBlockheightExceededError` error

614 views Asked by At

I am trying write a simple program to send some SOL from one wallet to another. I keep running into TransactionExpiredBlockheightExceededError on sendAndConfirmTransaction.

Interestingly, this works fine on Devnet but fails on Mainnet.

Error:

TransactionExpiredBlockheightExceededError: Signature <signature> has expired: block height exceeded.

Here is my exiting code:

const fromKeypair = Keypair.fromSecretKey(new Uint8Array(from_wallet_secret));
const toKeypair = Keypair.fromSecretKey(new Uint8Array(to_wallet__secret));

const PRIORITY_RATE = 100; // MICRO_LAMPORTS 
const SEND_AMT = 0.01 * LAMPORTS_PER_SOL;
const PRIORITY_FEE_IX = ComputeBudgetProgram.setComputeUnitPrice({microLamports: PRIORITY_RATE});

function generateTxExample() {
    return new Transaction().add(SystemProgram.transfer({
        fromPubkey: fromKeypair.publicKey,
        toPubkey: toKeypair.publicKey,
        lamports: SEND_AMT
    }));
}

async function createAndSendTransactions() {
    const txPriority = generateTxExample().add(PRIORITY_FEE_IX);
    const { blockhash, lastValidBlockHeight } = await SOLANA_CONNECTION.getLatestBlockhash();
    txPriority.recentBlockhash = blockhash;
    txPriority.lastValidBlockHeight = lastValidBlockHeight;

    sendAndConfirmTransaction(SOLANA_CONNECTION,txPriority,[fromKeypair]);
   
}

createAndSendTransactions();

  • I tried added priority fee to make sure the transaction gets through but no luck.

This works well on devnet so not sure what am I missing to make this work on mainnet.

0

There are 0 answers