0

With the new version of library TranasctionBuilder.new() arguments have changed.

When running:

    const txBuilder = this.S.TransactionBuilder.new(
      this.S.LinearFee.new(
        this.S.BigNum.from_str(protocolParameters.linearFee.minFeeA),
        this.S.BigNum.from_str(protocolParameters.linearFee.minFeeB)
      ),
      this.S.BigNum.from_str(protocolParameters.minUtxo),
      this.S.BigNum.from_str(protocolParameters.poolDeposit),
      this.S.BigNum.from_str(protocolParameters.keyDeposit),
      this.S.BigNum.from_str(protocolParameters.coinsPerUtxoWord),
      protocolParameters.maxValSize,
      protocolParameters.maxTxSize,
      protocolParameters.priceMem,
      protocolParameters.priceStep,
      this.S.LanguageViews.new(Buffer.from(languageViews, "hex"))
    );

It throws an error

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'new')

What do I do wrong here?

1 Answer 1

1

You should probably now use the ConfigBuilder to create a config for creating the TransactionBuilder.

This should do the trick:

const cfg = TransactionBuilderConfigBuilder.new()
      .fee_algo(this.S.LinearFee.new(
        this.S.BigNum.from_str(protocolParameters.linearFee.minFeeA),
        this.S.BigNum.from_str(protocolParameters.linearFee.minFeeB)
      ))
      .pool_deposit(this.S.BigNum.from_str(protocolParameters.poolDeposit))
      .key_deposit(this.S.BigNum.from_str(protocolParameters.keyDeposit))
      .max_tx_size(protocolParameters.maxTxSize)
      .max_value_size(protocolParameters.maxValSize)
      .coins_per_utxo_word(this.S.BigNum.from_str(protocolParameters.coinsPerUtxoWord))
      .build()

const txBuilder = this.S.TransactionBuilder.new(cfg);
3
  • It worked out. Thank you. Feb 8, 2022 at 10:00
  • the TransactionBuilderConfigBuilder is not part of @cardano/serialization-lib-asmjs .. does anyone know why ?
    – LKBH Pools
    Jun 7, 2022 at 15:38
  • Just checked and it should be there. Maybe double check the version you have installed. It must be one above 10.0.0 - try installing the latest (which is currently 10.2.0) via: npm i @emurgo/cardano-serialization-lib-asmjs@latest
    – sean
    Jun 7, 2022 at 16:57

Your Answer

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

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