Skip to content

Commit

Permalink
Update freegas.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
juntao committed Mar 24, 2019
1 parent 2271bfa commit b2a84b4
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions docs/freegas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ Because `freegas` will consume the contract balance for the transaction fee, Dap
How Virtual Machine handles the freegas function
------------------------------------------------

When ``freegas`` is triggered, VM will follow these rules to calculate
transaction fee:
if Balance(Callee contract) >= transaction fee,
then Use Balance(Calle contract) to pay the fee
and refund all of the reserved balance
else
then Use origin tx gas to pay the fee
and refund the remaining balance
The blockchain could pass ``gasPrice=0`` transactions to the VM to signal that the caller has requested a ``freegas`` function call. Learn more about `free transactions <https://travis.readthedocs.io/en/latest/transactions.html#free-transactions>` The VM now performs the following actions.

* If ``gasLimit < 5000000``, it will just process it normally. The caller's gas fee will be 0.
* If ``gasLimit > 5000000``, it will require the contract function to be ``freegas``
* The call consumes a max of ``(default gasPrice) * gasLimit`` amount of gas
* the TX fails if the function is not ``freegas``
* the TX fails if the contract does not have enough fund to cover gas

The gas fee for caller is ALWAYS 0 in this case.


Example 1
---------
Expand Down

0 comments on commit b2a84b4

Please sign in to comment.