{"id":23636608,"url":"https://github.com/0xscratch/estimate_gas_ccip","last_synced_at":"2025-11-09T03:30:40.180Z","repository":{"id":254564960,"uuid":"846920687","full_name":"0xScratch/Estimate_Gas_CCIP","owner":"0xScratch","description":null,"archived":false,"fork":false,"pushed_at":"2024-08-24T11:36:21.000Z","size":54,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-28T06:13:55.146Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/0xScratch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-24T10:28:34.000Z","updated_at":"2024-08-25T19:29:27.000Z","dependencies_parsed_at":"2024-08-24T11:52:43.034Z","dependency_job_id":null,"html_url":"https://github.com/0xScratch/Estimate_Gas_CCIP","commit_stats":null,"previous_names":["0xscratch/estimate_gas_ccip"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xScratch%2FEstimate_Gas_CCIP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xScratch%2FEstimate_Gas_CCIP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xScratch%2FEstimate_Gas_CCIP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/0xScratch%2FEstimate_Gas_CCIP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/0xScratch","download_url":"https://codeload.github.com/0xScratch/Estimate_Gas_CCIP/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239565609,"owners_count":19660159,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-28T06:14:11.022Z","updated_at":"2025-11-09T03:30:40.147Z","avatar_url":"https://github.com/0xScratch.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Estimate_Gas_CCIP\n\nThis repository is the solution for the exercise given in [ChainLink Bootcamp Day-3](https://cll-devrel.gitbook.io/ccip-bootcamp/day-3/day-3-homework)\n\n## Problem Statement\n\nFollowing the [Optimizing gas](https://docs.chain.link/ccip/tutorials/ccipreceive-gaslimit) guide measure the gas consumption of the ccipReceive function. Once you have the number, increase it by 10% and provide as gasLimit parameter of the transferUsdc function instead of the currently hard-coded 500_000. Use [this](https://cll-devrel.gitbook.io/ccip-masterclass-4/ccip-masterclass/exercise-2-deposit-transferred-usdc-to-compound-v3#step-7-on-avalanchefuji-call-transferusdc-function) Gitbook for guidance.\n\n## Solution\n\nAfter the deployment of the desired contracts and following all those steps, we finally arrive to [Step 7](https://cll-devrel.gitbook.io/ccip-masterclass-4/ccip-masterclass/exercise-2-deposit-transferred-usdc-to-compound-v3#step-7-on-avalanchefuji-call-transferusdc-function) where we have to pass the estimated gaslimit instead of the hardcoded value of 500_000.\n\nIn order to reproduce the solution, we will be using Offchain method i.e. with the help of Tenderly. Here we go:\n\n1. First, follow up these [prerequisites](https://docs.chain.link/ccip/tutorials/ccipreceive-gaslimit#prerequisites-2) that will help you set up the environment variables and generate the necessary typings.\n\n2. I have already modified the `data.json` file and included addresses of both contracts i.e. `TransferUSDC.sol` as well as `CrossChainReciever.sol` which you can find in `contracts` directory.\n\n3. Now we are all set to run `npm run estimate-gas-tenderly` command. Here's what I got after running this command:\n\n    ```bash\n    \u003e estimate-gas-ccip@1.0.0 estimate-gas-tenderly D:\\Stuff\\chain\\Chainlink\\estimate-gas-ccip\\offchain\n    \u003e ts-node src/estimateGasTenderly.ts\n\n    Final Gas Usage Report:\n    Number of iterations: 0 - Gas used: 226054\n    Number of iterations: 50 - Gas used: 245954\n    Number of iterations: 99 - Gas used: 245954\n    ```\n\n4. Now, we have to increase the gas limit by 10% of 245954 which is `270550` approximately. And, this value will be filled up as a parameter like this:\n\n    ![transferUSDC](./assets/transferUSDC.png)\n\n5. Here's the transaction hash -\u003e `0x90f229fc151439527d5ad985f45240b9546561897b9ab63db668f1127950744d` which can be verified on [CCIP Explorer](https://ccip.chain.link/msg/0x200b0740742e8a26ddce3a3008343ac51c754daa900c078bed9527dda4c916ed).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xscratch%2Festimate_gas_ccip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F0xscratch%2Festimate_gas_ccip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F0xscratch%2Festimate_gas_ccip/lists"}