Skip to content

Commit

Permalink
add component to all guides/tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
gfletcher-cll committed Feb 7, 2025
1 parent 5ee4864 commit 059b56f
Show file tree
Hide file tree
Showing 22 changed files with 50 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/content/ccip/ccip-javascript-sdk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ title: "Using the CCIP JavaScript SDK"

import { Aside, ClickToZoom } from "@components"
import { Tabs } from "@components/Tabs"
import { EducationalDisclaimer } from "@components"
import CcipCommon from "@features/ccip/CcipCommon.astro"

The [CCIP JavaScript SDK][def] is a tool that helps you to simplify management of cross-chain token transfers, and to integrate CCIP with the frontend of your own app.

Expand Down Expand Up @@ -285,4 +285,4 @@ You can use `pnpm build` to build both packages together. If you're building eac
"@chainlink/ccip-react-components": "link:../../packages/ccip-react-components",
```

<EducationalDisclaimer />
<CcipCommon callout="educationalDisclaimer" />
3 changes: 3 additions & 0 deletions src/content/ccip/test-tokens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ title: "Acquire Test Tokens"

import { ClickToZoom, Aside } from "@components"
import { MintTokenButton } from "@features/ccip/components/MintTokenButton"
import CcipCommon from "@features/ccip/CcipCommon.astro"

As a best practice, always test your applications thoroughly on testnet before going live on mainnet. When testing token transfers, you must have enough tokens and ensure the [token pools](/ccip/architecture#token-pools) have enough funds. Public faucets sometimes limit how many tokens a user can create and token pools might not have enough liquidity. To resolve these issues, CCIP supports two test tokens that you can mint permissionlessly so you don't run out of tokens while testing different scenarios.

Expand Down Expand Up @@ -79,3 +80,5 @@ Follow these steps to learn how to mint these tokens. The steps explain how to m
/>

- Follow this [MetaMask guide](https://support.metamask.io/hc/en-us/articles/360015489031#h_01FWH492CHY60HWPC28RW0872H) to import _CCIP-BnM_ in your wallet.

<CcipCommon callout="educationalDisclaimer" />
4 changes: 4 additions & 0 deletions src/content/ccip/tutorials/ccipreceive-gaslimit.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ date: Last Modified
title: "Optimizing Gas Limit Settings in CCIP Messages"
---

import CcipCommon from "@features/ccip/CcipCommon.astro"

When constructing a [CCIP message](/ccip/api-reference/v1.5.1/client#evm2anymessage), it's crucial to set the gas limit accurately. The gas limit represents the maximum amount of gas consumed to execute the [`ccipReceive`](/ccip/api-reference/v1.5.1/ccip-receiver#ccipreceive) function on the CCIP Receiver, which influences the transaction fees for sending a CCIP message. Notably, unused gas is not reimbursed, making it essential to estimate the gas limit carefully:

- Setting the gas limit too low will cause the transaction to revert when CCIP calls `ccipReceive` on the CCIP Receiver, which requires a manual re-execution with an increased gas limit. For more details about this scenario, read the [Manual Execution](/ccip/tutorials/manual-execution) guide.
Expand Down Expand Up @@ -540,3 +542,5 @@ As we have explored various methods for estimating gas for the `ccipReceive` fun
1. **Comprehensive Testing:** Emphasize testing under diverse scenarios to ensure your gas estimations are robust. Different conditions can significantly affect gas usage, so covering as many cases as possible in your tests is crucial.
1. **Preliminary Local Estimates:** Local testing is a critical first step for estimating gas and ensuring your contracts function correctly under various scenarios. While Hardhat and Foundry facilitate development and testing, it's key to remember that these environments may not perfectly mirror your target blockchain's conditions. These initial estimates serve as valuable insights, guiding you toward more accurate gas limit settings when you proceed to testnet validations. Incorporating a buffer based on these preliminary results can help mitigate the risks of underestimating gas requirements due to environmental differences.
1. **Efficiency with Offchain Methods:** Since testing across different blockchains can be resource-intensive, leaning on offchain methods for gas estimation is invaluable. Tools such as Tenderly not only facilitate rapid and accurate gas usage insights on your target blockchains but also enable you to simulate the execution of the `ccipReceive` function on actual contracts deployed on mainnets. If Tenderly doesn't support a particular blockchain, a practical alternative is to use a Web3 provider that does support that chain, as illustrated in the [Estimate gas using a Web3 provider](#estimate-gas-using-a-web3-provider) section. This is particularly helpful when considering the diversity in gas metering rules across blockchains. This approach saves time and enhances the precision of your gas limit estimations, allowing for more cost-effective transactions from your dApp.

<CcipCommon callout="educationalDisclaimer" />
2 changes: 2 additions & 0 deletions src/content/ccip/tutorials/cross-chain-tokens/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,5 @@ The tutorials will implement the logic of this process, which involves deploying

- [Register from a Safe (Burn & Mint)](/ccip/tutorials/cross-chain-tokens/register-from-safe-burn-mint-hardhat): Learn how to register a cross-chain token with the **Burn & Mint** mechanism using a Safe Smart Account.
- [Hardhat version](/ccip/tutorials/cross-chain-tokens/register-from-safe-burn-mint-hardhat)

<CcipCommon callout="educationalDisclaimer" />
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,5 @@ Check status of the message at https://ccip.chain.link/msg/2895eae406f09dd2a9997
```

