0

I'm trying to deploy a contract on Avalanche Fuji testnet using Truffle. Here is my truffle config:

require('dotenv').config();
const mnemonic = process.env["MNEMONIC"];
const infuraUrl = process.env["INFURA_URL"]; //https://avalanche-fuji.infura.io/v3/...
 
const HDWalletProvider = require('@truffle/hdwallet-provider');

module.exports = {

  networks: {
    development: {
      host: "127.0.0.1",
      port: 8545,
      network_id: "*"
    },
    fuji: {
      provider: () => new HDWalletProvider(mnemonic, infuraUrl),
      network_id: "43113",
      gas: 5000000,
      networkCheckTimeout: 1000000,    
      timeoutBlocks: 200,
    }
  },
  ...
  }
};

When I run truffle migrate --network fuji, I get the following error:

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.

/Users/me/Projects/myProject/node_modules/eth-block-tracker/src/polling.js:51
        const newErr = new Error(`PollingBlockTracker - encountered an error while attempting to update latest block:\n${err.stack}`)
                       ^
Error: PollingBlockTracker - encountered an error while attempting to update latest block:
undefined
    at PollingBlockTracker._performSync (/Users/me/Projects/myProject/node_modules/eth-block-tracker/src/polling.js:51:24)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at listOnTimeout (node:internal/timers:540:9)
    at processTimers (node:internal/timers:514:7)
UnhandledRejections detected
Promise {
  <rejected> {
    code: -32603,
    message: 'Socket connection timeout',
    data: { originalError: [Object] }
  }
} {
  code: -32603,
  message: 'Socket connection timeout',
  data: { originalError: { code: 'ERR_SOCKET_CONNECTION_TIMEOUT' } }
}
...

Some people mentioned its the internet speed but the internet speed at my place is very fast. Does anyone know what the issue is? Is it the Infuria API?

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
code_learner93
  • 571
  • 5
  • 12

2 Answers2

1

There might be many reasons

  • your infuraUrl is either undefined or you did not paste the correct url.

  • it might be dns issue. try to change the dns provider

  • your infura node might go down. Infura sometimes suffers from outage

Yilmaz
  • 35,338
  • 10
  • 157
  • 202
0

Just to follow up if anyone else is facing a similar issue. I tried creating another Infura API, double checked that my API endpoint is not undefined, double checked everything, but to no avail. Another part of the error message which I didnt include in the original post is:

Error: Cannot find module '../binaries/uws_darwin_arm64_115.node'
Require stack:
- /Users/me/.nvm/versions/node/v20.2.0/lib/node_modules/truffle/node_modules/ganache/node_modules/@trufflesuite/uws-js-unofficial/src/uws.js
- /Users/me/.nvm/versions/node/v20.2.0/lib/node_modules/truffle/node_modules/ganache/dist/node/core.js
- /Users/me/.nvm/versions/node/v20.2.0/lib/node_modules/truffle/build/migrate.bundled.js
- /Users/me/.nvm/versions/node/v20.2.0/lib/node_modules/truffle/node_modules/original-require/index.js
- /Users/me/.nvm/versions/node/v20.2.0/lib/node_modules/truffle/build/cli.bundled.js
Falling back to a NodeJS implementation; performance may be degraded.

I just ran the following and reinstalled Truffle and it resolved the error

nvm install --lts   
nvm use --lts

I was running Node v20.2.0 and Truffle v5.9.0 but doing the above changed them to Node v18.16.0 and Truffle v5.9.1 and it worked. Contract is successfully deployed :)

code_learner93
  • 571
  • 5
  • 12