Transaction With Payment¶
TransactionWithPayment
is a data structure that allows paying for the desired state transitions.
Definition¶
TransactionWithPayment
contains the following fields:
Type | ||
---|---|---|
stateTransitionFunction |
TransactionFunction |
The desired state update. |
paymentTransaction |
Transaction |
The payment transaction. It is unbalanced, contains consumed resources (gas payment sent) but not created (the receiver is not specified). Includes in a special application data field the hash of the transaction function and the gas limit. |
gasLimit |
Arithmetic |
The maximum amount of gas that can be used for execution of the StateTransition |
Execution¶
When executing a TransactionFunctionWithPayment
, the executor takes the following steps:
- Checks that
paymentTransaction
is “simple”. What exactly this means can be executor-specific, but roughly “simple” means “inexpensive to verify”. A basic (very restrictive) check could be that the payment transaction has exactly one consumed resource and nothing else. - Decide whether this gas payment is sufficient. This decision can be controller-specific (maybe there are certain assets and certain prices accepted for gas).
- Alter
paymentTransaction
, adding new resources assigned to the executor (or whoever is supposed to receive the gas payments) as necessary to make the payment transaction balanced. - Verify
paymentTransaction
, including in a special application data field the hash of the transaction function and the gas limit. - Execute
paymentTransaction
(apply the state changes). - Evaluate
stateTransitionFunction
, limited bygasLimit
. - If
stateTransitionFunction
evaluation finishes withingasLimit
(returning a transaction object), check that the transaction object is valid and balanced (gas is charged for these checks as well), and if so apply it to state (as previously in the RM).