Let's say someone has 10'000 different tokens on one address. Each token is in a single UTxO. Would it be possible to send them all in one transaction to another address (or the same address), so they are all in one UTxO? Or is there a limit on how many distinct tokens one can send in a single transaction?
The maximum transaction size is specified in the genesis configuration of the chain. For reference, here is a genesis config for the Shelley Testnet.
maxTxSize is set to
16384 (bytes, I assume).
So. Yes, there is definitely a limit to how many different tokens you could include in a UTxO.
This doesn't answer the question on limits to the number of inputs for a transaction. Obviously these couldn't result in an output larger than
maxTxSize, but I can't say if there are additional constraints on the number of inputs. I'm curious to know so I might keep looking. In the mean time, I hope that helps.
We can simulate this in the playground. I set up three tokens T1,T2 and T3 and gave one of each to Wallet 1 at the beginning.
Then I sent three separate transactions, sending each token in its own transaction to Wallet 2, resulting in 3 new UTxOs in Wallet 2, one for each token.
I then paid all the tokens back to Wallet 1 in a single transaction.
If you zoom in on the image, you can see that there are four inputs, which are the lovelace for fees plus one UTxO for each token. One of the outputs to Wallet 1 is a single UTxO with all three tokens included. The other output is the change given back to Wallet 2 after Lovelace fees are deducted.
As mentioned by Aoaddeola, there should be no theoretical limit to the number of tokens this can scale for.
To the best of my knowledge, there is no limit to the amount of tokens a transaction can contain.
Value itself has the following Signature
Map CurrencySymbol (Map TokenName Integer). Which literarily means an unlimited number of tokens, since
Map poses no limit to the amount of elements it can contain.