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}