> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tenderly.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Оценка газа

> Оценивайте газ с помощью Simulation API через estimate_gas или получайте 100% точные лимиты через RPC-методы tenderly_estimateGas перед отправкой.

Simulation API позволяет вам симулировать транзакции и получать оценочный расход газа, необходимый для их успешного выполнения.

Установите `estimate_gas: true` в запросе, чтобы получить оценки газа.

<Note>
  Примечание: вы можете получить 100% точные оценки газа с помощью RPC-методов [**`tenderly_estimateGas`**](/node-rpc/rpc-reference?network=ethereum-mainnet\&method=tenderly_estimateGas) и [**`tenderly_estimateGasBundle`**](/node-rpc/rpc-reference?network=ethereum-mainnet\&method=tenderly_estimateGasBundle).
</Note>

**Пример**

Обязательно храните ключ доступа безопасно в файле `.env`.

```ts title="example.ts" showLineNumbers theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}

dotenv.config();

const { TENDERLY_ACCOUNT_SLUG, TENDERLY_PROJECT_SLUG, TENDERLY_ACCESS_KEY } = process.env;

const simulateTransaction = async () => {
  const { data } = await axios.post(
    `https://api.tenderly.co/api/v1/account/${TENDERLY_ACCOUNT_SLUG}/project/${TENDERLY_PROJECT_SLUG}/simulate`,
    {
      // Simulation Configuration
      save: true,
      save_if_fails: false,
      estimate_gas: true,
      simulation_type: 'quick',
      network_id: '1',
      // Standard EVM Transaction object (sample values)
      from: '0xdc6bdc37b2714ee601734cf55a05625c9e512461',
      to: '0x6b175474e89094c44da98b954eedeac495271d0f',
      input: '0x095ea7b3000000000000000000000000f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1f1000000000000000000000000000000000000000000000000000000000000012b',
      gas: 8000000,
      gas_price: 0,
      value: 0,
    },
    {
      headers: {
        'X-Access-Key': TENDERLY_ACCESS_KEY as string,
      },
    },
  );

  console.log({ data });
};

simulateTransaction();
```

Это вычисляет максимальный газ, необходимый для транзакции. После успешной симуляции проверьте поле `gas_used` в структуре `transaction`.

**Результат**

```json title="example.json" showLineNumbers theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
"transaction": {
    ...
    "gas": 8000000,
    "gas_price": 0,
    "gas_fee_cap": 0,
    "gas_tip_cap": 0,
    "cumulative_gas_used": 0,
    "gas_used": 51534, // Gas estimates
    "effective_gas_price": 0,
    ...
 }
```
