user5724: 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}


user6769: 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.

5724: <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>
 6769: <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>
