# Onchain Gas Transaction

## Types of transactions <a href="#types-of-transactions" id="types-of-transactions"></a>

On DaVinci there are a few different types of transactions:

* Regular transactions: a transaction from one account to another.
* Contract deployment transactions: a transaction without a 'to' address, where the data field is used for the contract code.
* Execution of a contract: a transaction that interacts with a deployed smart contract. In this case, 'to' address is the smart contract address.

### On gas <a href="#on-gas" id="on-gas"></a>

As mentioned, transactions cost gas to execute. Simple transfer transactions require ***21000 units*** of Gas.

So for Bob to send Alice 1 DCOIN at a `baseFeePerGas` of 190 gwei and `maxPriorityFeePerGas` of 10 gwei, Bob will need to pay the following fee:

```mathematica
(190 + 10) * 21000 = 4,200,000 gwei
--or--
0.0042 DCOIN
```

* Bob's account will be debited **-1.0042 DCOIN** (1 DCOIN for Alice + 0.0042 DCOIN in gas fees)
* Alice's account will be credited **+1.0 DCOIN**
* The base fee will be burned **-0.00399 DCOIN**
* Validator keeps the tip **+0.000210 DCOIN**

<figure><img src="https://396162852-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHuSW6in7Iwg0f9o5fa3q%2Fuploads%2Fd95xSqbQThjQd5Lk1P3m%2Fonchain-txs.png?alt=media&#x26;token=5eeb76f0-0a4a-48b5-bfb5-d3d1efd8d0c8" alt=""><figcaption><p>DaVinci Virtual Machine Ilustrated</p></figcaption></figure>

### Block size <a href="#block-size" id="block-size"></a>

Each block has a target size of 15 million gas, but the size of blocks will increase or decrease in accordance with network demand, up until the block limit of 30 million gas (2x the target block size). The protocol achieves an equilibrium block size of 15 million on average through the process of *tâtonnement*. This means if the block size is greater than the target block size, the protocol will increase the base fee for the following block. Similarly, the protocol will decrease the base fee if the block size is less than the target block size. The amount by which the base fee is adjusted is proportional to how far the current block size is from the target. More on blocks.

### Base fee <a href="#base-fee" id="base-fee"></a>

Every block has a base fee which acts as a reserve price. To be eligible for inclusion in a block the offered price per gas must at least equal the base fee. The base fee is calculated independently of the current block and is instead determined by the blocks before it - making transaction fees more predictable for users. When the block is created this **base fee is "burned"**, removing it from circulation.

The base fee is calculated by a formula that compares the size of the previous block (the amount of gas used for all the transactions) with the target size. The base fee will increase by a maximum of 12.5% per block if the target block size is exceeded. This exponential growth makes it economically non-viable for block size to remain high indefinitely.

### EIP-1559

The base fee on DaVinci is, like Ethereum, computed via the [EIP-1559](https://notes.ethereum.org/@vbuterin/eip-1559-faq) mechanism. The EIP-1559 parameters used by DaVinci differ from those used by Ethereum as follows.

<table><thead><tr><th width="251" align="center">Parameter</th><th align="center">DaVinci Value</th><th align="center">Ethereum Value </th></tr></thead><tbody><tr><td align="center">Block gas limit</td><td align="center">30,000,000 gas</td><td align="center">30,000,000 gas</td></tr><tr><td align="center">Block gas target</td><td align="center">5,000,000 gas</td><td align="center">15,000,000 gas</td></tr><tr><td align="center">EIP-1559 elasticity multiplier</td><td align="center">6</td><td align="center">2</td></tr><tr><td align="center">EIP-1559 denominator</td><td align="center">250</td><td align="center">8</td></tr><tr><td align="center">Maximum base fee increase (per block)</td><td align="center">2%</td><td align="center">12.5%</td></tr><tr><td align="center">Maximum base fee decrease (per block)</td><td align="center">0.4%</td><td align="center">12.5%</td></tr><tr><td align="center">Block time in seconds</td><td align="center">2</td><td align="center">12</td></tr></tbody></table>
