The library can be used to decode contract transactions data. The library uses TypeScript to provide type information for the decoded data, this helps it self document and make it easier for you to use the library.
Using NPM
npm install eth-data-decoder
using Yarn
yarn add eth-data-decoder
import { parseContractABI, decodeTransactionDataProcessor } from 'eth-data-decoder';
const contractABI = parseContractABI(contractABIString);
const decoder = decodeTransactionDataProcessor(contractABI);
// ...
// ...
// ...
// Decode the transaction input
const decodedData = decoder(transaction.input);
// Get the name of the function called
console.log(`Function name: ${decodedData.functionABI.name})`);
// Get the list of the param names and its values
decodedData.params.map(
param =>
console.log(`Name: ${param.abi.name}, Value: ${param.rawValue}));
MIT © 2019 Zohaib Rauf.