<p>It should be right there just as you say. The <em>add_inputs_from</em> function on the <em>TransactionBuilder</em> takes the <em>strategy</em> as the second parameter.</p>
<p>So in Javascript if your using this (<a href="https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-browser" rel="nofollow noreferrer">https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-browser</a> or <a href="https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-nodejs" rel="nofollow noreferrer">https://www.npmjs.com/package/@emurgo/cardano-serialization-lib-nodejs</a>), you can import from it the CoinSelectionStrategyCIP2 and pass a strategy to the tx builder like this:</p>
<pre><code>txBuilder.add_inputs_from(utxos, CoinSelectionStrategyCIP2.LargestFirst)
</code></pre>
<p>The implementation of the strategies is here: <a href="https://github.com/Emurgo/cardano-serialization-lib/blob/6a8c67a0fdb2ac6d72132d9693b87a6734f3fed5/rust/src/tx_builder.rs#L329" rel="nofollow noreferrer">https://github.com/Emurgo/cardano-serialization-lib/blob/6a8c67a0fdb2ac6d72132d9693b87a6734f3fed5/rust/src/tx_builder.rs#L329</a></p>

CC BY-SA 4.0
2022-01-23T19:18:06.880Z
Ok cool thanks I'll try it out maybe I was looking at it wrong
radflipper
CC BY-SA 4.0
2022-01-23T16:52:29.790Z
2022-01-23T16:52:29.790Z
sean
<p>Looking through the cardano-serialization-lib I see a <code>TransactionBuilderConfig</code> and a <code>TransactionBuilder</code> constructor that looks like it takes the Config and exposes <code>add_from_inputs</code> that <em>maybe</em> does the coinSelection that is in a separate module in projects like Nami.</p>
<p>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??</p>

CC BY-SA 4.0
2022-01-22T23:07:45.400Z
Welcome to Cardano SE! As a new user be sure to take the [Tour].
gRebel
<cardano-serialization-lib>
TransactionBuilder and add_from_inputs
# TransactionBuilder and add_from_inputs

(Asked by: username_0 on 2022-01-22)

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??

**Tags:** cardano-serialization-lib
> **Comments:**
> **username_1**: Welcome to Cardano SE! As a new user be sure to take the [Tour].  

---

## 1 answers

### Answer by username_2 on 2022-01-23. Score: 0

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

> **Comments:**
> **username_0**: Ok cool thanks I'll try it out maybe I was looking at it wrong  

---

