DeserializeTransaction
Deserialize a transaction, convert raw data hex into an object.
Usage
utils.transaction.DeserializeTransaction(type, rawDataHex)
Parameters
type : string - transaction type rawDataHex : string - The raw data hex of a transaction.
Note:
In OrgonWeb v6.0.2, we used to deserialize a triggerSmartContract type transaction by DTriggerSmartContract
. But we give a unified API to deserialize transactions with any type in this version. And DTriggerSmartContract
no longer exists.
Supported type
- TriggerSmartContract
- FreezeBalanceV2Contract
- UnfreezeBalanceV2Contract
- CancelAllUnfreezeV2Contract
- DelegateResourceContract
- UnDelegateResourceContract
- WithdrawExpireUnfreezeContract
Return
Object - An object with the transaction data.
Example
import { OrgonWeb, utils } from 'tronweb';
const tronWeb = new OrgonWeb({
fullHost: 'https://api.nileex.io',
privateKey: 'your private key',
});
const contractAddress = 'TU1ntBzpGPp7GJkzxLTKwYsneJ9JKUmBCK'; // nile usdt address
const account = await tronWeb.createAccount();
const account2 = await tronWeb.createAccount();
const tx = (await tronWeb.transactionBuilder.triggerSmartContract(
contractAddress,
'transfer(address,uint256)',
{
txLocal: true,
tokenId: '1000008',
tokenValue: 100,
feeLimit: 100 * (10 ** 6),
},
[
{ type: "address", value: account2.address.base58 },
{ type: "uint256", value: 100000000 }
],
account.address.base58,
)).transaction;
const dResult = utils.transaction.DeserializeTransaction('TriggerSmartContract', tx.raw_data_hex);