Skip to content

Fix truffle-plugin-verify for --via-ir (viaIR: true) compiler settings

License

Notifications You must be signed in to change notification settings

an-ivannikov/fix-truffle-plugin-verify-for-via-ir

Repository files navigation

Fix truffle-plugin-verify for --via-ir (viaIR: true) compiler settings

Postinstall fix for [email protected].

The problem and solution are described here: github.com/rkalis/truffle-plugin-verify/issues/181

Problem

When using the --via-ir (viaIR: true) compiler option, the plugin cannot verify the smart contract and produces this error:

Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.

Solution

Automatic file replacement called by postinstall script.

Copy the files /scripts/fix-truffle-plugin-verify-for-via-ir.js and /scripts/data/util.js into your project and upgrade the package.json.

  ...
  "scripts": {
    "postinstall": "node ./scripts/fix-truffle-plugin-verify-for-via-ir.js",
    ...
  },
  ...

Proof

Verified smart contract.

Install dependencies

yarn install

Compile, test, deploy and verify Smart Contracts

Compiler options are defined in the file /truffle-config.js.

Compile Smart Contracts

After successful compilation, smart contract appear in /flatten folder, which already include all dependencies in one file.

yarn compile

Test Smart Contracts

In a different terminal:

yarn ganache
yarn test
yarn deploy development

Deploy Smart Contracts

Make /.env file from /.env.example. Fill in the environment variable data:

yarn deploy sepolia

Verify Smart Contracts

yarn verify sepolia Migrations

About

Fix truffle-plugin-verify for --via-ir (viaIR: true) compiler settings

Topics

Resources

License

Stars

Watchers

Forks