Skip to content

Web3 Errors Extract is a TypeScript implementation of the Ethereum JSON RPC API to get/extract EVM-based web3 transaction revert messages or any other errors.

Notifications You must be signed in to change notification settings

moazzamgodil/web3-errors-extract

Repository files navigation

Web3 Errors Extract

npm package Downloads Issues ES Version Node Version

Web3 Errors Extract is a TypeScript implementation of the Ethereum JSON RPC API to get/extract EVM-based web3 transaction revert messages or any other errors.

Installation

You can install the package using NPM

Using NPM

npm install web3-errors-extract

Using Yarn

yarn add web3-errors-extract

Getting Started

Prerequisites

Usage

const { Web3errors } = require("web3-errors-extract");

OR

import { Web3errors } from "web3-errors-extract";
const ABI1 = [{
    "type":"function",
    "name":"foo",
    "inputs": [{"name":"a","type":"uint256"}],
    "outputs": [{"name":"b","type":"address"}]
},{
    "type":"event",
    "name":"Event",
    "inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"bytes32","indexed":false}],
}]

const ABI2 = [{
    "type":"function",
    "name":"foo",
    "inputs": [{"name":"a","type":"uint256"}],
    "outputs": [{"name":"b","type":"address"}]
},{
    "type":"event",
    "name":"Event",
    "inputs": [{"name":"a","type":"uint256","indexed":true},{"name":"b","type":"bytes32","indexed":false}],
}]

const err = new Web3errors("YOUR RPC URL OR PROVIDER", [ABI1, ABI2] /* OPTIONAL ARRAY OF ABIs */);
/*
 * Get an error message for a specific tx hash
 */
err.getErrOfTx("0x1234......fff").then(console.log).catch(console.error);
/*
 * Get an error message by providing an exception error object of any blockchain (send or call) tx you received in return
 */
err.getErrorMessage(EXCEPTION ERROR OBJECT).then(console.log).catch(console.error);

About

Web3 Errors Extract is a TypeScript implementation of the Ethereum JSON RPC API to get/extract EVM-based web3 transaction revert messages or any other errors.

Resources

Stars

Watchers

Forks

Packages

No packages published