<p>When you initialized the CSL you should  enter the protocol parameters.</p>
<p>That is the first place I would be looking at.</p>
<blockquote>
<p>const txBuilderCfg = CardanoWasm.TransactionBuilderConfigBuilder.new()
.fee_algo(linearFee)
.pool_deposit(CardanoWasm.BigNum.from_str('500000000'))
.key_deposit(CardanoWasm.BigNum.from_str('2000000'))
.max_value_size(4000)
.max_tx_size(8000)
.coins_per_utxo_word(CardanoWasm.BigNum.from_str('34482'))
.build();</p>
</blockquote>
<p>Also fee structures changed with the Vasil hard-fork. So if you have not updated your CLS to the latest version it will probably not calculate the fees corectly.</p>

CC BY-SA 4.0
2022-10-31T19:08:52.447Z
Hi Leo, thanks for the input. That is also what i thought, however other transactions  calculate fee correctly.  I have the parameters:

        this.protocolParams = {
            linearFee: {
                minFeeA: "44",
                minFeeB: "155381",
            },
            minUtxo: "34482",
            poolDeposit: "500000000",
            keyDeposit: "2000000",
            maxValSize: 5000,
            maxTxSize: 16384,
            priceMem: 0.0577,
            priceStep: 0.0000721,
            coinsPerUtxoWord: "34482",
        }
Why_Is_This_Hard
CC BY-SA 4.0
2022-10-31T17:33:48.983Z
2022-10-31T17:33:48.983Z
Leo
<p>I encountered this same issue:
Fee too small required vs actual.
I sent the available ADA in the wallet to itself....i.e. an 'internal' transfer?
After doing that, the fee too small error did not occur.
I suspect it has something to do with how there was not enough ADA in any one utxo that was selected for use in the tx - but I ma not sure.
Doing that consolidated the available ADA into a single utxo though, and that was what allowed me to get past the &quot;fee too small&quot; error.</p>

CC BY-SA 4.0
2023-04-04T02:18:41.997Z
2023-04-04T02:18:41.997Z
RelevantData
<p>Having some issues getting a submit Stake Registration certificate using cardano-serialization-lib. The transaction builds, can can be signed, but what's weird is the correct fee is not being calculated. I have a console.log output of the fee that is being calculated at &quot;calculated fee:166953&quot; but the network is asking for 171177</p>
<p>Error: {&quot;requiredFee&quot;:171177,&quot;actualFee&quot;:166953}</p>
<p>Any ideas why the fee is not being calculated correctly by CSL ?</p>
<pre><code>buildStakeRegistrationTransaction = async () =&gt; {

        const txBuilder = await this.initTransactionBuilder();
        const shelleyChangeAddress = Address.from_bech32(this.state.changeAddress);

        //obtaining my payment address
        const baseAddress = BaseAddress.from_address(Address.from_bech32(this.state.changeAddress));


        // Find the available UTXOs in the wallet and
        // us them as Inputs
        const txUnspentOutputs = await this.getTxUnspentOutputs();
        txBuilder.add_inputs_from(txUnspentOutputs, 1)

  
        const certs = Certificates.new();

        //Adding StakeRegistration Certificate
        certs.add(
            Certificate.new_stake_registration(
                StakeRegistration.new(
                    baseAddress.stake_cred()
                )
            )
        );

        txBuilder.set_certs(certs)  
    
        txBuilder.add_change_if_needed(Address.from_bech32(this.state.changeAddress))

        const txBody = txBuilder.build();

        //
        console.log(&quot;calculated fee:&quot; + txBuilder.get_fee_if_set().to_str() );

        // add witness --&gt; shouldnt really be needed as its just a StakeReg cert ?
        const transactionWitnessSet = TransactionWitnessSet.new();
        const tx = Transaction.new(
            txBody,
            TransactionWitnessSet.from_bytes(transactionWitnessSet.to_bytes())
        )

        // transaction witness / sign:
        let txVkeyWitnesses = await this.API.signTx(Buffer.from(tx.to_bytes(), &quot;utf8&quot;).toString(&quot;hex&quot;), true);
        console.log(&quot;txVkeyWitnesses:&quot; + txVkeyWitnesses)
        txVkeyWitnesses = TransactionWitnessSet.from_bytes(Buffer.from(txVkeyWitnesses, &quot;hex&quot;));
        transactionWitnessSet.set_vkeys(txVkeyWitnesses.vkeys());
    

        const signedTx = Transaction.new(
            tx.body(),
            transactionWitnessSet
        );

        // submit TX:
        const submittedTxHash = await this.API.submitTx(Buffer.from(signedTx.to_bytes(), &quot;utf8&quot;).toString(&quot;hex&quot;));
        console.log(&quot;Submitted TX Hash:&quot; + submittedTxHash)
        this.setState({submittedTxHash});

}
</code></pre>
<p>Error:</p>
<pre><code>Uncaught (in promise) Error: submit tx failed: Error: 400:
0: {&quot;requiredFee&quot;:171177,&quot;actualFee&quot;:166953}
</code></pre>

