tron-tx-decoder
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.
Demo: https://tron-decoder.github.io
Installation
npm i tron-tx-decoder
Initialization
const TronTxDecoder = ; const decoder = mainnet: true ;// { mainnet: false } for testnet
Decode Input:
Decode function input parameters by passing transaction id.
{ const decodedInput = await decoder; return decodedInput;} ;
Output:
methodName: 'submitTheGame' inputNames: '_betId' 'freshHouseSeed' 'rollResult' '_gameOutcome' inputTypes: 'uint256' 'address' 'uint8' 'uint8' decodedInput: '0': BigNumber _hex: '0x265aa6' '1': '0x8F476d1155E9910A885Cae1c4396BDD392c3883E' '2': 11 '3': 1 _length: 4
Decode Output:
Decode function outputs by passing transaction id.
{ const decodedOutput = await decoder; return decodedOutput;} ;
Output:
methodName: 'submitTheGame' outputNames: null null outputTypes: 'uint256' 'uint256' decodedOutput: '0': BigNumber _hex: '0x265aa6' '1': BigNumber _hex: '0x0615ec20' _length: 2
Decode Revert Message (if any):
Decode function outputs by passing transaction id.
{ const decodedMessage = await decoder; return decodedMessage;} ;
Output:
txStatus: 'REVERT' revertMessage: 'Plot is not currently owned'
BigNumber
-
BigNumber can be converted to number using prototype .toNumber(). Which return a JavaScript number of the value.
Contributing
- Issues & Pull requests are welcome! Fork, branch, and submit PR.