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.
GasEstimate.ts
: This script estimates the gas used by theccipReceive
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.
- Node.js
- npm
- An Ethereum Sepolia RPC URL (place it in a
.env
file)
-
Clone the Repository:
git clone https://github.com/dannweeeee/ccipreceive-gaslimit.git cd ccipreceive-gaslimit
-
Install Dependencies:
npm install
-
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>
-
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.
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()
);