2

我在 Solidity 0.6.6 中编写了一个简单的智能合约,我正试图将其部署到 BSC 测试网。

这就是我在 truffle-config.js 文件中的内容(privateKeys 是一个数组,其中包含单个条目 ['0x + privatekey']:

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

当我运行命令“truffle migrate --reset --network bscTestnet”时,我收到以下错误:

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



Starting migrations...
======================
> Network name:    'bscTestnet'
> Network id:      97
> Block gas limit: 30000000 (0x1c9c380)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------

Error:  *** Deployment Failed ***

"Migrations" -- cb is not a function.

    at /Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at Migration._deploy (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:70:1)
    at Migration._load (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:56:1)
    at Migration.run (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217:1)
    at Object.runMigrations (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.runAll (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
    at Object.run (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
    at runMigrations (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:80:1)
    at Object.module.exports [as run] (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:44:1)
    at Command.run (/Users/admin/.nvm/versions/node/v17.4.0/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:189:1)
Truffle v5.4.31 (core: 5.4.31)
Node v17.4.0
4

2 回答 2

7

打开了一个关于它的问题:https ://github.com/trufflesuite/truffle/issues/4676 我猜它是 HardwareWallet2.0.2 中的一个错误。恢复到 HardwareWallet2.0.0 为我解决了这个问题

npm i @truffle/hdwallet-provider@2.0.0

于 2022-01-30T17:17:21.703 回答
1

更新:对,解决方法:我将@HDWalletProvider 回滚到 v2.0.1 并且能够迁移。

我认为今天更新的 ppl 的新版本一定有问题。

=================

Polygon Mumbai 也有同样的问题。

函数“cb”指的是回调函数。奇怪的是错误消息根本没有引用我自己的代码;它引用了位于以下位置的 migrations.js:

<.nvm/versions/node/v16.11.1/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1 at processTicksAndRejections (node:internal/process/task_queues:96:5 >

这让我相信 1_initial_migration.js 存在问题......但是这是自动生成的,所以我看不到任何问题......这很奇怪。

1_initial_migration.js:

const Migrations = artifacts.require("Migrations");

module.exports = function(deployer) {
  deployer.deploy(Migrations);
};
于 2022-01-30T17:04:40.480 回答