# Gas

**Gas** is the unit that measures the **computational workload** required to execute transactions or contracts on the **ENI network**.&#x20;

***

## Key Terms and Concepts

**Gas**

Gas is a measure of the amount of work required to execute a transaction, and its value varies according to the complexity of the transaction being executed.

***

**Gas Price**

Gas Price refers to the amount of **$ENI** a user is willing to pay per unit of gas.

Users can set the **gas price** to influence transaction fees.

***

**Gas Limit**

**Gas limit** is the maximum amount of gas a user wants to use for a transaction. If the gas limit is set too low, a node attempting to execute the transaction will run out of gas, fail to complete the transaction, and consume the entire specified gas limit.

***

**Fees**

**Fees = Gas Price \* Gas Limit**.

* ```bash
  curl -H "Authorization: your-apikey-here" https://api.blocknative.com/gasprices/blockprices?chainid=$CHAIN_ID
  ```

***

**Maximum Gas**

The maximum gas limit for transactions ensures that complex transactions do not consume excessive resources. You can query an RPC node using `/consensus_params` (i.e., <https://rpc.eniac.network/consensus\\_params>) to find the maximum gas limit for each chain.

***

**Minimum Gas Price**

ENI enforces a minimum gas price to prevent junk transactions. These prices are set by chain.

***

**Maximum Byte Size**

Each transaction has a maximum byte limit, defined by each chain. This limit can be retrieved by querying the `/consensus_params` endpoint of an RPC node.

***

**Maximum Gas Limit for Queries**

Since queries also consume gas, they have a maximum gas limit. This limit is specific to each RPC provider, so check with your provider to determine the maximum gas limit for your query.

***

#### Sending Gas in Transactions

When submitting a transaction for broadcast, the user needs to specify the gas price and the gas limit to determine the fee.

***

**Using enid**

When using enid, fees are set via the `--fees` flag, and gas limits and gas prices can be set via the `--gas` and `--gas-prices` flags, respectively.

```bash
enid tx bank send <from_address> <to_address> <amount> --gas <gas_limit> --gas-prices <gas_price> --fees <fee>
```

***

**Using CosmJS**

In any CosmJS transaction, the gas fee must be specified using the `StdFee` object.

```js
const fee = {
  amount: [{ denom: 'ueni', amount: '5000' }],
  gas: '200000'
};
const result = await client.signAndBroadcast(address, [msg], fee, memo);
```

***

**Using EVM (wagmi)**

```js
import { sendTransaction } from 'wagmi/actions';

sendTransaction({
  request: {
    to: '0xRecipientAddress',
    value: '1000000000000000000',   // 1 ENI
    gasPrice: '100000000000',       // 100 Gwei
    gasLimit: '21000'
  }
});
```

***

## Optimizing Gas Prices for Smart Contracts

**Best Practices for Efficient Gas Usage:**

* **Minimize storage operations:** Storage is expensive in terms of gas.
* **Use fixed-size data structures:** They are more gas-efficient.
* **Avoid unnecessary computations:** Streamline your smart contract logic.

Optimizing gas usage ensures **lower costs** and **faster execution** for smart contracts on the ENI network.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.eniac.network/getting-started/quickstart/gas.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
