4

Is there any prebuild method in Cardano Serialization Lib that allows to select some UTXOs that cover the balance needed for a transaction?

Or should i make a script that querys all the utxo in that addres and selects the first ones that covers this given amount?

1 Answer 1

3

You are speaking about what we call Coin Selection Algorithms and they are described in CIP2.

There are several implementations floating around on Github, such as BerryPool implementation of the Random-Improve coin selection algorithm or what Yoroi does.

5
  • Yes i have seen Berrys implementation, but it semed a little bit too complex, and the CIP2 apears to be in haskell right? I did one script that only querys one by one until it gets the minimun and then the extra is sended back to the owner, i dont know if this is enought for my dapp or if should I use Berry implementation. Nov 13, 2021 at 3:25
  • 1
    No, the CIP describes the algorithm, these are language agnostic. Nov 13, 2021 at 19:50
  • +1 for the links to the coin selection CIP and the implementations!
    – LACE pool
    Jan 15 at 13:43
  • The cardano-wallet's implementation in Haskell for coin selection can be found here: github.com/input-output-hk/cardano-wallet/blob/…
    – LACE pool
    Jan 15 at 13:52
  • @MarekMahut-StakeNuts CIP20 states "Problems relating to network fees, and how to adjust coin selections to pay for such fees, are outside the scope of this article." Any ideas how to solve that?
    – wutzebaer
    Nov 2 at 23:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.