ethers.js icon indicating copy to clipboard operation
ethers.js copied to clipboard

Revert info is only shown when using local environment

Open tab00 opened this issue 2 years ago • 2 comments

Ethers Version

6.9.0

Describe the Problem

When a revert occurs in a local environment (hardhat or localhost) error name and arguments are output to the terminal as expected.

e.g.

ProviderError: Error: VM Exception while processing transaction: reverted with custom error 'AnError("0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266")'

However, when a revert occurs in a testnet environment, we get:

ProviderError: execution reverted

but no error name or arguments, making it difficult to solve the problem.

I tried on Avalanche Fuji and BSC testnets.

Code Snippet

Undeployable.sol:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.23;

contract Undeployable
{
    error AnError(address account);

    constructor() {
        revert AnError(msg.sender);
    }
}

deploy.js:

import { ethers } from "hardhat"

async function main() {
  const instance = await ethers.deployContract("Undeployable")
 
  await instance.waitForDeployment()
}

main().catch(error => {
  console.error(error)
  process.exitCode = 1
})

hardhat.config.ts:

import "dotenv/config"
import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";

const accounts = [process.env.PRIVATE_KEY]

const config: HardhatUserConfig = {
  solidity: { 
    compilers: [
      {
        version: `0.8.23`,
        settings: {
          optimizer: {
            enabled: true,
            runs: 200
          },
          evmVersion: `paris`,
        }
      },
    ],
  },
  networks: {
    avalancheFujiTestnet: {
      url: "https://api.avax-test.network/ext/bc/C/rpc",
      accounts,
    },
  },
};

export default config;

package.json:

{
  "devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^4.0.0",
    "dotenv": "^16.3.1",
    "ethers": "^6.9.0",
    "hardhat": "^2.19.2",
    "ts-node": "^10.9.2",
    "typescript": "^5.3.3"
  },
}

Environment

node.js v20, Hardhat v2.19.2

tab00 avatar Dec 09 '23 10:12 tab00

Same issue observed with Arbitrum Sepolia testnet

0xdefime avatar Dec 13 '23 16:12 0xdefime

What can we do about this issue?

tab00 avatar Dec 19 '23 18:12 tab00