Max number of transaction inputs

I’m working on workflow for collecting money from NFT sale.
Our idea is to generate for each participant unique address for collecting ADA.
Once unique address is funded, using funds from this address we would generate mint transaction and sign it using policy skey and unique address skey. Once it is submitted user would get back back NFT to address from which he/she sent funds…

Once sales is over we would like to send all remaining lovelaces from all unique addresses back to one address.

Wanted to ask if there is a maximal number of inputs that we can have in transaction

cardano-cli transaction build-raw
–fee $fee
–tx-in $txhashNumber1#0

–tx-in $txhashNumber1000#0
–tx-out $address+$output
–invalid-hereafter 27064655
–out-file matx.raw

fee=$(cardano-cli transaction calculate-min-fee --tx-body-file matx.raw --tx-in-count 1000 --tx-out-count 1 --witness-count 2 --$testnet --protocol-params-file protocol.json | cut -d " " -f1)

cardano-cli transaction sign
–signing-key-file paymentNumber1.skey

–signing-key-file paymentNumber1000.skey
–signing-key-file policy/policy.skey
–$testnet --tx-body-file matx.raw
–out-file matx.signed

1 Like

The maximum transaction size currently is 16 kB. There should be room for at least 160 inputs, and maybe quite a bit more.

1 Like

Thanks for the answer.
For minting transaction
–minting-script-file policy/policy.script
–metadata-json-file metadata.json \

if we are adding policy.script and metada.json, I assume that they are added as well to this 16KB limit?

The metadata does count towards the transaction size. My guess is that the script doesn’t count because only its hash is stored on the chain.

The documentation isn’t clear about exactly what counts towards the limit. I’d have to study the Haskell source code to be definitive. Scripts, signatures, certificates, etc. take space in the submitted transaction, but they aren’t stored in toto on the chain, just used for validation.

1 Like

P.S. I did some experiments on testnet and here is what I found:

  1. For simple transactions (i.e., no metadata, tokens, scripts, etc.), one can create valid transactions with up to 434 --tx-ins!
  2. Items in cardando-cli transaction build-raw count against the size limit. This includes metadata, certificates, auxillary scripts, etc.
  3. Items in cardano-cli transaction sign also count against the size limit. This includes signatures, minting scripts and other simple scripts.
  4. For metadata and scripts, it’s the size in CBOR that counts, not the JSON size.
  5. The size of the tx.raw and tx.signed files are about twice as large as the actual CBOR size of the transaction they contain.
  6. Each --tx-in generally uses about 38 bytes.

If the transaction involves NFTs, a considerable size is consumed by the policy IDs, asset names, and metadata. Recently, when I minted 80 tokens with heavy metadata, I split it into batches of ~14 tokens.

3 Likes

Thanks for the answer.

Regards,
Adam.