Looking through the cardano-serialization-lib I see a TransactionBuilderConfig and a TransactionBuilder constructor that looks like it takes the Config and exposes add_from_inputs that maybe does the coinSelection that is in a separate module in projects like Nami.

I don't however see how that's exposed in the javascript. Am I missing and/or misunderstanding these things or how they could or should be used??

  • Welcome to Cardano SE! As a new user be sure to take the Tour.
    – gRebel
    Jan 22, 2022 at 23:07

1 Answer 1


It should be right there just as you say. The add_inputs_from function on the TransactionBuilder takes the strategy as the second parameter.

So in Javascript if your using this (https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-browser or https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-nodejs), you can import from it the CoinSelectionStrategyCIP2 and pass a strategy to the tx builder like this:

txBuilder.add_inputs_from(utxos, CoinSelectionStrategyCIP2.LargestFirst)

The implementation of the strategies is here: https://github.com/Emurgo/cardano-serialization-lib/blob/6a8c67a0fdb2ac6d72132d9693b87a6734f3fed5/rust/src/tx_builder.rs#L329

  • Ok cool thanks I'll try it out maybe I was looking at it wrong
    – radflipper
    Jan 23, 2022 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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