Skip to content

Gas fees estimation on connected chains #467

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fadeev opened this issue Mar 7, 2025 · 2 comments
Open

Gas fees estimation on connected chains #467

fadeev opened this issue Mar 7, 2025 · 2 comments

Comments

@fadeev
Copy link
Member

fadeev commented Mar 7, 2025

Implement a system where a contract on a connected chain A can make an on-chain call (let's say to the Gateway on chain A) to get a fee amount required to make a call to chain B.

Right now, for example, when making a call from chain A to chain B (through ZetaChain, of course), a contract on chain A needs the fee amount to be submitted by a user/end-user app.

On ZetaChain gas fees can be queried from ZRC-20s:

function withdrawGasFeeWithGasLimit(uint256 gasLimit) public view override returns (address, uint256) {
address gasZRC20 = ISystem(SYSTEM_CONTRACT_ADDRESS).gasCoinZRC20ByChainId(CHAIN_ID);
if (gasZRC20 == address(0)) revert ZeroGasCoin();
uint256 gasPrice = ISystem(SYSTEM_CONTRACT_ADDRESS).gasPriceByChainId(CHAIN_ID);
if (gasPrice == 0) {
revert ZeroGasPrice();
}
uint256 gasFee = gasPrice * gasLimit + PROTOCOL_FLAT_FEE;
return (gasZRC20, gasFee);
}

I think we need the same functionality to be available on connected chains.

Ideally, the gas fee amount required to make a call to chain B, is reported on chain A in the gas token of chain A.

Gas prices are regularly updated by observer-signer validators and are stored in the crosschain module state:

https://zetachain.blockpi.network/lcd/v1/public/zeta-chain/crosschain/gasPrice

I assume that if we set up a system where this information is transferred to connected chains (either by observer-signer validators, or as a CCTX), it should do the trick.

How other projects are handling this:

@lumtis
Copy link
Member

lumtis commented Mar 10, 2025

This is a complex task that also has a tokenomic aspect: how to fund the fees for pushing the gas price.

In most isn't enough for the developer to have access to this value with a query and so set this value from the front-end when performing the deposit?

@fadeev
Copy link
Member Author

fadeev commented Mar 10, 2025

It is possible to set the value from the frontend, so I'd say this is a nice to have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants