Skip to content

Instantly share code, notes, and snippets.

@dcb9
Last active October 7, 2023 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcb9/ec6cd7f58a8af2941955114971ac0f23 to your computer and use it in GitHub Desktop.
Save dcb9/ec6cd7f58a8af2941955114971ac0f23 to your computer and use it in GitHub Desktop.
hardhat ethers parse custom error
const txHash = '0x...';
const contract = await hre.ethers.getContractAt(FIXME);
const tx = await hre.ethers.provider.getTransaction(txHash)
try {
let code = await hre.ethers.provider.call(tx, tx.blockNumber)
} catch (err) {
const code = err.data.replace('Reverted ','');
console.log(code);
console.log(contract.interface.parseError(code));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment