Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Estimate gas from within smart contract

Let’s assume that a smart contract A is deployed in Moonbeam and a smart contract B is deployed in Binance Smart Chain.

Contract A sends transactions to contract B and vice versa like a ping-pong game.
As long as both contracts A and B can estimate Gas accurately they can keep playing ping-pong until they run out of funds

Question: Is there a way to safely estimate gas from within sc A before sending the tx to scB?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Note: I am aware of how to estimateGasFee from front end using Axelar JS SDK

>Solution :

You can only use the estimateGasFee method provided by the Axelar JS SDK. However, there is no direct way to estimate gas fees within a smart contract itself.

Since the transaction is going through the Axelar network -> destination chain and your solidity code only has access to data about the source chain, we can only access data via the Axelarjs SDK, not natively in your solidity code.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading