calculateTransactionSize function

int calculateTransactionSize(
  1. TronContractData contractData
)

Used for calculating the bandwidth of a transaction (Size in Bytes) Builds a Dummy Transaction and calculates the size of the transaction https://github.com/tronprotocol/wallet-cli/issues/292

Implementation

int calculateTransactionSize(TronContractData contractData) {
  final rawTx = buildRawTransaction(
    contractData,
    block: tronDummyBlock,
  );

  final tx = signTransaction(
    rawTx: rawTx,
    seed: dummySeed,
  );

  final rawDataLength = tx.rawData.writeToBuffer().length;

  final sigLength = tx.signature.first.toUint8List.length;

  final headerSize = (rawDataLength > 127 ? 3 : 2) + 2;

  return rawDataLength + sigLength + headerSize + maxReturnFieldSize;
}