Skip to content

[Feature Request] Support for Solidity v0.8.4 Custom Errors #667

Description

@C-Mierez

Greetings,
From the release of Solidity 0.8.4 there's a new preferred way of reporting failures by using Custom Errors when the transaction reverts.

Although full support seems to still be in the works on major Web3 libraries, it would still be nice if TypeChain could generate some types for these. As far I could tell, the current generated .ts files don't create anything related to errors defined in the smart contract.

This kind of feature would be useful for facilitating testing of these smart contracts. In my experience, the current not-so-elegant way to test custom errors is done by hard-coding the custom error names as strings:

  • MyContract: error MyError();
  • Test: await expect(tx).to.revertWith("MyError");

This is where I think TypeChain could potentially make this clearer and streamlined by at least generating the error names:

  • Test: await expect(tx).to.revertWith(myContract.MyError); or similar

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions