Truffle
當我將智能合約部署到 BSC 時,稱為“程式碼:-32000,消息:‘找不到標頭’”的錯誤是什麼?
我只是被這個錯誤所困擾,如下所示;錯誤
$$ ERR_UNHANDLED_ERROR $$: 未處理的錯誤。({程式碼:-32000,消息:‘找不到標題’}) 我不知道我為什麼會得到這個,因為我可以看到我的智能合約在 BSC 測試網路上很好,但在 BSC 主網路上卻不行。
(我正在使用松露來部署我的契約)
該錯誤是在 1_initial_migration 之後引起的
1_initial_migration.js ====================== Deploying 'Migrations' ---------------------- > transaction hash: 0x6327d076f8bf47eb2b464ded537ff2bf35decae888ab305331cedd725e8bf91e > Blocks: 5 Seconds: 13 > contract address: 0xaa4edCFFfe2F25CAef66225Ac435207dafc31191 > block number: 12407665 > block timestamp: 1636174466 > account: 0xFD901af64871036e3be2Cc5412529c9286bE511E > balance: 0.69776911 > gas used: 201831 (0x31467) > gas price: 5 gwei > value sent: 0 ETH > total cost: 0.001009155 ETH Pausing for 10 confirmations... ------------------------------- > confirmation number: 2 (block: 12407668) > confirmation number: 3 (block: 12407669) Error [ERR_UNHANDLED_ERROR]: Unhandled error. ({ code: -32000, message: 'header not found' }) at new NodeError (internal/errors.js:322:7) at Web3ProviderEngine.emit (events.js:389:17) .....
松露-config.js
const HDWalletProvider = require('@truffle/hdwallet-provider'); const fs = require('fs'); const mnemonic = fs.readFileSync(".secret").toString().trim(); const path = require("path"); module.exports = { contracts_build_directory: path.join(__dirname, "client/src/contracts"), networks: { development: { host: "127.0.0.1", // Localhost (default: none) port: 8545, // Standard BSC port (default: none) network_id: "*", // Any network (default: none) }, testnet: { provider: () => new HDWalletProvider(mnemonic, `https://data-seed-prebsc-1-s1.binance.org:8545`), network_id: 97, confirmations: 10, timeoutBlocks: 200, skipDryRun: false }, bsc: { provider: () => new HDWalletProvider(mnemonic, `https://bsc-dataseed1.binance.org`), network_id: 56, confirmations: 10, timeoutBlocks: 200, skipDryRun: true }, }, // Set default mocha options here, use special reporters etc. mocha: { // timeout: 100000 }, // Configure your compilers compilers: { solc: { version: "^0.8.0", // A version or constraint - Ex. "^0.5.0" } } }
你能幫幫我嗎?
將 RPC 伺服器更改為: truffle-config.js 中的https://bsc-dataseed2.binance.org(而不是 dataseed1)…我遇到了同樣的問題,這解決了它!