JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 21
  • Score
    100M100P100Q72024F
  • License MIT

Lightweight utility for decoding function parameters and function output from Tron blocklchain transactions.

Package Exports

  • tron-tx-decoder

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (tron-tx-decoder) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tron-tx-decoder

JavaScript Style Guide npm npm bundle size License: MIT

Lightweight utility for decoding function parameters and function output from Tron blocklchain transactions.

  • Minimal dependencies.

  • Decode method name used by specific Transaction Id.

  • Find the input parameter passed to function by Transaction Id.

  • Find the exact output returned from the function by Transaction Id.

  • Built with ethers.js.

Installation

npm i tron-tx-decoder

Initialization

const TronTxDecoder = require('tron-tx-decoder');

const decoder = new TronTxDecoder({ mainnet: true });
// { mainnet: false } for testnet

Decode Input:

Decode funciton input parameters by passing transaction id.

async function decodeTxInput(txId){
    const decodedInput = await decoder.decodeInputById(txId);
    return decodedInput;
}

decodeTxInput("0c739761b34a891b3bbecd528302de827736660d76c62dacf8d3a9ebe7dade08").then(console.log);
// { 
//    methodName: 'submitTheGame',
//    decodedInput: 
//     [ { '_betId (uint256)': BigNumber { _hex: '0x265aa6' } },
//       { 'freshHouseSeed (address)': '0x8F476d1155E9910A885Cae1c4396BDD392c3883E' },
//       { 'rollResult (uint8)': 11 },
//       { '_gameOutcome (uint8)': 1 } ] 
// }

Decode Output:

Decode funciton outputs by passing transaction id.

async function decodeTxOutput(txId){
    const decodedOutput = await decoder.decodeResultById(txId);
    return decodedOutput;
}

decodeTxOutput("0c739761b34a891b3bbecd528302de827736660d76c62dacf8d3a9ebe7dade08").then(console.log);
// { 
//    methodName: 'submitTheGame',
//    decodedOutput: 
//      [ { uint256: BigNumber { _hex: '0x265aa6' } },
//        { uint256: BigNumber { _hex: '0x0615ec20' } } ] 
// }

BigNumber

Contributing

  • Issues & Pull requests are welcome! Fork, branch, and submit PR.

Licence

MIT