2

When trying to run truffle migrate --network bsc, truffle usually (not always) manages to deploy the migrations contract, then fails with an error: header not found.

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({ code: -32000, message: 'header not found' })
    at new NodeError (node:internal/errors:363:5)
    at Web3ProviderEngine.emit (node:events:354:17)
    at D:\Contracts\novaria\node_modules\web3-provider-engine\index.js:54:14
    at afterRequest (D:\Contracts\novaria\node_modules\web3-provider-engine\index.js:148:21)
    at D:\Contracts\novaria\node_modules\web3-provider-engine\index.js:174:21
    at D:\Contracts\novaria\node_modules\web3-provider-engine\index.js:232:9
    at D:\Contracts\novaria\node_modules\async\internal\once.js:12:16
    at replenish (D:\Contracts\novaria\node_modules\async\internal\eachOfLimit.js:61:25)
    at D:\Contracts\novaria\node_modules\async\internal\eachOfLimit.js:71:9
    at eachLimit (D:\Contracts\novaria\node_modules\async\eachLimit.js:43:36)
    at D:\Contracts\novaria\node_modules\async\internal\doLimit.js:9:16
    at end (D:\Contracts\novaria\node_modules\web3-provider-engine\index.js:211:5)
    at Request._callback (D:\Contracts\novaria\node_modules\web3-provider-engine\subproviders\rpc.js:70:28)
    at Request.self.callback (D:\Contracts\novaria\node_modules\request\request.js:185:22)
    at Request.emit (node:events:365:28)
    at Request.<anonymous> (D:\Contracts\novaria\node_modules\request\request.js:1154:10)
    at Request.emit (node:events:365:28)
    at IncomingMessage.<anonymous> (D:\Contracts\novaria\node_modules\request\request.js:1076:12)
    at Object.onceWrapper (node:events:471:28)
    at IncomingMessage.emit (node:events:377:35)
    at endReadableNT (node:internal/streams/readable:1312:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

Here's the config for bsc network:

   bsc: {
      provider: () => { return new HDWalletProvider(mnemonic, `https://bsc-dataseed2.binance.org/`)},
      network_id: 56,
      confirmations: 10,
      timeoutBlocks: 200,
      skipDryRun: true,
    },

 compilers: {
    solc: {
      version: "0.8.7",    // Fetch exact version from solc-bin (default: truffle's version)
      // docker: true,        // Use "0.5.1" you've installed locally with docker (default: false)
      settings: {          // See the solidity docs for advice about optimization and evmVersion
       optimizer: {
         enabled: true,
         runs: 200
       },

Deploying to testnet and development works without issue. I have in the past deployed to bsc with truffle (been a while though). I've tried changing RPC urls, and messed around with timeout and confirmations (pretty sure that doesn't make a difference for this error). After searching the internet for solutions, the only answer that seems to have worked for people is to change the RPC, but I haven't had any luck with that. Does anyone have any suggestions?

Nate F
  • 23
  • 3

1 Answers1

1

I had the same problem today. Fixed it by using the Websocket endpoint wss://bsc-ws-node.nariox.org:443 from the smart chain docs https://docs.binance.org/smart-chain/developer/rpc.html

  • 1
    This worked for me, so I definitely appreciate it. I do still wonder what the deeper issue is. One forum I viewed suggested it had something to do with the interactions between truffle and hardhat, but it also seems weird that all the normal RPCs are having an issue but the community endpoint works? I also just tried using the https://bscrpc.com endpoint, and it also seems to work. – Nate F Mar 03 '22 at 15:06