<p>I have tried the <code>txBuilder.add_change_if_needed(addr)</code>  but it didnt work. Can you please tell me, that can a NFT alone be locked in a smart contract? Like i have tried that by sending the nft to smart contract by using function</p>
<pre><code>txOutputBuilder.with_asset_and_min_required_coin(
      multiAsset,
      this.sLib.BigNum.from_str(protocolParams.coinsPerUtxoWord)
    )
</code></pre>
<p>So NFT gets locked with some minimal ADA of about <strong>1.30593</strong> (maybe its because of coinsPerUtxoWord).
But when i wanna unlock that NFT from smart contract, how should i specify that minimal amount in my txInput as its according to coinsPerUtxoWord. And when i set the NFT alone in input, then the transaction gets unbalance, and shows the issue of imbalanced input and output of tx. I think this got imbalance because at output it requires some ADA for fee whereas i am passing NFT asset in input.
To resolve this i have tried to pass UTXOS in txInput by using</p>
<pre><code>const txUnspentOutputs = await this.getTxUnspentOutputs();
 txBuilder.add_inputs_from(txUnspentOutputs, 3)
</code></pre>
<p>and also i used later
<code>txBuilder.add_change_if_needed(shelleyChangeAddress)</code>
so that the change gets back to the changeAddress
But again its showing me the issue of</p>
<p><code>&quot;&quot;transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (ValueNotConservedUTxO ( Value 9996312330 (fromList [(PolicyID {policyID = ScriptHash \&quot;80786e0ffb709cf2da414f0496be530a129c23f18c7a493abbf8589c\&quot;},fromList [(617274426c61636b6e5768697465,1)])])) ( Value 9994984850 (fromList [(PolicyID {policyID = ScriptHash \&quot;80786e0ffb709cf2da414f0496be530a129c23f18c7a493abbf8589c\&quot;},fromList [(617274426c61636b6e5768697465,1)])]))))),UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (FeeTooSmallUTxO (Coin 798505) (Coin 171969))))])&quot;&quot; </code></p>
<p>I think the main issue is in this line of code i.e. <code> txOutputBuilder = txOutputBuilder.with_asset_and_min_required_coin(multiAsset, this.sLib.BigNum.from_str(protocolParams.coinsPerUtxoWord))</code>
of txOutput as given. But i dont know what to use instead of this nor i found any useful reading resource regarding it.</p>
<pre><code>let txOutputBuilder = this.sLib.TransactionOutputBuilder.new();
    txOutputBuilder = txOutputBuilder.with_address(shelleyChangeAddress);
    txOutputBuilder = txOutputBuilder.next();
 
    txOutputBuilder = txOutputBuilder.with_asset_and_min_required_coin(multiAsset, this.sLib.BigNum.from_str(protocolParams.coinsPerUtxoWord))
  const txOutput = txOutputBuilder.build();
    
  
    txBuilder.add_output(txOutput)
    console.log(&quot;txBuilder after adding output: &quot;, txBuilder)
</code></pre>
<p>Can you please help me out in this, I think i am a bit close just missing some points maybe. Your little guidance can be quite helpful. Thanks</p>

CC BY-SA 4.0
2023-05-05T12:45:13.037Z
2023-05-05T12:45:13.037Z
duaa azhar
<p>Looks like the error is telling you that you have a utxo problem. Your inputs must match your outputs. This could be that they're mismatched, or you're missing the input altogether. <a href="https://iohk.zendesk.com/hc/en-us/articles/900001220843-Transaction-errors-ValueNotConservedUTxO" rel="nofollow noreferrer">https://iohk.zendesk.com/hc/en-us/articles/900001220843-Transaction-errors-ValueNotConservedUTxO</a></p>
<p>I would also look at add_key_input as defined in the example here: <a href="https://github.com/Emurgo/cardano-serialization-lib/blob/master/doc/getting-started/minting-nfts.md" rel="nofollow noreferrer">https://github.com/Emurgo/cardano-serialization-lib/blob/master/doc/getting-started/minting-nfts.md</a></p>
<p>It seems like you're only setting the collateral with the inputs, but never actually setting the utxo's as input for the transaction.</p>

