簡體   English   中英

錯誤:PollingBlockTracker - 嘗試更新最新區塊時遇到錯誤:未定義

[英]Error: PollingBlockTracker - encountered an error while attempting to update latest block: undefined

我正在嘗試在多邊形區塊鏈上開發 DApp。 基本上我正在鑄造 NFT,但在鑄造了幾次之后我得到了這個錯誤。 它甚至發生在我不鑄造 NFT 的時候。 這是我的代碼。

const Web3 = require("web3")
const fs = require("fs")
var HDWalletProvider = require("@truffle/hdwallet-provider");
var provider = new HDWalletProvider(SECRET_PHRASE, "https://rpc-mumbai.maticvigil.com")
const web3 = new Web3(provider)
const constractJSON = JSON.parse(fs.readFileSync(`${process.cwd()}/contracts/Collection.json`))
const abi = constractJSON["abi"]
const byteCode = constractJSON["byteCode"]["object"]





const mintNFT = async (contractAddress,tokenURI,to) => {

    const contract = await new web3.eth.Contract(abi, contractAddress)    

    const result = await contract.methods.claimItem(tokenURI,to).send({from: WALLET_ADDRESS,gasLimit:6000000},)  
}

module.exports = mintNFT

這是完整的錯誤。

mint_service_1  | /usr/src/app/node_modules/safe-event-emitter/index.js:74
mint_service_1  |       throw err
mint_service_1  |       ^
mint_service_1  |
mint_service_1  | Error: PollingBlockTracker - encountered an error while attempting to update latest block:
mint_service_1  | undefined
mint_service_1  |     at PollingBlockTracker._performSync (/usr/src/app/node_modules/eth-block-tracker/src/polling.js:51:24)
mint_service_1  |     at processTicksAndRejections (node:internal/process/task_queues:96:5)
mint_service_1  | Emitted 'error' event on Web3ProviderEngine instance at:
mint_service_1  |     at safeApply (/usr/src/app/node_modules/safe-event-emitter/index.js:70:5)
mint_service_1  |     at PollingBlockTracker.SafeEventEmitter.emit (/usr/src/app/node_modules/safe-event-emitter/index.js:56:5)
mint_service_1  |     at PollingBlockTracker._performSync (/usr/src/app/node_modules/eth-block-tracker/src/polling.js:53:16)
mint_service_1  |     at processTicksAndRejections (node:internal/process/task_queues:96:5)

我遇到了同樣的問題。 您可以在下面看到錯誤日志

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/buuthongtran/Downloads/FlightSurety/node_modules/eth-block-tracker/src/polling.js:51:24)
        at processTicksAndRejections (internal/process/task_queues.js:95:5)
    npm ERR! Test failed.  See above for more details.

我發現我在運行 truffle 測試之前忘記啟動 Ganache,所以我嘗試啟動 Ganache 並輸入正確的助記符和端口。 之后問題就消失了。

將此networkCheckTimeout: 10000添加到truffle.config.js

goerli: {
  networkCheckTimeout: 10000,
  provider: () =>
    new HDWalletProvider(PRIVATE_KEY, INFURA_GOERLI_URL),
  network_id: 5,
  gas: 5500000,
  gasPrice: 20000000000,
  confirmations: 2,
  timeoutBlocks: 200,
},

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM