title: Blockhash not found when sending transaction
body: <p>When sending a transaction using Solana web3, it sometimes shows this error:<br />
  <code>Error: failed to send transaction: Transaction simulation failed: Blockhash not found</code></p>
  <p>What is the proper way of dealing with this error other than retrying for <em>x</em> amount of times?<br />
  Is there a way to guarantee this issue won't happen when sending transactions?</p>
  <p>Here is an example of how I'm sending a transaction:</p>
  <pre class="lang-js prettyprint-override"><code>const web3 = require(&quot;@solana/web3.js&quot;)
  const bs58 = require('bs58')
  
  const publicKey = new web3.PublicKey(new Uint8Array(bs58.decode(&quot;BASE_58_PUBLIC_KEY&quot;).toJSON().data))
  const secretKey = new Uint8Array(bs58.decode(&quot;BASE_58_SECRET_KEY&quot;).toJSON().data)
  
  const connection = new web3.Connection(
    &quot;https://api.mainnet-beta.solana.com&quot;, &quot;finalized&quot;,
    {
      commitment: &quot;finalized&quot;,
      confirmTransactionInitialTimeout: 30000
    }
  )
  const transaction = new web3.Transaction().add(
    web3.SystemProgram.transfer({
      fromPubkey: publicKey,
      toPubkey: publicKey,
      lamports: 1
    })
  )
  web3.sendAndConfirmTransaction(
    connection,
    transaction,
    [{publicKey: publicKey, secretKey: secretKey}],
    {commitment: &quot;finalized&quot;}
  )
  
  
  </code></pre>
  <p>How can I improve this to avoid the <code>Blockhash not found</code> error?</p>