solidity - Error: PollingBlockTracker - encountered an error while attempting to update latest block - Stack Overflow

admin2025-04-21  2

My truffle-config.js:

require("dotenv").config();
const { MNEMONIC, INFURA_PROJECT_ID } = process.env;

const HDWalletProvider = require("@truffle/hdwallet-provider");

module.exports = {


  networks: {
    development: {
      host: "127.0.0.1", // Localhost (default: none)
      port: 8545, // Standard Ethereum port (default: none)
      network_id: "*", // Any network (default: none)
    },
    sepolia: {
      provider: () => new HDWalletProvider(MNEMONIC, `/${INFURA_PROJECT_ID}`),
      network_id: 11155111, 
      gas: 50000000000, 
      confirmations: 2, 
      timeoutBlocks: 200, 
      skipDryRun: true, 
    },
  },

  compilers: {
    solc: {
      version: "0.8.21", 
      settings: {
        optimizer: {
          enabled: false,
          runs: 200,
        },
       
      },
    },
  },

when i try to deploy it using truffle migrate --network sepolia im getting the following error

Compiling your contracts...
===========================
> Compiling @openzeppelin\contracts\access\Ownable.sol
> Compiling @openzeppelin\contracts\interfaces\draft-IERC6093.sol
> Compiling @openzeppelin\contracts\token\ERC20\ERC20.sol
> Compiling @openzeppelin\contracts\token\ERC20\IERC20.sol
> Compiling @openzeppelin\contracts\token\ERC20\extensions\IERC20Metadata.sol
> Compiling @openzeppelin\contracts\utils\Context.sol
> Compiling .\contracts\CysToken.sol
> Compiling .\contracts\Exchange.sol
> Compiling .\contracts\Gugutoken.sol
> Compiling .\contracts\StudentListStorage.sol
> Compiling .\contracts\StudentStorage.sol
> Compiling .\contracts\TpcToken.sol
> Artifacts written to D:\code\web3\vue_web3js\truffle_contracts\build\contracts
> Compiled successfully using:
   - solc: 0.8.21+commit.d9974bed.Emscripten.clang

D:\code\web3\vue_web3js\truffle_contracts\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 (D:\code\web3\vue_web3js\truffle_contracts\node_modules\eth-block-tracker\src\polling.js:51:24)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

The contract compilation was successful, but I'm getting this error during the deployment process. How can I fix this issue?

Specifically, I tried:

  1. Increasing gas limit from 5.5M to 8M
  2. Increasing timeoutBlocks from 200 to 500

But neither of these changes resolved the error.

转载请注明原文地址:http://anycun.com/QandA/1745229307a90510.html