0.0.2 • Published 5 years ago
eth-data-decoder v0.0.2
Ethereum Data Decoder (TypeScript)
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.
Installation
Using NPM
npm install eth-data-decoder
using Yarn
yarn add eth-data-decoder
Example
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}));
License
MIT © 2019 Zohaib Rauf.
0.0.2
5 years ago