Last active
October 7, 2023 13:51
-
-
Save dcb9/ec6cd7f58a8af2941955114971ac0f23 to your computer and use it in GitHub Desktop.
hardhat ethers parse custom error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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