# Transaction Calculation
# Intrinsic Gas Calculation
The intrinsic gas for a transaction is the amount of the transaction used before any code runs. in other words, it's a constant "transaction fee" plus a fee for every byte of data supplied with the transaction.The gas in the transaction needs to be greater than or equal to the intrinsic gas used by the transaction.
is the constant transaction fee 5,000 - There are two types of
- Regular transaction : 16,000
- Contract creation : 48,000
is the number of bytes equal to zero within the data in the clause and the number of bytes not equal to zero
# Total Transaction Gas Calculation
VeChainThor clauses allows a single transaction to carry out multiple tasks. Therefore, it needs to execute all the clauses cost in the transaction.
The total gas,
where
There are two types of
- Regular transaction : 16,000
- Contract creation : 48,000
is the number of bytes equal to zero within the data in the clause and the number of bytes not equal to zero
is the gas cost returned by the virtual machine for executing the clause.
# Proof of Work
VeChainThor allows the transaction-level proof of work and converts the proved work into extra gas price that will be used by the system to generate more reward to the block generator that validates the transaction. In other words, users can utilize their local computational power to make their transactions more likely to be included in a new block.
In particular, the computational work can be proved through fields Nonce
and BlockRef
in the transaction model. Let Nonce
and Gas
, respectively. We use BlockRef
and Nonce
and Signature
,
The PoW,
The extra gas price,
with the following constraint
The VTHO reward
where
From the above equations, we know that
- Since
is a valid block number,BlockRef
must refer to an existing block, that is, its value must equal the first four bytes of an existing block ID; - The TX must be packed into a block within the period of 30 blocks after block
, or otherwise, the PoW would not be recognized by the system; - The extra gas price
can not be greater than base gas price P.
# Total Gas Price
The total gas price for the transaction sender is computed as:
and the total price for block generators as
GasPriceCoef
(is the bounded interval between 0-255) and It can be seen that the gas price used to calculate the transaction cost depends solely on the input gas-price coefficient while the reward for packing the transaction into a block varies due to the transaction-level proof-of-work mechanism.