Understanding tx fee

  1. If I send the following tx:
    let txn = { 
            to: recipient[0],
            fee: 1,
            amount: Number(recipient[1]),
            firstRound: params.lastRound,
            lastRound: endRound,
            genesisID: params.genesisID,
            genesisHash: params.genesishashb64
        };

https://testnet.algoexplorer.io/tx/IVBBW5OTGPM5PR35YUWROZ3QUA7O4QZU3UIFTP7RARBJRN557Z5A
I get the correct amount of fee: 0.001 Algos

If I send the following:

    let txn = { 
            to: recipient[0],
            fee: 10,
            ...
        };

then for some reason I get charged 0.00245 Algos
https://testnet.algoexplorer.io/tx/EZAOPQOW5QSJE36Z2LE2XSZTUKLLGSKKNPOWKJ5J4OCZURTK3ECQ

Why the fee is different?

Thanks for posting this question. The reason this is happening is because the js SDK fee is specified in micro algos per byte of the size of the transaction. In the first case the calculation is below the minimum transaction fee. I will try to get this documented on the website. Also I will log an issue to just set a total fee.

1 Like

how do I calculate the total amount of fee before I send a tx? So I know the total I will spend. Is there a thing like estimateGas ?
How do I know what fee I should specify? Is there a priority for tx fee? The higher the better? what are the boundaries?

@JasonW
why algod is very CPU hungry?

is your node up to date? run goal node status -d yourdatadirectory

I had to stop it

Last committed block: 261423
Time since last block: 0.1s
Sync Time: 4.3s
Last consensus protocol: https://github.com/algorandfoundation/specs/tree/5615adc36bad610c7f165fa2967f4ecfa75125f0
Next consensus protocol: https://github.com/algorandfoundation/specs/tree/5615adc36bad610c7f165fa2967f4ecfa75125f0
Round for next consensus protocol: 261424
Next consensus protocol supported: true
Genesis ID: testnet-v1.0
Genesis hash: SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=

Your node was catching up. He heavily parallelize catchup to do it as fast as possible. Once you catch up, your CPU will drop to single digits. The current round is > 450,000 so you’ll have to let it run a little longer. You can run ./carpenter -d <datadir> to watch it make progress.