5

I need to deploy my smart contract to BSC Testnet

I always got this :

Error: PollingBlockTracker - encountered an error while attempting to update latest block:
Error: ETIMEDOUT
I tried to change the RPC specified here https://docs.binance.org/smart-chain/developer/rpc.html#rate-limit

All of them, yet still the same.

One thing is, I tried to deploy it to ropsten instead just for fun. And it is success. Is there any problem with BSC Testnet RPC nowadays ?

Here is my snip for truffle-config.js

        testnet: {
            provider: () => new HDWalletProvider(mnemonic, `https://data-seed-prebsc-1-s2.binance.org:8545`),
            network_id: 97, // 3 for ropsten, 97 for bsc test
            confirmations: 2,
            timeoutBlocks: 2000,
            skipDryRun: true,
            networkCheckTimeout: 1000000
        },

I searched, some people use websocket (wss), some change the RPC Url, some add the networkCheckTimeout. I tried all of them (except wss, since I don't see it is provided by BSC Testnet). But nothing work.

Any suggestion ? Thank you

Lyn
  • 151
  • 1
  • 3

3 Answers3

11

If you compile a lot of files, truffle ask for the lastest block. Since BSC testnet limits the amount of request you can make, it hangs and then you get a timeout. I solved this issue just compiling my code first and for deploy, using --compile-none.

truffle deploy --network testnet --reset --compile-none
Luiz Soares
  • 1,064
  • 6
  • 14
  • 1
    Thank you for the response. I might try it when there is another chance. For now, I had abandoned truffle and use remix instead. No problem at all with remix and somehow, it is also faster. So, I dont think I'll be back to use truffle for a while. – Lyn May 28 '21 at 00:25
  • Seriously truffle got an issue. Correct that remix will work without an issue but not truffle. – NinjaMAN Aug 16 '21 at 08:03
0

The problem is that BSC produces blocks so quickly that it exceeds the default number of blocks Truffle is configured to wait for. You can solve this by adding the networkCheckTimeout and timeoutBlocks fields in your network config:

bsc: {
  networkCheckTimeout: 1000000,
  timeoutBlocks: 200
}
Paul Razvan Berg
  • 17,902
  • 6
  • 73
  • 143
0

I had the same problem. I recreated the project, but this time I downloaded npm install @truffle/hdwallet-provider before truffle init.

Also make sure your bscTestnet in networks section of truffle-config.js file looks like this:

    bscTestnet: {
      provider: () => new HDWalletProvider(
        privateKeys,
        'https://data-seed-prebsc-1-s1.binance.org:8545/'
      ),
      network_id: 97,
      skipDryRun: true
    }
Abdulhakim
  • 201
  • 1
  • 6