<cardano-serialization-lib><cardano-address>
Calculated fee too small for StakeRegistration cert submission via cardano-serialization-lib wallet connect
# Calculated fee too small for StakeRegistration cert submission via cardano-serialization-lib wallet connect

(Asked by: username_0 on 2022-10-31)

Having some issues getting a submit Stake Registration certificate using cardano-serialization-lib. The transaction builds, can can be signed, but what's weird is the correct fee is not being calculated. I have a console.log output of the fee that is being calculated at "calculated fee:166953" but the network is asking for 171177
Error: {"requiredFee":171177,"actualFee":166953}
Any ideas why the fee is not being calculated correctly by CSL ?
buildStakeRegistrationTransaction = async () => {

        const txBuilder = await this.initTransactionBuilder();
        const shelleyChangeAddress = Address.from_bech32(this.state.changeAddress);

        //obtaining my payment address
        const baseAddress = BaseAddress.from_address(Address.from_bech32(this.state.changeAddress));


        // Find the available UTXOs in the wallet and
        // us them as Inputs
        const txUnspentOutputs = await this.getTxUnspentOutputs();
        txBuilder.add_inputs_from(txUnspentOutputs, 1)

  
        const certs = Certificates.new();

        //Adding StakeRegistration Certificate
        certs.add(
            Certificate.new_stake_registration(
                StakeRegistration.new(
                    baseAddress.stake_cred()
                )
            )
        );

        txBuilder.set_certs(certs)  
    
        txBuilder.add_change_if_needed(Address.from_bech32(this.state.changeAddress))

        const txBody = txBuilder.build();

        //
        console.log("calculated fee:" + txBuilder.get_fee_if_set().to_str() );

        // add witness --> shouldnt really be needed as its just a StakeReg cert ?
        const transactionWitnessSet = TransactionWitnessSet.new();
        const tx = Transaction.new(
            txBody,
            TransactionWitnessSet.from_bytes(transactionWitnessSet.to_bytes())
        )

        // transaction witness / sign:
        let txVkeyWitnesses = await this.API.signTx(Buffer.from(tx.to_bytes(), "utf8").toString("hex"), true);
        console.log("txVkeyWitnesses:" + txVkeyWitnesses)
        txVkeyWitnesses = TransactionWitnessSet.from_bytes(Buffer.from(txVkeyWitnesses, "hex"));
        transactionWitnessSet.set_vkeys(txVkeyWitnesses.vkeys());
    

        const signedTx = Transaction.new(
            tx.body(),
            transactionWitnessSet
        );

        // submit TX:
        const submittedTxHash = await this.API.submitTx(Buffer.from(signedTx.to_bytes(), "utf8").toString("hex"));
        console.log("Submitted TX Hash:" + submittedTxHash)
        this.setState({submittedTxHash});

}

Error:
Uncaught (in promise) Error: submit tx failed: Error: 400:
0: {"requiredFee":171177,"actualFee":166953}

**Tags:** cardano-serialization-lib, cardano-address

---

## 2 answers

### Answer by username_1 on 2022-10-31. Score: 1

When you initialized the CSL you should enter the protocol parameters.

That is the first place I would be looking at.

> const txBuilderCfg = CardanoWasm.TransactionBuilderConfigBuilder.new()
> .fee\_algo(linearFee)
> .pool\_deposit(CardanoWasm.BigNum.from\_str('500000000'))
> .key\_deposit(CardanoWasm.BigNum.from\_str('2000000'))
> .max\_value\_size(4000)
> .max\_tx\_size(8000)
> .coins\_per\_utxo\_word(CardanoWasm.BigNum.from\_str('34482'))
> .build();

Also fee structures changed with the Vasil hard-fork. So if you have not updated your CLS to the latest version it will probably not calculate the fees corectly.

> **Comments:**
> **username_0**: Hi Leo, thanks for the input. That is also what i thought, however other transactions  calculate fee correctly.  I have the parameters:          this.protocolParams = {             linearFee: {                 minFeeA: "44",                 minFeeB: "155381",             },             minUtxo: "34482",             poolDeposit: "500000000",             keyDeposit: "2000000",             maxValSize: 5000,             maxTxSize: 16384,             priceMem: 0.0577,             priceStep: 0.0000721,             coinsPerUtxoWord: "34482",         }  

---

### Answer by username_2 on 2023-04-04. Score: 0

I encountered this same issue:
Fee too small required vs actual.
I sent the available ADA in the wallet to itself....i.e. an 'internal' transfer?
After doing that, the fee too small error did not occur.
I suspect it has something to do with how there was not enough ADA in any one utxo that was selected for use in the tx - but I ma not sure.
Doing that consolidated the available ADA into a single utxo though, and that was what allowed me to get past the "fee too small" error.


---

