Truffle – Error Code -32000 ‘Header Not Found’ When Deploying Smart Contracts on BSC

bsccontract-deploymenttruffletruffle-deployment

I am just stuck with this error as follow;
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({ code: -32000, message: 'header not found' })

I have no idea of any reason why I got this since I could see my smart contracts were fine with the BSC test net, but not the BSC main net.

(I am using truffle to deploy my contracts)

The error is caused after 1_initial_migration

1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------
   > transaction hash:    0x6327d076f8bf47eb2b464ded537ff2bf35decae888ab305331cedd725e8bf91e
   > Blocks: 5            Seconds: 13
   > contract address:    0xaa4edCFFfe2F25CAef66225Ac435207dafc31191
   > block number:        12407665
   > block timestamp:     1636174466
   > account:             0xFD901af64871036e3be2Cc5412529c9286bE511E
   > balance:             0.69776911
   > gas used:            201831 (0x31467)
   > gas price:           5 gwei
   > value sent:          0 ETH
   > total cost:          0.001009155 ETH

   Pausing for 10 confirmations...
   -------------------------------
   > confirmation number: 2 (block: 12407668)
   > confirmation number: 3 (block: 12407669)
Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({ code: -32000, message: 'header not found' })
    at new NodeError (internal/errors.js:322:7)
    at Web3ProviderEngine.emit (events.js:389:17)
.....

truffle-config.js

const HDWalletProvider = require('@truffle/hdwallet-provider');
const fs = require('fs');
const mnemonic = fs.readFileSync(".secret").toString().trim();
const path = require("path");

module.exports = {
   contracts_build_directory: path.join(__dirname, "client/src/contracts"),
  networks: {
    development: {
      host: "127.0.0.1",     // Localhost (default: none)
      port: 8545,            // Standard BSC port (default: none)
      network_id: "*",       // Any network (default: none)
    },
    testnet: {
      provider: () => new HDWalletProvider(mnemonic, `https://data-seed-prebsc-1-s1.binance.org:8545`),
      network_id: 97,
      confirmations: 10,
      timeoutBlocks: 200,
      skipDryRun: false
    },
    bsc: {
      provider: () => new HDWalletProvider(mnemonic, `https://bsc-dataseed1.binance.org`),
      network_id: 56,
      confirmations: 10,
      timeoutBlocks: 200,
      skipDryRun: true
    },
  },

  // Set default mocha options here, use special reporters etc.
  mocha: {
    // timeout: 100000
  },

  // Configure your compilers
  compilers: {
    solc: {
      version: "^0.8.0", // A version or constraint - Ex. "^0.5.0"
    }
  }
}

would you please help me out ?

Best Answer

Change RPC server to: https://bsc-dataseed2.binance.org in truffle-config.js (instead of dataseed1)... I had the same problem and this resolved it!

Related Topic