Revert info is only shown when using local environment
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
Same issue observed with Arbitrum Sepolia testnet
What can we do about this issue?