o1js icon indicating copy to clipboard operation
o1js copied to clipboard

Specify fee per weight unit

Open mitschabaude opened this issue 9 months ago • 1 comments

https://discord.com/channels/484437221055922177/1234429008427618387/1234765711298007071

can we add to Mina.transaction the possibility to specify the fee per weight unit instead of fee per transaction? According to the explanation above, the market fee will be fee/wu, and to get the tx fee right, we need to know the number of account updates, which is finally known only after the tx is created.

mitschabaude avatar Apr 30 '24 07:04 mitschabaude

Given that market conditions can change fast, there should also be a way to resend the tx with an increased fee, something like:

const txSent = await tx.send();
const json = txSent.toJSON();

// 10 min later, if tx is not included in the book due to fee fluctuations
const tx1 = Mina.Transaction.fromJSON(
    JSON.parse(json)
  ) as Mina.Transaction;
tx1.setFee(increasedFeePerWU) // tx1.feePayer.body.fee = increasedFeePerWU * accountUpdatesNum;
const txSent1 = await tx1.sign([privateKey]).send();

dfstio avatar May 01 '24 06:05 dfstio