CC BY-SA 4.0
2023-04-20T05:26:24.937Z
Sorry i didn't get it what you are trying to mention. Like i do have set the txInput ` txBuilder.add_input(
      ScriptAddress,
      this.sLib.TransactionInput.new(
        this.sLib.TransactionHash.from_bytes(Buffer.from(transactionHashLocked, "hex")),
        this.transactionIndxLocked.toString()),
      this.sLib.Value.new_from_assets(multiAsset)
    ) `
Also i am setting the UTXO. and yes i know there is some imabalance in my inputs and outputs but i am unable to figure it out that how do i resolve this because i am new to cardano and this is the CSL modified code.
duaa azhar
CC BY-SA 4.0
2023-04-20T12:41:04.790Z
@duaaazhar Ah ok, good. So you know it's a balance issue. To find the balance issue ... I would console.log() any time you set a value in the script, and keep a running sum so you can compare that with the utxo's you're adding in. Then you should be able to find the mismatch. However, maybe try something like txBuilder.add_change_if_needed(addr) and see if that doesn't just resolve the issue. I looked here for some reference. https://github.com/Emurgo/cardano-serialization-lib/issues/285
PREEB
CC BY-SA 4.0
2023-05-05T12:46:12.110Z
Hi @PREEB , I have answered this in the reply to my question. Can you please help me out in that query?
Thanks in Advance.
duaa azhar
CC BY-SA 4.0
2023-04-18T13:31:57.267Z
2023-04-18T13:31:57.267Z
PREEB
<p>As of today the Cardano Serialization Library is no longer maintained and you shouldn't rely on it.</p>
<p>The closest to the CSL is the <a href="https://github.com/dcSpark/cardano-multiplatform-lib" rel="nofollow noreferrer">Cardano Multiplatform library</a> that still relies on Rust + WASM.</p>
<p>If you don't want to load 10 MB of WASM in your web app you can also try <a href="https://github.com/HarmonicLabs/cardano-ledger-ts" rel="nofollow noreferrer"><code>cardano-ledger-ts</code></a>(for the types) + <a href="https://github.com/HarmonicLabs/plu-ts" rel="nofollow noreferrer"><code>plu-ts-offchain</code></a>(for the transaction builder)</p>
<pre class="lang-bash prettyprint-override"><code>npm install @harmoniclabs/cardano-ledger-ts @harmoniclabs/plu-ts-offchain
</code></pre>

CC BY-SA 4.0
2023-05-13T10:03:47.000Z
2023-05-13T10:03:47.000Z
Michele Nuzzi
<p>I am trying to implement the Unlocking of NFT from an &quot;always true&quot; smart contract. I am using the Cardano serialization library for this. I can lock the NFT successfully, but when i unlock the NFT then i get the issue of Fee imbalancing issue i think. Maybe i am missing something and stuck on this.
I am facing this error
<code>&quot;&quot;transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (ValueNotConservedUTxO (Value 1297310 (fromList [(PolicyID {policyID = ScriptHash \&quot;80786e0ffb709cf2da414f0496be530a129c23f18c7a493abbf8589c\&quot;},fromList [(61727445796573,1)])])) (Value 2050770 (fromList [(PolicyID {policyID = ScriptHash \&quot;80786e0ffb709cf2da414f0496be530a129c23f18c7a493abbf8589c\&quot;},fromList [(61727445796573,1)])])))))])&quot;&quot; </code></p>
<p>Given below is my code for unlocking NFT.</p>
<pre><code>    assetName = undefined,
    assetPolicyId = undefined,
    storeWalletSelected = undefined,
    transactionHashLocked = undefined
  ) {
    
    const txBuilder = await this.initTransactionBuilder();
    const ScriptAddress = this.sLib.Address.from_bech32(this.addressScriptBech32);
    const walletAddress = await this.getAddress()
    const shelleyChangeAddress = this.sLib.Address.from_bech32(walletAddress)
    const protocolParams = this.getProtocolParameters();

    let multiAsset = this.sLib.MultiAsset.new();
    let assets = this.sLib.Assets.new()
    assets.insert(
      this.sLib.AssetName.new(Buffer.from(assetName, &quot;hex&quot;)), // Asset Name
      this.sLib.BigNum.from_str(this.assetAmountToSend.toString()) // How much to send
    );

    multiAsset.insert(
      this.sLib.ScriptHash.from_bytes(Buffer.from(assetPolicyId, &quot;hex&quot;)), // PolicyID
      assets
    );

    txBuilder.add_input(
      ScriptAddress,
      this.sLib.TransactionInput.new(
        this.sLib.TransactionHash.from_bytes(Buffer.from(transactionHashLocked, &quot;hex&quot;)),
        this.transactionIndxLocked.toString()),
      this.sLib.Value.new_from_assets(multiAsset)
    ) // how much lovelace is at that UTXO


    txBuilder.set_fee(this.sLib.BigNum.from_str(Number(this.manualFee).toString()))

    const scripts = this.sLib.PlutusScripts.new();
    scripts.add(this.sLib.PlutusScript.from_bytes(Buffer.from(this.plutusScriptCborHex, &quot;hex&quot;))); //from cbor of plutus script

    // Add outputs
    const outputValStr = Number(this.manualFee).toString();

    let txOutputBuilder = this.sLib.TransactionOutputBuilder.new();
    txOutputBuilder = txOutputBuilder.with_address(shelleyChangeAddress);
    txOutputBuilder = txOutputBuilder.next();
    txOutputBuilder = txOutputBuilder.with_asset_and_min_required_coin(
      multiAsset,
      this.sLib.BigNum.from_str(protocolParams.coinsPerUtxoWord)
    )
    
    const txOutput = txOutputBuilder.build();
    txBuilder.add_output(txOutput)

    // once the transaction is ready, we build it to get the tx body without witnesses
    const txBody = txBuilder.build();

    const collateral = await this.getCollateral(storeWalletSelected);
    const inputs = this.sLib.TransactionInputs.new();
    collateral.forEach((utxo) =&gt; inputs.add(utxo.input()) );

    let datums = this.sLib.PlutusList.new();
    // datums.add(PlutusData.from_bytes(Buffer.from(this.state.datumStr, &quot;utf8&quot;)))
    datums.add(this.sLib.PlutusData.new_integer(
      this.sLib.BigInt.from_str(this.datumStr)))

    const redeemers = this.sLib.Redeemers.new();

    const data = this.sLib.PlutusData.new_constr_plutus_data(
        this.sLib.ConstrPlutusData.new(
          this.sLib.BigNum.from_str(&quot;0&quot;),
          this.sLib.PlutusList.new()
        )
    );

    const redeemer = this.sLib.Redeemer.new(
      this.sLib.RedeemerTag.new_spend(),
      this.sLib.BigNum.from_str(&quot;0&quot;),
      data,
      this.sLib.ExUnits.new(
        this.sLib.BigNum.from_str(&quot;7000000&quot;),
        this.sLib.BigNum.from_str(&quot;3000000000&quot;)
      )
    );

    redeemers.add(redeemer)

    //Tx witness
    const transactionWitnessSet = this.sLib.TransactionWitnessSet.new();

    transactionWitnessSet.set_plutus_scripts(scripts)
    transactionWitnessSet.set_plutus_data(datums)
    transactionWitnessSet.set_redeemers(redeemers)

    const costModel = this.sLib.TxBuilderConstants.plutus_vasil_cost_models().get(this.sLib.Language.new_plutus_v1())    

    const costModels = this.sLib.Costmdls.new();
    costModels.insert(this.sLib.Language.new_plutus_v1(), costModel);

    const scriptDataHash = this.sLib.hash_script_data(redeemers, costModels, datums);
    txBody.set_script_data_hash(scriptDataHash);

    txBody.set_collateral(inputs)

    const baseAddress = this.sLib.BaseAddress.from_address(shelleyChangeAddress)
    const requiredSigners = this.sLib.Ed25519KeyHashes.new();
    requiredSigners.add(baseAddress.payment_cred().to_keyhash())

    txBody.set_required_signers(requiredSigners);

    const tx = this.sLib.Transaction.new(
      txBody,
      this.sLib.TransactionWitnessSet.from_bytes(transactionWitnessSet.to_bytes())
    )

    let txVkeyWitnesses = await this.wallet.signTx(Buffer.from(tx.to_bytes(), &quot;utf8&quot;).toString(&quot;hex&quot;), true);
    txVkeyWitnesses = this.sLib.TransactionWitnessSet.from_bytes(Buffer.from(txVkeyWitnesses, &quot;hex&quot;));

    transactionWitnessSet.set_vkeys(txVkeyWitnesses.vkeys());
    const signedTx = this.sLib.Transaction.new(tx.body(), transactionWitnessSet);

    const submittedTxHash = await this.wallet.submitTx(Buffer.from(signedTx.to_bytes(), &quot;utf8&quot;).toString(&quot;hex&quot;));
    console.log('Tx Hash NFT Reedemed: ', submittedTxHash);
    return submittedTxHash
  }
</code></pre>
<p>The protocol Parameters used in this are</p>
<pre><code>getProtocolParameters () {
   return {
     linearFee: {
         minFeeA: &quot;44&quot;,
         minFeeB: &quot;155381&quot;,
     },
     minUtxo: &quot;34482&quot;,
     poolDeposit: &quot;500000000&quot;,
     keyDeposit: &quot;2000000&quot;,
     maxValSize: 5000,
     maxTxSize: 16384,
     priceMem: 0.0577,
     priceStep: 0.0000721,
     coinsPerUtxoWord: &quot;34482&quot;,
   }
 }
</code></pre>
<p>The manual fee variable is</p>
<pre><code>this.manualFee = 900000
</code></pre>
<p>Kindly suggest me some solution if you find any.</p>

<cardano-node><smart-contract><nft><cardano-serialization-lib><staking>
Unlock NFT from smart contract by Cardano-serialization-library
# Unlock NFT from smart contract by Cardano-serialization-library

(Asked by: username_0 on 2023-04-13)

I am trying to implement the Unlocking of NFT from an "always true" smart contract. I am using the Cardano serialization library for this. I can lock the NFT successfully, but when i unlock the NFT then i get the issue of Fee imbalancing issue i think. Maybe i am missing something and stuck on this.
I am facing this error
""transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (ValueNotConservedUTxO (Value 1297310 (fromList [(PolicyID {policyID = ScriptHash \"80786e0ffb709cf2da414f0496be530a129c23f18c7a493abbf8589c\"},fromList [(61727445796573,1)])])) (Value 2050770 (fromList [(PolicyID {policyID = ScriptHash \"80786e0ffb709cf2da414f0496be530a129c23f18c7a493abbf8589c\"},fromList [(61727445796573,1)])])))))])"" 
Given below is my code for unlocking NFT.
    assetName = undefined,
    assetPolicyId = undefined,
    storeWalletSelected = undefined,
    transactionHashLocked = undefined
  ) {
    
    const txBuilder = await this.initTransactionBuilder();
    const ScriptAddress = this.sLib.Address.from_bech32(this.addressScriptBech32);
    const walletAddress = await this.getAddress()
    const shelleyChangeAddress = this.sLib.Address.from_bech32(walletAddress)
    const protocolParams = this.getProtocolParameters();

    let multiAsset = this.sLib.MultiAsset.new();
    let assets = this.sLib.Assets.new()
    assets.insert(
      this.sLib.AssetName.new(Buffer.from(assetName, "hex")), // Asset Name
      this.sLib.BigNum.from_str(this.assetAmountToSend.toString()) // How much to send
    );

    multiAsset.insert(
      this.sLib.ScriptHash.from_bytes(Buffer.from(assetPolicyId, "hex")), // PolicyID
      assets
    );

    txBuilder.add_input(
      ScriptAddress,
      this.sLib.TransactionInput.new(
        this.sLib.TransactionHash.from_bytes(Buffer.from(transactionHashLocked, "hex")),
        this.transactionIndxLocked.toString()),
      this.sLib.Value.new_from_assets(multiAsset)
    ) // how much lovelace is at that UTXO


    txBuilder.set_fee(this.sLib.BigNum.from_str(Number(this.manualFee).toString()))

    const scripts = this.sLib.PlutusScripts.new();
    scripts.add(this.sLib.PlutusScript.from_bytes(Buffer.from(this.plutusScriptCborHex, "hex"))); //from cbor of plutus script

    // Add outputs
    const outputValStr = Number(this.manualFee).toString();

    let txOutputBuilder = this.sLib.TransactionOutputBuilder.new();
    txOutputBuilder = txOutputBuilder.with_address(shelleyChangeAddress);
    txOutputBuilder = txOutputBuilder.next();
    txOutputBuilder = txOutputBuilder.with_asset_and_min_required_coin(
      multiAsset,
      this.sLib.BigNum.from_str(protocolParams.coinsPerUtxoWord)
    )
    
    const txOutput = txOutputBuilder.build();
    txBuilder.add_output(txOutput)

    // once the transaction is ready, we build it to get the tx body without witnesses
    const txBody = txBuilder.build();

    const collateral = await this.getCollateral(storeWalletSelected);
    const inputs = this.sLib.TransactionInputs.new();
    collateral.forEach((utxo) => inputs.add(utxo.input()) );

    let datums = this.sLib.PlutusList.new();
    // datums.add(PlutusData.from_bytes(Buffer.from(this.state.datumStr, "utf8")))
    datums.add(this.sLib.PlutusData.new_integer(
      this.sLib.BigInt.from_str(this.datumStr)))

    const redeemers = this.sLib.Redeemers.new();

    const data = this.sLib.PlutusData.new_constr_plutus_data(
        this.sLib.ConstrPlutusData.new(
          this.sLib.BigNum.from_str("0"),
          this.sLib.PlutusList.new()
        )
    );

    const redeemer = this.sLib.Redeemer.new(
      this.sLib.RedeemerTag.new_spend(),
      this.sLib.BigNum.from_str("0"),
      data,
      this.sLib.ExUnits.new(
        this.sLib.BigNum.from_str("7000000"),
        this.sLib.BigNum.from_str("3000000000")
      )
    );

    redeemers.add(redeemer)

    //Tx witness
    const transactionWitnessSet = this.sLib.TransactionWitnessSet.new();

    transactionWitnessSet.set_plutus_scripts(scripts)
    transactionWitnessSet.set_plutus_data(datums)
    transactionWitnessSet.set_redeemers(redeemers)

    const costModel = this.sLib.TxBuilderConstants.plutus_vasil_cost_models().get(this.sLib.Language.new_plutus_v1())    

    const costModels = this.sLib.Costmdls.new();
    costModels.insert(this.sLib.Language.new_plutus_v1(), costModel);

    const scriptDataHash = this.sLib.hash_script_data(redeemers, costModels, datums);
    txBody.set_script_data_hash(scriptDataHash);

    txBody.set_collateral(inputs)

    const baseAddress = this.sLib.BaseAddress.from_address(shelleyChangeAddress)
    const requiredSigners = this.sLib.Ed25519KeyHashes.new();
    requiredSigners.add(baseAddress.payment_cred().to_keyhash())

    txBody.set_required_signers(requiredSigners);

    const tx = this.sLib.Transaction.new(
      txBody,
      this.sLib.TransactionWitnessSet.from_bytes(transactionWitnessSet.to_bytes())
    )

    let txVkeyWitnesses = await this.wallet.signTx(Buffer.from(tx.to_bytes(), "utf8").toString("hex"), true);
    txVkeyWitnesses = this.sLib.TransactionWitnessSet.from_bytes(Buffer.from(txVkeyWitnesses, "hex"));

    transactionWitnessSet.set_vkeys(txVkeyWitnesses.vkeys());
    const signedTx = this.sLib.Transaction.new(tx.body(), transactionWitnessSet);

    const submittedTxHash = await this.wallet.submitTx(Buffer.from(signedTx.to_bytes(), "utf8").toString("hex"));
    console.log('Tx Hash NFT Reedemed: ', submittedTxHash);
    return submittedTxHash
  }

The protocol Parameters used in this are
getProtocolParameters () {
   return {
     linearFee: {
         minFeeA: "44",
         minFeeB: "155381",
     },
     minUtxo: "34482",
     poolDeposit: "500000000",
     keyDeposit: "2000000",
     maxValSize: 5000,
     maxTxSize: 16384,
     priceMem: 0.0577,
     priceStep: 0.0000721,
     coinsPerUtxoWord: "34482",
   }
 }

The manual fee variable is
this.manualFee = 900000

Kindly suggest me some solution if you find any.

**Tags:** cardano-node, smart-contract, nft, cardano-serialization-lib, staking

---

## 3 answers

### Answer by username_0 on 2023-05-05. Score: 0

I have tried the txBuilder.add_change_if_needed(addr)  but it didnt work. Can you please tell me, that can a NFT alone be locked in a smart contract? Like i have tried that by sending the nft to smart contract by using function
txOutputBuilder.with_asset_and_min_required_coin(
      multiAsset,
      this.sLib.BigNum.from_str(protocolParams.coinsPerUtxoWord)
    )

So NFT gets locked with some minimal ADA of about 1.30593 (maybe its because of coinsPerUtxoWord).
But when i wanna unlock that NFT from smart contract, how should i specify that minimal amount in my txInput as its according to coinsPerUtxoWord. And when i set the NFT alone in input, then the transaction gets unbalance, and shows the issue of imbalanced input and output of tx. I think this got imbalance because at output it requires some ADA for fee whereas i am passing NFT asset in input.
To resolve this i have tried to pass UTXOS in txInput by using
const txUnspentOutputs = await this.getTxUnspentOutputs();
 txBuilder.add_inputs_from(txUnspentOutputs, 3)

and also i used later
txBuilder.add_change_if_needed(shelleyChangeAddress)
so that the change gets back to the changeAddress
But again its showing me the issue of
""transaction submit error ShelleyTxValidationError ShelleyBasedEraBabbage (ApplyTxError [UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (ValueNotConservedUTxO ( Value 9996312330 (fromList [(PolicyID {policyID = ScriptHash \"80786e0ffb709cf2da414f0496be530a129c23f18c7a493abbf8589c\"},fromList [(617274426c61636b6e5768697465,1)])])) ( Value 9994984850 (fromList [(PolicyID {policyID = ScriptHash \"80786e0ffb709cf2da414f0496be530a129c23f18c7a493abbf8589c\"},fromList [(617274426c61636b6e5768697465,1)])]))))),UtxowFailure (UtxoFailure (FromAlonzoUtxoFail (FeeTooSmallUTxO (Coin 798505) (Coin 171969))))])"" 
I think the main issue is in this line of code i.e.  txOutputBuilder = txOutputBuilder.with_asset_and_min_required_coin(multiAsset, this.sLib.BigNum.from_str(protocolParams.coinsPerUtxoWord))
of txOutput as given. But i dont know what to use instead of this nor i found any useful reading resource regarding it.
let txOutputBuilder = this.sLib.TransactionOutputBuilder.new();
    txOutputBuilder = txOutputBuilder.with_address(shelleyChangeAddress);
    txOutputBuilder = txOutputBuilder.next();
 
    txOutputBuilder = txOutputBuilder.with_asset_and_min_required_coin(multiAsset, this.sLib.BigNum.from_str(protocolParams.coinsPerUtxoWord))
  const txOutput = txOutputBuilder.build();
    
  
    txBuilder.add_output(txOutput)
    console.log("txBuilder after adding output: ", txBuilder)

Can you please help me out in this, I think i am a bit close just missing some points maybe. Your little guidance can be quite helpful. Thanks


---

### Answer by username_1 on 2023-04-18. Score: 0

Looks like the error is telling you that you have a utxo problem. Your inputs must match your outputs. This could be that they're mismatched, or you're missing the input altogether. <https://iohk.zendesk.com/hc/en-us/articles/900001220843-Transaction-errors-ValueNotConservedUTxO>

I would also look at add\_key\_input as defined in the example here: <https://github.com/Emurgo/cardano-serialization-lib/blob/master/doc/getting-started/minting-nfts.md>

It seems like you're only setting the collateral with the inputs, but never actually setting the utxo's as input for the transaction.

> **Comments:**
> **username_0**: Sorry i didn't get it what you are trying to mention. Like i do have set the txInput ` txBuilder.add_input(       ScriptAddress,       this.sLib.TransactionInput.new(         this.sLib.TransactionHash.from_bytes(Buffer.from(transactionHashLocked, "hex")),         this.transactionIndxLocked.toString()),       this.sLib.Value.new_from_assets(multiAsset)     ) ` Also i am setting the UTXO. and yes i know there is some imabalance in my inputs and outputs but i am unable to figure it out that how do i resolve this because i am new to cardano and this is the CSL modified code.  
> **username_1**: @duaaazhar Ah ok, good. So you know it's a balance issue. To find the balance issue ... I would console.log() any time you set a value in the script, and keep a running sum so you can compare that with the utxo's you're adding in. Then you should be able to find the mismatch. However, maybe try something like txBuilder.add_change_if_needed(addr) and see if that doesn't just resolve the issue. I looked here for some reference. https://github.com/Emurgo/cardano-serialization-lib/issues/285  
> **username_0**: Hi @PREEB , I have answered this in the reply to my question. Can you please help me out in that query? Thanks in Advance.  

---

### Answer by username_2 on 2023-05-13. Score: 0

As of today the Cardano Serialization Library is no longer maintained and you shouldn't rely on it.
The closest to the CSL is the Cardano Multiplatform library that still relies on Rust + WASM.
If you don't want to load 10 MB of WASM in your web app you can also try cardano-ledger-ts(for the types) + plu-ts-offchain(for the transaction builder)
npm install @harmoniclabs/cardano-ledger-ts @harmoniclabs/plu-ts-offchain


---

