|
| 1 | +--- |
| 2 | +title: Deploy Your Own ICTT Frontend |
| 3 | +description: Set up the BuilderKit for deploying your own Interchain Token Transfer (ICTT) frontend with custom tokens and chains. |
| 4 | +updated: 2024-05-31 |
| 5 | +icon: Terminal |
| 6 | +authors: [0xstt] |
| 7 | +--- |
| 8 | +import Link from 'next/link'; |
| 9 | +import { cn } from '@/utils/cn'; |
| 10 | +import { buttonVariants } from '@/components/ui/button.tsx' |
| 11 | +import { Step, Steps } from 'fumadocs-ui/components/steps'; |
| 12 | + |
| 13 | +In this section, you’ll learn how to deploy your own **ICTT frontend** using the BuilderKit and pre-configured tokens and chains. Follow these steps to quickly set up and test your own ICTT frontends with Avalanche L1s. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +<Steps> |
| 18 | + |
| 19 | +<Step> |
| 20 | +### Open the AvaCloudSDK Starter Kit Github Repository |
| 21 | + |
| 22 | +Start by opening the repository on Github. |
| 23 | + |
| 24 | +<Link |
| 25 | + href="https://github.com/ava-labs/avalanche-starter-kit" |
| 26 | + className={cn( |
| 27 | + buttonVariants({ variant: 'default', className: 'mt-4' }), |
| 28 | + )} |
| 29 | + target='_blank' |
| 30 | +>Open Avalanche Starter Kit</Link> |
| 31 | +</Step> |
| 32 | + |
| 33 | +<Step> |
| 34 | +### Open the Dev Container and Navigate to the Chain Definitions |
| 35 | + |
| 36 | +- Open the repository in a Github Codespace or Visual Studio Code. |
| 37 | +- Navigate to the `web-apps/builderkit/chains/definitions` folder. |
| 38 | + |
| 39 | +In this folder, you’ll find separate files for each chain configuration. For example, `echo.ts` contains the definition for the **Echo L1** chain: |
| 40 | + |
| 41 | +```ts |
| 42 | +import { defineChain } from "viem"; |
| 43 | + |
| 44 | +export const echo = defineChain({ |
| 45 | + id: 173750, |
| 46 | + name: 'Echo L1', |
| 47 | + network: 'echo', |
| 48 | + nativeCurrency: { |
| 49 | + decimals: 18, |
| 50 | + name: 'Ech', |
| 51 | + symbol: 'ECH', |
| 52 | + }, |
| 53 | + rpcUrls: { |
| 54 | + default: { |
| 55 | + http: ['https://subnets.avax.network/echo/testnet/rpc'] |
| 56 | + }, |
| 57 | + }, |
| 58 | + blockExplorers: { |
| 59 | + default: { name: 'Explorer', url: 'https://subnets-test.avax.network/echo' }, |
| 60 | + }, |
| 61 | + iconUrl: "/chains/logo/173750.png" |
| 62 | +}); |
| 63 | +``` |
| 64 | + |
| 65 | +### How to Configure Your Own Blockchain |
| 66 | + |
| 67 | +To configure your custom blockchain (e.g., `myblockchain`): |
| 68 | + |
| 69 | +1. Copy the existing echo.ts file and rename it to myblockchain.ts. |
| 70 | +2. Update the fields to match your blockchain’s specific details, such as chain ID, network name, and native currency. |
| 71 | +3. Save the file in the chains/definitions folder. |
| 72 | + |
| 73 | +</Step> |
| 74 | +<Step> |
| 75 | +### Import Your Chains |
| 76 | + |
| 77 | +- Navigate to the `web-apps/builderkit/flows/ictt` folder. |
| 78 | + |
| 79 | +Once you're inside the **ICTT** folder, open the `page.tsx` file to begin configuring the tokens and chains. |
| 80 | + |
| 81 | +```tsx |
| 82 | +import { myblockchain } from './chains/definitions'; |
| 83 | +``` |
| 84 | + |
| 85 | +**Add Imported Chains to Array** |
| 86 | + |
| 87 | +After importing the chains, add them into the chains array: |
| 88 | + |
| 89 | +```tsx |
| 90 | +const chains = [avalanche, avalancheFuji, echo, dispatch, myblockchain]; |
| 91 | +``` |
| 92 | + |
| 93 | +This array will hold the configuration of all the chains that will interact with your ICTT frontend. |
| 94 | +</Step> |
| 95 | +<Step> |
| 96 | +### Add Your Chain, and Configure Tokens |
| 97 | + |
| 98 | +Next, configure your tokens. Here’s an example token configuration: |
| 99 | + |
| 100 | +```tsx |
| 101 | +const tokens = [ |
| 102 | + { |
| 103 | + address: "0x8D6f0E153B1D4Efb46c510278Db3678Bb1Cc823d", |
| 104 | + name: "TOK", |
| 105 | + symbol: "TOK", |
| 106 | + decimals: 18, |
| 107 | + chain_id: 43113, |
| 108 | + supports_ictt: true, |
| 109 | + transferer: "0xD63c60859e6648b20c38092cCceb92c5751E32fF", |
| 110 | + mirrors: [ |
| 111 | + { |
| 112 | + address: "0x8D6f0E153B1D4Efb46c510278Db3678Bb1Cc823d", |
| 113 | + transferer: "0x8D6f0E153B1D4Efb46c510278Db3678Bb1Cc823d", |
| 114 | + chain_id: 173750, |
| 115 | + decimals: 18 |
| 116 | + } |
| 117 | + ] |
| 118 | + }, |
| 119 | + { |
| 120 | + address: "0x8D6f0E153B1D4Efb46c510278Db3678Bb1Cc823d", |
| 121 | + name: "TOK.e", |
| 122 | + symbol: "TOK.e", |
| 123 | + decimals: 18, |
| 124 | + chain_id: 173750, |
| 125 | + supports_ictt: true, |
| 126 | + is_transferer: true, |
| 127 | + mirrors: [ |
| 128 | + { |
| 129 | + home: true, |
| 130 | + address: "0x8D6f0E153B1D4Efb46c510278Db3678Bb1Cc823d", |
| 131 | + transferer: "0xD63c60859e6648b20c38092cCceb92c5751E32fF", |
| 132 | + chain_id: 43113, |
| 133 | + decimals: 18 |
| 134 | + } |
| 135 | + ] |
| 136 | + } |
| 137 | +]; |
| 138 | +``` |
| 139 | + |
| 140 | +<Accordions> |
| 141 | +<Accordion title="What Are `is_transferer` and `home` Flags?"> |
| 142 | +- **`is_transferer` Flag**: This flag is used to indicate if the token on the current chain is a transferer. A transferer is a contract that allows the token to be moved between chains using Interchain Token Transfers (ICTT). Set this flag to true if this token is responsible for transferring assets. |
| 143 | +- **`home` Flag**: The `home` flag is used to indicate that this token is the original version of the asset on the **home chain**. When a token is mirrored on multiple chains, the home chain holds the original token, while the mirrors are representations of it on other chains. |
| 144 | + |
| 145 | +These flags ensure proper handling of tokens when they are moved across chains. The `home` flag helps identify which chain holds the token, while `the is_transferer` flag specifies whether the token contract is responsible for transfers. |
| 146 | +</Accordion> |
| 147 | +</Accordions> |
| 148 | + |
| 149 | + |
| 150 | +</Step> |
| 151 | +<Step> |
| 152 | +### Implement the ICTT Component |
| 153 | + |
| 154 | +After configuring the tokens and chains, implement the **ICTT component** in the page. Here’s how to pass the token and chain details to the component: |
| 155 | + |
| 156 | +```tsx |
| 157 | +<ICTT tokens={tokens} token_in="0x8D6f0E153B1D4Efb46c510278Db3678Bb1Cc823d" source_chain_id={43113} destination_chain_id={173750}></ICTT> |
| 158 | +``` |
| 159 | + |
| 160 | +In this example: |
| 161 | + |
| 162 | +- `tokens` contains the configuration. |
| 163 | +- `token_in` specifies the address of the token being transferred. |
| 164 | +- `source_chain_id` and `destination_chain_id` represent the IDs of the source and destination chains. |
| 165 | +</Step> |
| 166 | +<Step> |
| 167 | +### Run the Application |
| 168 | + |
| 169 | +Move back to the `web-apps` folder and run the following command to start the app in development mode: |
| 170 | + |
| 171 | +```bash |
| 172 | +yarn run dev |
| 173 | +``` |
| 174 | + |
| 175 | +You can now interact with the ICTT component. |
| 176 | + |
| 177 | +</Step> |
| 178 | +</Steps> |
0 commit comments