@nomiclabs/buidler
Version:
Buidler is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
13 lines (9 loc) • 328 B
text/typescript
import { rawDecode } from "ethereumjs-abi";
export function decodeRevertReason(returnData: Buffer): string {
if (returnData.length === 0) {
return "";
}
// TODO: What should happen if the reason fails to be decoded?
const decoded = rawDecode(["string"], returnData.slice(4));
return decoded.toString("utf8");
}