I have an application where I want to avoid using 3rd binaries like cardano-cli. I need to calculate what is minimal UTXO size for TX where N different tokens is sent.
Right now cardano-wallet HTTP endpoint returns error 404 with long error string that contains correct value
"message": "Some outputs have ada values that are too small. There's a minimum ada value specified by the protocol that each output must satisfy. I'll handle that minimum value myself when you do not explicitly specify an ada value for an output. Otherwise, you must specify enough ada. Here are the problematic outputs: - Expected min coin value: 1.413762 TxOut: address: 00064225...d59deacc coin: 1.400000 tokens: - policy: 9e87deb6ec1e989f125652b4883728fdd308e4223a0396f45b2023c2 tokens: - token: 766d3774657374486f736b794361736847726162 quantity: 1 "
I want to be able to calculate this value myself. What I do right now is that I take "base min UTXO" size of 1.6ADA for lovelace and 1 token and then add 0.3ADA for each extra token, so if someone is sending 2 tokens it asks for 1.9ADA deposit.
That works but isn't correct and I probably use unnecessarily large deposits (it doesn't matter so much as whole deposit - tx fees is returned back to user) but I'd like to make this correct.
So what is the correct algorithm to calculate precise fee? Mind this is just a simple transaction of ADA and some native assets to single output address, no plutus or other complex things to consider.