You can check the status of the message on the [Chainlink CCIP Explorer](https://ccip.chain.link/) using the message ID provided in the output.

<CcipCommon callout="educationalDisclaimer" />
Original file line number Diff line number Diff line change
Expand Up @@ -499,3 +499,5 @@ Example output:
2024-12-02T20:57:45.288Z info: ✅ Transferred 100 of 0x16F6b0f41b9217857551e29F38F99975a2fc9add to 0x9d087fC03ae39b088326b67fA3C788236645b717 on chain arbitrumSepolia. Transaction hash: 0xa68375fc560f8910b1c6dda8d6765d0bebd02e2de91f763188e529b5eb007ab4 - CCIP message id: 0xdbf8a93ed33c726d866478ef9c492b5dbba65eb62192a42b63743ce3af86e443
2024-12-02T20:57:45.288Z info: Check status of message on https://ccip.chain.link/msg/0xdbf8a93ed33c726d866478ef9c492b5dbba65eb62192a42b63743ce3af86e443
```

<CcipCommon callout="educationalDisclaimer" />
Original file line number Diff line number Diff line change
Expand Up @@ -427,3 +427,5 @@ You can check the status of the message on the [Chainlink CCIP Explorer](https:/
Your tokens have been locked on the token pool on Avalanche Fuji, the corresponding tokens have been minted on Arbitrum Sepolia and sent to your receiver address.

Note: Since your Lock & Release token pool on Avalanche Fuji has locked some tokens, you can transfer tokens from Arbitrum Sepolia to Avalanche Fuji using CCIP as an exercise. Your tokens will be burned on Arbitrum Sepolia, and the corresponding tokens will be released on Avalanche Fuji. Make sure not to transfer more tokens than the amount of tokens locked in the token pool on Avalanche Fuji.

<CcipCommon callout="educationalDisclaimer" />
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,5 @@ Example output:
Your tokens have been locked on the token pool on Avalanche Fuji, the corresponding tokens have been minted on Arbitrum Sepolia and sent to your receiver address.
Note: Since your Lock & Release token pool on Avalanche Fuji has locked some tokens, you can transfer tokens from Arbitrum Sepolia to Avalanche Fuji using CCIP as an exercise. Your tokens will be burned on Arbitrum Sepolia, and the corresponding tokens will be released on Avalanche Fuji. Make sure not to transfer more tokens than the amount of tokens locked in the token pool on Avalanche Fuji.
<CcipCommon callout="educationalDisclaimer" />
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
GrantPrivilegesStep,
} from "@components/CCIP/TutorialBlockchainSelector"
import { PrerequisitesCard, ContractsImportCard, SetupSection, TutorialCard } from "@components/CCIP/TutorialSetup"
import CcipCommon from "@features/ccip/CcipCommon.astro"

## Overview

Expand Down Expand Up @@ -119,3 +120,5 @@ Any modern web browser
<ChainUpdateBuilderWrapper chain="destination" client:load />

<PoolConfigVerification chain="destination" client:load />

<CcipCommon callout="educationalDisclaimer" />
Original file line number Diff line number Diff line change
Expand Up @@ -864,3 +864,5 @@ $ npx hardhat transferTokens --tokenaddress 0xee78C4D525Df5591ba1F3e697A28a84b83
```

You can check the status of the message on the [Chainlink CCIP Explorer](https://ccip.chain.link) by visiting the provided URL. In this example, the message ID is `0x5cd29ba4c7e4517d5a5c9df49fb03c59020a2163a4dc7617101eb682fd63f44b`.

<CcipCommon callout="educationalDisclaimer" />
Original file line number Diff line number Diff line change
Expand Up @@ -460,3 +460,5 @@ In the example below, we use a token pool at address `0x50b9a80719A2348D3a2d91f1
```

Notice in the logs that the transfer failed because the rate limit was exceeded: `TokenRateLimitReached`.

<CcipCommon callout="educationalDisclaimer" />
Original file line number Diff line number Diff line change
Expand Up @@ -547,3 +547,5 @@ In the example below, we use a token pool at address `0xa6aca9013b111228433da2ae
```

Notice in the logs that the transfer failed because the rate limit was exceeded: `TokenRateLimitReached`.

<CcipCommon callout="educationalDisclaimer" />
3 changes: 3 additions & 0 deletions src/content/ccip/tutorials/get-status-offchain.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ title: "Checking CCIP Message Status"
---

import { CodeSample, ClickToZoom, CopyText, Aside } from "@components"
import CcipCommon from "@features/ccip/CcipCommon.astro"

In this tutorial, you will learn how to verify the status of a Chainlink CCIP transaction offchain using JavaScript. Starting with a CCIP message ID, you'll execute the script to query the current status of a cross-chain message.

Expand Down Expand Up @@ -85,3 +86,5 @@ To query the status of the provided CCIP message ID, the script completes the fo
4. Query each matching OffRamp contract for an event related to the message ID

If an event is found, the script reads the status from the arguments. It translates the numeric status into a human-readable status and logs this information.

<CcipCommon callout="educationalDisclaimer" />
1 change: 1 addition & 0 deletions src/content/ccip/tutorials/manual-execution.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,4 @@ Client.EVMExtraArgsV2({
```

<CcipCommon callout="senderContractCallout" />
<CcipCommon callout="educationalDisclaimer" />
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,5 @@ The `retryFailedMessage` function provides a mechanism to recover assets if a CC
- An event `MessageRecovered` is emitted to signal the successful recovery of the tokens.

This function showcases a graceful asset recovery solution, protecting user values even when message processing encounters issues.

<CcipCommon callout="educationalDisclaimer" />
2 changes: 2 additions & 0 deletions src/content/ccip/tutorials/programmable-token-transfers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,5 @@ On the destination blockchain, the router invokes the `_ccipReceive` [function](

- `_ccipReceive` is called by the `ccipReceive` [function](/ccip/api-reference/v1.5.1/ccip-receiver#ccipreceive), which ensures that only the router can deliver CCIP messages to the receiver contract. See the `onlyRouter` [modifier](/ccip/api-reference/v1.5.1/ccip-receiver#onlyrouter) for more information.
- The modifier `onlyAllowlisted` ensures that only a call from an allowlisted source chain and sender is accepted.

<CcipCommon callout="educationalDisclaimer" />
Original file line number Diff line number Diff line change
Expand Up @@ -362,3 +362,5 @@ Both contracts use allowlists to process only messages from and to allowed sourc
## Final note

In this example, the _message tracker_ contract emits an event when it receives the acknowledgment message confirming the initial message reception and processing on the counterpart chain. However, you could think of any other logic to execute when the _message tracker_ receives the acknowledgment. This tutorial demonstrates the pattern for sending arbitrary data, but you can apply the same pattern to programmable token transfers.

<CcipCommon callout="educationalDisclaimer" />
2 changes: 2 additions & 0 deletions src/content/ccip/tutorials/send-arbitrary-data.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,5 @@ This example applies three important security measures:

- `_ccipReceive` is called by the `ccipReceive` [function](/ccip/api-reference/v1.5.1/ccip-receiver#ccipreceive), which ensures that only the router can deliver CCIP messages to the receiver contract. See the `onlyRouter` [modifier](/ccip/api-reference/v1.5.1/ccip-receiver#onlyrouter) for more information.
- The modifier `onlyAllowlisted` ensures that only a call from an allowlisted source chain and sender is accepted.

<CcipCommon callout="educationalDisclaimer" />
3 changes: 3 additions & 0 deletions src/content/ccip/tutorials/token-manager.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ title: "Using the Token Manager"
---

import { Aside, ClickToZoom } from "@components"
import CcipCommon from "@features/ccip/CcipCommon.astro"

<Aside type="note" title="Talk to a CCIP expert">
If you require technical advice or wish to consult on your project's implementation, please contact a CCIP expert. Our
Expand Down Expand Up @@ -207,3 +208,5 @@ You can send a request for verification from the **Settings** page:
1. The _Verification_ tab has a **Verify my token** button that submits a verification request with the information you provided in the previous two tabs.

When your verification request is granted, the Token Manager will display a **Verified** badge on the token page.

<CcipCommon callout="educationalDisclaimer" />
2 changes: 2 additions & 0 deletions src/content/ccip/tutorials/transfer-tokens-from-contract.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,5 @@ The `transferTokensPayNative` function undertakes five primary operations:
1. Dispatches the CCIP message to the destination chain by executing the router's `ccipSend` [function](/ccip/api-reference/v1.5.1/i-router-client#ccipsend). **Note**: `msg.value` is set because you pay in native gas.

**Note**: As a security measure, the `transferTokensPayNative` function is protected by the `onlyAllowlistedChain`, ensuring the contract owner has allowlisted a destination chain.

<CcipCommon callout="educationalDisclaimer" />
3 changes: 3 additions & 0 deletions src/content/ccip/tutorials/transfer-tokens-from-eoa.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ whatsnext: { "Checking CCIP Message Status Off-Chain": "/ccip/tutorials/get-stat
---

import { CodeSample, ClickToZoom, CopyText, Aside } from "@components"
import CcipCommon from "@features/ccip/CcipCommon.astro"

In this tutorial, you will use Chainlink CCIP to transfer tokens directly from your [EOA (Externally Owned Account)](https://ethereum.org/en/developers/docs/accounts/#types-of-account) to an account on a different blockchain. First, you will pay for CCIP fees on the source blockchain using LINK. Then, you will run the same example paying for CCIP fees in native gas, such as ETH on Ethereum or AVAX on Avalanche.

Expand Down Expand Up @@ -279,3 +280,5 @@ The router's `ccipSend` function returns a message ID. The script simulates a ca
#### Checking the status on the destination chain

The script polls the off-ramp contracts on the destination chain to wait for the message to be executed. If the message is executed, it returns the status. Otherwise, the message times out after 40 minutes.

<CcipCommon callout="educationalDisclaimer" />
2 changes: 2 additions & 0 deletions src/content/ccip/tutorials/usdc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,5 @@ The Receiver contract handles incoming cross-chain messages, processes them, and
1. `getFailedMessages` function:

- Retrieves a paginated list of failed messages for inspection.

<CcipCommon callout="educationalDisclaimer" />

0 comments on commit 059b56f

Please sign in to comment.