0

I have a Truffle migration that deploys and configures a set of smart contracts on BSC (Binance Smart Chain).

When running the migration on the actual network, it works fine.

However, when I try to run the exact same migration through ganache-cli on a network fork, one of the transactions reverts:

Error: Returned error: VM Exception while processing transaction: revert

(The fork is handy and used for development, testing, and continuous integration.)

Here some of the common/relevant issues checked:

  • There is enough ETH (actually BNB) on the migration wallet;
  • No contracts exceed the size limit;
  • Increasing both transaction and block gas limits;

As there are common pitfalls when using ganache-cli, I wonder if one of them could be the possible reasons for the reversal.

I have also tried to make it print a better error message/stack trace, but the truffle --stacktrace-extra flag had no effect on that.

Any possible suggestions on how to further investigate that?

Here is how I start ganache-cli:

npx ganache-cli \
    -q \
    -h 0.0.0.0 \
    -i 56 \
    --chainId 56 \
    -l 100000000 \
    -f https://bsc-dataseed.binance.org/ \
    --account $PRIVATE_KEY,100000000000000000000000

And here is my truffle-config.js:

require('dotenv').config();
const HDWalletProvider = require('@truffle/hdwallet-provider');
const privateKey = process.env['PRIVATE_KEY'];

module.exports = {
  compilers: {
    solc: {
      version: '0.6.12',
      optimizer: {
        enabled: false,
        runs: 200,
      },
    },
  },
  networks: {
    bscmain: {
      network_id: 56,
      networkCheckTimeout: 10000,
      provider: () => new HDWalletProvider(privateKey, 'wss://bsc-dataseed.binance.org/'),
      skipDryRun: false,
    },
    development: {
      network_id: '*',
      gas: 10000000,
      host: 'localhost',
      port: 8545,
      skipDryRun: true,
    },
  },
};

I am running ganache-cli version 6.12.2.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.