How to calculate transaction size?

+1 vote
How does one calculate transaction size - with each transaction paying in native currency of 0.001 with stream data of a sha256 hash.

I am trying to work out for a chain, at 5 minute blocks, with around 100 mining nodes, what the max transaction volume might be per second, and what size I should allow for blocks. I would think that with 100 nodes, I would not get 1000 tps?.. So I am trying to think ahead of what I need to change in params.dat to suit.
asked Sep 6, 2017 by mark

1 Answer

0 votes

First, the limit on tps is only minimally affected by the number of nodes, since the core bottleneck is in every node processing the full set transactions. The cost of transferring transactions and blocks between peers is relatively low, and each node only retrieves each transaction and block once from its peers.

Second, the simplest way to work out the transaction size is to just to create some transaction of the type you need, and see how large it is by retrieving the raw transaction data, counting hexadecimal characters, and dividing by two.

Third, some basic guidelines for the size of common transaction types (assuming non-multisig inputs/outputs) are as follows:

  • 10 bytes fixed per transaction
  • 180 bytes per input
  • 34 bytes per redeemable output (covers native currency only, even if there is none)
  • For redeemable outputs containing issued assets, add 4 bytes plus 24 bytes per asset type
  • 11 bytes + data length per non-redeemable raw metadata output
  • 39 bytes + key length + data length per non-redeemable stream item output

This ignores a few extra bytes that can result from various "variable integer" representations.

answered Sep 6, 2017 by MultiChain
Yep, I tested it with a sample, showed 328 bytes. So allowing 1000 tps, x 5 minutes = 300k transactions per block - 98MB per block...reducing this to 1 minute makes more sense in this case, makes it 20MB per block...
How do i calculate the transaction size in detail?

Here is the getrawtransaction data for the transaction i want to calculate:
{
    "hex" : "01000000015325607ca21ae496213596469212355ab21f9a3d39c39dd20cbd8952811daecd010000006b483045022100b19f1066114169e936d5ff52f35c9bf5bb15fb23e556e5976353b22e07346f3802204834373479cec26c9bb677e07d629a5b8aab7f8edb421bcf050c5c47c79f8e2e012102455fdc89adde068c597970c6f372a78252a0af5cbfd46532bb2d3b3d3f11444dffffffff0200000000000000003776a9142e08f3f5c8721dac8cce7c49c5809ba2108c7ac188ac1c73706b71b78ebca7ebfa345c63fdf05c8af4b6880a000000000000007500000000000000003776a914441aa1a94509bf1ecedbf02f020f21a030af8fde88ac1c73706b71b78ebca7ebfa345c63fdf05c8af4b6883ed59600000000007500000000",
    "txid" : "f43706474ade1508e4e8981c4a513b5bf8004708068c4ad074a01ae3687a4a40",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "cdae1d815289bd0cd29dc3393d9a1fb25a3512924696352196e41aa27c602553",
            "vout" : 1,
            "scriptSig" : {
                "asm" : "3045022100b19f1066114169e936d5ff52f35c9bf5bb15fb23e556e5976353b22e07346f3802204834373479cec26c9bb677e07d629a5b8aab7f8edb421bcf050c5c47c79f8e2e01 02455fdc89adde068c597970c6f372a78252a0af5cbfd46532bb2d3b3d3f11444d",
                "hex" : "483045022100b19f1066114169e936d5ff52f35c9bf5bb15fb23e556e5976353b22e07346f3802204834373479cec26c9bb677e07d629a5b8aab7f8edb421bcf050c5c47c79f8e2e012102455fdc89adde068c597970c6f372a78252a0af5cbfd46532bb2d3b3d3f11444d"
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 0,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 2e08f3f5c8721dac8cce7c49c5809ba2108c7ac1 OP_EQUALVERIFY OP_CHECKSIG 73706b71b78ebca7ebfa345c63fdf05c8af4b6880a00000000000000 OP_DROP",
                "hex" : "76a9142e08f3f5c8721dac8cce7c49c5809ba2108c7ac188ac1c73706b71b78ebca7ebfa345c63fdf05c8af4b6880a0000000000000075",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "17DsHi1bejKSpRaB9RvxMQnKtACouXQLWc3o5q"
                ]
            },
            "assets" : [
                {
                    "name" : "intercoin",
                    "issuetxid" : "88b6f48a5cf0fd635c34faeba7bc8eb77d6b45e760862bef70e7c9ecbd093719",
                    "assetref" : "30-265-46728",
                    "qty" : 1,
                    "raw" : 10,
                    "type" : "transfer"
                }
            ]
        },
        {
            "value" : 0,
            "n" : 1,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 441aa1a94509bf1ecedbf02f020f21a030af8fde OP_EQUALVERIFY OP_CHECKSIG 73706b71b78ebca7ebfa345c63fdf05c8af4b6883ed5960000000000 OP_DROP",
                "hex" : "76a914441aa1a94509bf1ecedbf02f020f21a030af8fde88ac1c73706b71b78ebca7ebfa345c63fdf05c8af4b6883ed596000000000075",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1ACsDg9tdx7Lu9yyhuqRZwyMpUhs4q4tnP1P2F"
                ]
            },
            "assets" : [
                {
                    "name" : "intercoin",
                    "issuetxid" : "88b6f48a5cf0fd635c34faeba7bc8eb77d6b45e760862bef70e7c9ecbd093719",
                    "assetref" : "30-265-46728",
                    "qty" : 988499,
                    "raw" : 9884990,
                    "type" : "transfer"
                }
            ]
        }
    ],
    "blockhash" : "001bbf4d1e9deec3c1c5cce4b59a000e6c6ba4b2df2b7073c64ef2fbf2160f2f",
    "confirmations" : 1,
    "time" : 1556357190,
    "blocktime" : 1556357190
}
It is just the length of the first "hex" field value divided by 2 (since two hexadecimal characters make one byte).
...