Skip to content

zqgdrmq/measure-gas-consumption-ccipReceive-

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chainlink CCIP Gas Estimation and TransferUSDC Update

This repository contains a script to estimate the gas consumption of the ccipReceive function and increase the gas limit for the transferUsdc function by 10%. The increased gas limit is used to ensure the transferUsdc function has enough gas for execution.

Project Structure

  • GasEstimate.ts: This script estimates the gas used by the ccipReceive function, increases it by 10%, and logs the results.
  • config.ts: Configuration file for the CCIP settings.
  • helper.ts: Helper functions for building transaction data and estimating intrinsic gas.

Prerequisites

  • Node.js
  • npm
  • An Ethereum Sepolia RPC URL (place it in a .env file)

Getting Started

  1. Clone the Repository:

    git clone https://github.com/Signor1/ccipreceive-gaslimit.git
    cd ccipreceive-gaslimit
  2. Install Dependencies:

    npm install
  3. To address an issue with importing CrossChainReceiver__factory from '../typechain-types', you need to ensure that the TypeScript type definitions have been correctly generated and are available in the specified path.

   npx hardhat typechain 
  1. Set Up Environment Variables:

    For the script, create a .env file in the root of your project and add your Ethereum Sepolia RPC URL:

    ETHEREUM_SEPOLIA_RPC_URL=<Your Ethereum Sepolia RPC URL>
  2. Run the Script:

    Use the following command to estimate the gas usage and calculate the increased gas limit:

    npm run estimate

    The script will output the estimated gas used by the ccipReceive function and the increased gas limit.

Usage Example

The script will log the following:

  • The estimated gas used by the ccipReceive function.
  • The gas limit after applying a 10% increase.

You can then use the increasedGasLimit in the transferUsdc contract function as shown in the commented section of the script:

const transferUsdcTx = await transferUsdcContract.transferUsdc(
  destinationChainSelector,
  receiverAddress,
  amount,
  increasedGasLimit.toString()
);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published