Skip to content

Commit

Permalink
phrasing
Browse files Browse the repository at this point in the history
  • Loading branch information
fadeev committed Nov 29, 2024
1 parent b24e787 commit 8c2e98d
Showing 1 changed file with 33 additions and 32 deletions.
65 changes: 33 additions & 32 deletions src/pages/developers/evm/gas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,30 @@ import { Alert } from "~/components/shared";

## Calling Universal Apps

When calling or depositing tokens to a universal app on ZetaChain through the
Gateway on a connected chain, you pay the fee in the native gas token of that
chain, similar to a standard transaction. There are no additional charges or
fees and execution of universal apps on ZetaChain can be considered gasless,
when a call is made from a connected chain.

For example, if you are depositing ETH from Ethereum to ZetaChain, the fee will
be in ETH. For more information on Ethereum gas and fees, refer to the [official
When interacting with a universal app on ZetaChain from a connected chain
through the Gateway, fees are paid in the native gas token of the source chain,
just like in standard transactions. There are no additional charges or fees, and
execution of universal apps on ZetaChain can be considered gasless, when a call
is made from a connected chain.

For instance, depositing ETH from Ethereum to ZetaChain incurs a fee in ETH,
aligning with Ethereum's usual gas fee structure. For detailed information on
Ethereum gas,, refer to the [official
documentation](https://ethereum.org/en/developers/docs/gas/).

If a contract on ZetaChain's EVM is called directly (not from a connected
chain), users need to include a fee for gas for each transaction. The gas market
mechanism for smart contracts on ZetaChain's EVM is similar to that of
[Ethermint](https://docs.ethermint.zone/basics/gas.html) and follows Ethereum's
EIP 1559 gas fee structure. This system is designed to deter spamming activities
on the network.
Direct calls to contracts on ZetaChain's EVM (not cross-chain calls) require
users to provide gas fees for each transaction. The ZetaChain EVM employs a gas
market mechanism inspired by
[Ethermint](https://docs.ethermint.zone/basics/gas.html) and adheres to
Ethereum's EIP 1559 fee model, which helps maintain network security and
prevents spam.

## Outgoing Calls and Withdrawals

When making a call from a universal app to a contract on a connected chain or
withdrawing ZRC-20 tokens back to a connected chain, the "withdraw gas fee" is
applicable.
Universal apps on ZetaChain can initiate calls to contracts on connected chains
or facilitate withdrawals of ZRC-20 tokens back to a connected chain. These
operations require a "withdraw gas fee," which is calculated based on the gas
limit of the target chain.

Before making a call from a universal app to a contract on a connected chain,
query the withdraw gas fee for the expected gas limit:
Expand All @@ -38,16 +40,11 @@ query the withdraw gas fee for the expected gas limit:
(address gasZRC20, uint256 gasFee) = IZRC20(zrc20).withdrawGasFeeWithGasLimit(gasLimit);
```

- `gasZRC20` is the address of the gas token of the chain to which the
call/withdrawal is being made. For example, both for Ethereum USDC and ETH the
gas ZRC-20 is ETH.
- `gasFee` is the amount of tokens that will be charged for the call/withdrawal
operation for the specified gas limit.

It's important to query an up-to-date gas amount before executing Gateway
call/withdraw/withdrawAndCall methods, have the gas fee amount of the gas ZRC-20
token and approve the Gateway to spend the amount. If the Gateway fails to
transfer the gas fee amount to itself, the outgoing call/withdrawal will fail.
- `gasZRC20` is the address of the gas token for the destination chain of the
call or withdrawal. For example, both for Ethereum USDC and ETH the gas token
is ZRC-20 ETH.
- `gasFee` is the required amount for the specified gas limit. This ensures you
can accurately estimate the necessary fees for successful execution.

Before withdrawing ZRC-20 tokens to a connected chain, query the withdraw gas
fee:
Expand All @@ -56,14 +53,18 @@ fee:
(address gasZRC20, uint256 gasFee) = IZRC20(zrc20).withdrawGasFee();
```

The withdraw call results in a token transfer on a connected chain, so it
doesn't need a gas limit.
Withdrawals to connected chains result in token transfers and do not require an
explicit gas limit.

It’s important to query the current gas fee, approve the Gateway to spend the
necessary amount, and ensure the gas ZRC-20 token balance is sufficient. If the
Gateway cannot transfer the required fee to itself, the operation will fail.

## Current Fees

In the table below you can see the current fees. The fees are defined in native
gas tokens on the destination chain (the chain to which ZRC-20 tokens are
withdrawn). The fees are calculated with the gas limit of 500000.
The table below displays the current withdraw gas fees, calculated using a
default gas limit of 500,000. Fees are represented in the native gas token of
the destination chain.

<Fees type="omnichain" />

Expand Down

0 comments on commit 8c2e98d

Please sign in to comment.