I have made an gh issue and I think it clarified a few things for me as well.
The fee parameter (fee-per-byte) returned by the API is indeed correct (it is zero until network congestion occurs). The fee-per-byte is NOT a problem.
Is this a bug?
As stated above, suggested_params.min_fee has no effect when passed into a transaction contructor (sp=suggested_params).
The reason for this is because py-algorand-sdk uses a constant (constants.min_txn_fee) instead of the min-fee which is stored in the object (sp.min_fee).
if not sp.flat_fee:
self.fee = max(
self.estimate_size() * self.fee, constants.min_txn_fee
)
I do not know if this is intentional or not, but it does make it so that the user cannot specify the minimum fee - and you need to use a flat fee instead.
How to calculate fees for inner transactions
For the time-being, if:
- You have inner transactions (with fees paid by the user)
- You want to make sure that your transactions adapt to increased fee-per-byte (due to network congestion)
- You want it to work with specific number of inner transactions
Then you need to do something like the following:
# Get txn info
num_bytes = transaction.ApplicationNoOpTxn(
sender=sender.address,
sp=client.suggested_params(),
index=application_id,
app_args=['return_to_sender']
).estimate_size()
num_txns = 5 # hard coded (1 outer + 4 inner)
# Calculate fee & get suggested params
suggusted_params = client.suggested_params()
suggusted_params.fee = max(
num_bytes * suggested_params.fee, # fee-per-byte
num_txns * suggusted_params.min_fee # min-fee
)
suggusted_params.flat_fee = True
# Construct transaction
txn = transaction.ApplicationNoOpTxn(
sender=sender.address,
sp=suggusted_params,
index=application_id,
app_args=['return_to_sender']
)
# ...
# sign and send
(I have not tested)
Otherwise, for 99% of cases, the simple answers will work fine.
I would be convenient to use suggested_parameters.min_fee though.