I have an application call which contains inner transactions, written in PyTEAL.
I set the inner fee parameter to 0 so that the sender must pay for fees of the inner transaction and not use the funds held by the application.
InnerTxnBuilder.Begin(),
InnerTxnBuilder.SetFields(
{
TxnField.type_enum: TxnType.Payment,
TxnField.amount: amount,
TxnField.receiver: reciever,
# fee set to 0 to not use application funds
TxnField.fee: Int(0)
}
),
InnerTxnBuilder.Submit(),
But then it throws a fee too small
error, because I still need to modify the suggested parameters when I construct the transaction so that the user pays for the fees for the additional transactions.
I figured that I need to increase suggusted_params.fee
to include the fees of the inner transaction.
suggusted_params = algod.suggested_params()
# pay additional fee for one inner transaction
suggusted_params.fee = "???"
txn = transaction.ApplicationNoOpTxn(
sender=sender.address,
sp=suggusted_params,
index=application_id
)
But the question is, how do I calculate the fee for the transaction?
Unless I am mistaken:
suggusted_params.fee
is the fee per byte. However, the suggested params returns the value "fee": 0
on all networks, so we cannot calculate the required fees. (My intention was to multiply it by 2 since I have 1 inner transaction, but obviously cannot since the value is 0).
suggusted_params.min_fee
is the minimum fee that you must pay when the bytes*fee
is low. However, it is not useful either because I need the fee per byte, not the minimum network fee.
I have found that in the dev sandbox network, I need the fee to be at least 10. But I do not wish to use a static value because the fees might increase in the future.
Side note
Also, is this a good way to set an acceptable fee in PyTEAL? (Txn.fee is total fee, not fee per byte)
has_acceptable_fee = Txn.fee() <= Global.min_txn_fee() * Int(100)
Assert(has_acceptable_fee)
On another note, I think the interchangability of “suggested fee” (per byte) and “fee” might cause confusion in some cases.