Skip to content

Latest commit

 

History

History
66 lines (44 loc) · 1.86 KB

README.md

File metadata and controls

66 lines (44 loc) · 1.86 KB

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/dannweeeee/ccipreceive-gaslimit.git
    cd ccipreceive-gaslimit
  2. Install Dependencies:

    npm install
  3. 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>
  4. 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()
);