Closed kricha closed 10 months ago
In Java-tron, the consumed bandwidth of a transaction depends on its byte size after being serialized by protobuf
.
In frontend, you can use the following function to calculate the bandwidth with a signedTransaction roughly:
function estimateBandwidth(signedTxn) {
const DATA_HEX_PROTOBUF_EXTRA = 3;
const MAX_RESULT_SIZE_IN_TX = 64;
const A_SIGNATURE = 67;
const len = signedTxn.raw_data_hex.length /2 + DATA_HEX_PROTOBUF_EXTRA + MAX_RESULT_SIZE_IN_TX ;
const signatureListSize = signedTxn.signature.length || 0;
for(let i=0;i<signatureListSize;i++)
{
len += A_SIGNATURE;
}
return len;
}
In Java-tron, the consumed bandwidth of a transaction depends on its byte size after being serialized by
protobuf
. In frontend, you can use the following function to calculate the bandwidth with a signedTransaction roughly:function estimateBandwidth(signedTxn) { const DATA_HEX_PROTOBUF_EXTRA = 3; const MAX_RESULT_SIZE_IN_TX = 64; const A_SIGNATURE = 67; const len = signedTxn.raw_data_hex.length /2 + DATA_HEX_PROTOBUF_EXTRA + MAX_RESULT_SIZE_IN_TX ; const signatureListSize = signedTxn.signature.length || 0; for(let i=0;i<signatureListSize;i++) { len += A_SIGNATURE; } return len; }
before signing I can't calculate this?
You can calculate a unsigned transaction but the result is not the ultimate result. Only the signed transaction will be stored in the blockchain.
You can calculate a unsigned transaction but the result is not the ultimate result. Only the signed transaction will be stored in the blockchain.
thanks
I have transaction where I'm triggering method of smart contract and need to understand how could I calculate bandwidth to get same value as on tronscan
I've tried different operations to calculate this value, but can't get same.. this.chain.transactionBuilder
with this I'm getting 1960 966 862 431
maybe somebody could help me with this