diff --git a/.snippets/code/tutorials/messaging/cross-chain-contracts/snippet-1.sol b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-1.sol similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-contracts/snippet-1.sol rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-1.sol diff --git a/.snippets/code/tutorials/messaging/cross-chain-contracts/snippet-2.sol b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-2.sol similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-contracts/snippet-2.sol rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-2.sol diff --git a/.snippets/code/tutorials/messaging/cross-chain-contracts/snippet-3.js b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-contracts/snippet-3.js rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js diff --git a/.snippets/code/tutorials/messaging/cross-chain-contracts/snippet-4.html b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-4.html similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-contracts/snippet-4.html rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-4.html diff --git a/.snippets/code/tutorials/messaging/cross-chain-contracts/snippet-5.js b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-5.js similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-contracts/snippet-5.js rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-5.js diff --git a/.snippets/code/tutorials/messaging/cross-chain-contracts/snippet-6.js b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-6.js similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-contracts/snippet-6.js rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-6.js diff --git a/.snippets/code/tutorials/messaging/cross-chain-contracts/snippet-7.html b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-7.html similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-contracts/snippet-7.html rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-7.html diff --git a/.snippets/code/tutorials/messaging/cross-chain-contracts/snippet-8.html b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-8.html similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-contracts/snippet-8.html rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-8.html diff --git a/.snippets/code/tutorials/messaging/cross-chain-contracts/snippet-9.json b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-9.json similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-contracts/snippet-9.json rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-9.json diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-1.sol b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-1.sol similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-1.sol rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-1.sol diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-10.html b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-10.html similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-10.html rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-10.html diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-11.sol b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-11.sol similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-11.sol rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-11.sol diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-2.sol b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-2.sol similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-2.sol rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-2.sol diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-3.json b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-3.json similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-3.json rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-3.json diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-5.ts b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-5.ts similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-5.ts rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-5.ts diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-6.html b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-6.html similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-6.html rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-6.html diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-7.html b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-7.html similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-7.html rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-7.html diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-8.html b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-8.html similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-8.html rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-8.html diff --git a/.snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-9.json b/.snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-9.json similarity index 100% rename from .snippets/code/tutorials/messaging/cross-chain-token-transfers/snippet-9.json rename to .snippets/code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-9.json diff --git a/.snippets/code/tutorials/messaging/token-bridge/token-bridge-1.ts b/.snippets/code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-1.ts similarity index 100% rename from .snippets/code/tutorials/messaging/token-bridge/token-bridge-1.ts rename to .snippets/code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-1.ts diff --git a/.snippets/code/tutorials/messaging/token-bridge/token-bridge-2.ts b/.snippets/code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts similarity index 100% rename from .snippets/code/tutorials/messaging/token-bridge/token-bridge-2.ts rename to .snippets/code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts diff --git a/.snippets/code/tutorials/messaging/cctp/cctp-sdk-1.ts b/.snippets/code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-1.ts similarity index 100% rename from .snippets/code/tutorials/messaging/cctp/cctp-sdk-1.ts rename to .snippets/code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-1.ts diff --git a/.snippets/code/tutorials/messaging/cctp/cctp-sdk-2.ts b/.snippets/code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts similarity index 100% rename from .snippets/code/tutorials/messaging/cctp/cctp-sdk-2.ts rename to .snippets/code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts diff --git a/.snippets/code/tutorials/messaging/cctp/cctp-sdk-3.ts b/.snippets/code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-3.ts similarity index 100% rename from .snippets/code/tutorials/messaging/cctp/cctp-sdk-3.ts rename to .snippets/code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-3.ts diff --git a/.snippets/code/tutorials/messaging/cctp/cctp-sdk-4.ts b/.snippets/code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-4.ts similarity index 100% rename from .snippets/code/tutorials/messaging/cctp/cctp-sdk-4.ts rename to .snippets/code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-4.ts diff --git a/build/contract-integrations/.pages b/build/contract-integrations/.pages index af5d9f2f..340dbc5f 100644 --- a/build/contract-integrations/.pages +++ b/build/contract-integrations/.pages @@ -3,9 +3,7 @@ nav: - index.md - 'Wormhole Relayer': 'wormhole-relayers.md' - 'Core Contracts': 'core-contracts.md' - # - 'Token Bridge': 'token-bridge.md' - 'CCTP': 'cctp.md' - native-token-transfers - multigov - 'Development Environment': 'dev-env.md' - - 'FAQs': 'faqs.md' diff --git a/build/contract-integrations/wormhole-relayers.md b/build/contract-integrations/wormhole-relayers.md index 72737435..5424053f 100644 --- a/build/contract-integrations/wormhole-relayers.md +++ b/build/contract-integrations/wormhole-relayers.md @@ -138,4 +138,4 @@ See the [Wormhole CLI tool docs](/docs/build/toolkit/cli/) for installation and ## Step-by-Step Tutorial -For detailed, step-by-step guidance on creating cross-chain contracts that interact with the Wormhole relayer, refer to the [Create Cross-Chain Contracts](/docs/tutorials/messaging/cross-chain-contracts/) tutorial. +For detailed, step-by-step guidance on creating cross-chain contracts that interact with the Wormhole relayer, refer to the [Create Cross-Chain Contracts](/docs/tutorials/by-product/contract-integrations/cross-chain-contracts/) tutorial. diff --git a/build/toolkit/solidity-sdk.md b/build/toolkit/solidity-sdk.md index a9dc3b21..bf66f6d0 100644 --- a/build/toolkit/solidity-sdk.md +++ b/build/toolkit/solidity-sdk.md @@ -162,5 +162,5 @@ The SDK includes built-in support for Forge-based testing, which allows you to t For a detailed example, check out the below repositories: - - [Cross chain messaging](/docs/tutorials/messaging/cross-chain-contracts/){target=\_blank} - - [Cross chain token transfer](/docs/tutorials/messaging/cross-chain-token-contracts/){target=\_blank} \ No newline at end of file + - [Cross chain messaging](/docs/tutorials/by-product/contract-integrations/cross-chain-contracts/){target=\_blank} + - [Cross chain token transfer](/docs/tutorials/by-product/contract-integrations/cross-chain-token-contracts/){target=\_blank} \ No newline at end of file diff --git a/images/tutorials/connect/connect-1.webp b/images/tutorials/by-product/connect/react-dapp/connect-1.webp similarity index 100% rename from images/tutorials/connect/connect-1.webp rename to images/tutorials/by-product/connect/react-dapp/connect-1.webp diff --git a/images/tutorials/connect/connect-2.webp b/images/tutorials/by-product/connect/react-dapp/connect-2.webp similarity index 100% rename from images/tutorials/connect/connect-2.webp rename to images/tutorials/by-product/connect/react-dapp/connect-2.webp diff --git a/images/tutorials/connect/connect-3.webp b/images/tutorials/by-product/connect/react-dapp/connect-3.webp similarity index 100% rename from images/tutorials/connect/connect-3.webp rename to images/tutorials/by-product/connect/react-dapp/connect-3.webp diff --git a/images/tutorials/connect/connect-4.webp b/images/tutorials/by-product/connect/react-dapp/connect-4.webp similarity index 100% rename from images/tutorials/connect/connect-4.webp rename to images/tutorials/by-product/connect/react-dapp/connect-4.webp diff --git a/images/tutorials/connect/connect-5.webp b/images/tutorials/by-product/connect/react-dapp/connect-5.webp similarity index 100% rename from images/tutorials/connect/connect-5.webp rename to images/tutorials/by-product/connect/react-dapp/connect-5.webp diff --git a/images/tutorials/connect/connect-6.webp b/images/tutorials/by-product/connect/react-dapp/connect-6.webp similarity index 100% rename from images/tutorials/connect/connect-6.webp rename to images/tutorials/by-product/connect/react-dapp/connect-6.webp diff --git a/images/tutorials/connect/connect-7.webp b/images/tutorials/by-product/connect/react-dapp/connect-7.webp similarity index 100% rename from images/tutorials/connect/connect-7.webp rename to images/tutorials/by-product/connect/react-dapp/connect-7.webp diff --git a/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-1.webp b/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-1.webp new file mode 100644 index 00000000..58d18a64 Binary files /dev/null and b/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-1.webp differ diff --git a/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-2.webp b/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-2.webp new file mode 100644 index 00000000..b1c187b6 Binary files /dev/null and b/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-2.webp differ diff --git a/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-3.webp b/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-3.webp new file mode 100644 index 00000000..2b631772 Binary files /dev/null and b/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-3.webp differ diff --git a/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-4.webp b/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-4.webp new file mode 100644 index 00000000..535e5169 Binary files /dev/null and b/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-4.webp differ diff --git a/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-5.webp b/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-5.webp new file mode 100644 index 00000000..39277c55 Binary files /dev/null and b/images/tutorials/by-product/native-token-transfers/multichain-tokens/multichain-token-5.webp differ diff --git a/learn/governance/index.md b/learn/governance/index.md index 19abec9b..f1866484 100644 --- a/learn/governance/index.md +++ b/learn/governance/index.md @@ -63,7 +63,7 @@ Discover everything you need to know about MultiGov, Wormhole's cross-chain gove Access step-by-step guides for executing cross-chain governance actions, including treasury management proposals with MultiGov and Wormhole. - [:octicons-arrow-right-16: Create MultiGov solutions](/docs/tutorials/multigov/) + [:octicons-arrow-right-16: Create MultiGov solutions](/docs/tutorials/by-product/multigov/) - :octicons-question-16:{ .lg .middle } **Technical FAQs** diff --git a/tutorials/.pages b/tutorials/.pages index 9f407233..8e03ca39 100644 --- a/tutorials/.pages +++ b/tutorials/.pages @@ -1,5 +1,5 @@ title: Tutorials nav: - index.md - - messaging - - multigov + - by-product +# - end-to-end \ No newline at end of file diff --git a/tutorials/by-product/.pages b/tutorials/by-product/.pages new file mode 100644 index 00000000..c1f7f71f --- /dev/null +++ b/tutorials/by-product/.pages @@ -0,0 +1,8 @@ +title: Tutorials by Product +nav: + - index.md + - connect + - contract-integrations + - native-token-transfers + - multigov + - wormhole-sdk diff --git a/tutorials/by-product/connect/.pages b/tutorials/by-product/connect/.pages new file mode 100644 index 00000000..87c55266 --- /dev/null +++ b/tutorials/by-product/connect/.pages @@ -0,0 +1,4 @@ +title: Connect +nav: + - index.md + - 'Integrate Connect into a React DApp': react-dapp.md diff --git a/tutorials/by-product/connect/index.md b/tutorials/by-product/connect/index.md new file mode 100644 index 00000000..816edf4d --- /dev/null +++ b/tutorials/by-product/connect/index.md @@ -0,0 +1,34 @@ +--- +title: Wormhole Connect Tutorials +description: Enable cross-chain connectivity with Wormhole Connect. Learn integration and simplify user experiences across multiple blockchains. +--- + +# Connect Tutorials + +Wormhole Connect makes it simple to link your application to multiple blockchain ecosystems. These tutorials will teach you how to integrate Connect into your projects, streamline cross-chain interactions, simplify user onboarding, and deliver a smoother overall experience. + +
+ +- :octicons-repo-16:{ .lg .middle } **Integrate Connect into a React DApp** + + --- + + Learn how to incorporate Wormhole Connect into a React application. This step-by-step tutorial guides you through enabling cross-chain token transfers and interactions, bridging assets between networks, and enhancing the user experience with streamlined blockchain connectivity. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/connect/react-dapp/) + +
+ +## Additional Resources + +
+ +- :octicons-tools-16:{ .lg .middle } **Connect** + + --- + + Get deeper insights into setting up and customizing Wormhole Connect. Explore advanced guides, best practices, and configuration tips to streamline your cross-chain integrations. + + [:octicons-arrow-right-16: Learn more](/docs/build/applications/connect/) + +
\ No newline at end of file diff --git a/tutorials/messaging/sui-connect.md b/tutorials/by-product/connect/react-dapp.md similarity index 91% rename from tutorials/messaging/sui-connect.md rename to tutorials/by-product/connect/react-dapp.md index 2d6eb777..01ba9e5c 100644 --- a/tutorials/messaging/sui-connect.md +++ b/tutorials/by-product/connect/react-dapp.md @@ -1,9 +1,11 @@ --- -title: Transfer Tokens Cross-Chain with Connect +title: Integrate Connect into a React DApp Tutorial description: Learn how to use Wormhole Connect to transfers tokens cross-chain seamlessly between Sui and Avalanche Fuji with this step-by-step guide. --- -# Cross-Chain Token Transfers with Wormhole Connect +# Integrate Connect into a React DApp + +:simple-github: [Source code on GitHub](https://github.com/wormhole-foundation/demo-basic-connect){target=\_blank} ## Introduction @@ -127,26 +129,26 @@ To transfer tokens from Sui to Fuji in the Wormhole Connect interface: 2. Choose **Fuji** as the destination network and connect your wallet with the Fuji network 3. Enter the amount of SUI tokens you wish to transfer - ![](/docs/images/tutorials/connect/connect-1.webp) + ![](/docs/images/tutorials/by-product/connect/react-dapp/connect-1.webp) 4. Choose to view other routes - ![](/docs/images/tutorials/connect/connect-2.webp) + ![](/docs/images/tutorials/by-product/connect/react-dapp/connect-2.webp) 5. Select the manual bridge option, which will require two transactions: one on the source chain (Sui) and one on the destination chain (Fuji) !!! note It is recommended to use the manual bridge option for this tutorial. The automatic bridge feature is currently undergoing improvements, while the manual bridge ensures that transfers complete successfully. - ![](/docs/images/tutorials/connect/connect-3.webp) + ![](/docs/images/tutorials/by-product/connect/react-dapp/connect-3.webp) 6. Review and confirm the transfer on Sui. This will lock your tokens on the Sui chain - ![](/docs/images/tutorials/connect/connect-4.webp) + ![](/docs/images/tutorials/by-product/connect/react-dapp/connect-4.webp) 7. Follow the on-screen prompts to approve the transaction. You will be asked to sign with your Sui wallet - ![](/docs/images/tutorials/connect/connect-5.webp) + ![](/docs/images/tutorials/by-product/connect/react-dapp/connect-5.webp) Once the transaction has been submitted, Wormhole Connect will display the progress of the transfer. Monitor the status until you’re prompted to complete the transaction on the destination chain. You can also track your transactions on [Wormholescan](https://wormholescan.io/#/?network=Testnet){target=\_blank}. @@ -154,11 +156,11 @@ Once the transaction has been submitted, Wormhole Connect will display the progr After the Sui transaction is complete, confirm the final transaction on Fuji by claiming the wrapped tokens. You will be asked to confirm the transaction with your Fuji wallet. -![](/docs/images/tutorials/connect/connect-6.webp) +![](/docs/images/tutorials/by-product/connect/react-dapp/connect-6.webp) Once confirmed, check your Fuji wallet to verify that the wrapped SUI tokens have been successfully received. -![](/docs/images/tutorials/connect/connect-7.webp) +![](/docs/images/tutorials/by-product/connect/react-dapp/connect-7.webp) ## Resources diff --git a/tutorials/by-product/contract-integrations/.pages b/tutorials/by-product/contract-integrations/.pages new file mode 100644 index 00000000..0e5449fa --- /dev/null +++ b/tutorials/by-product/contract-integrations/.pages @@ -0,0 +1,5 @@ +title: Contract Integrations +nav: + - index.md + - 'Create Messaging Contracts': 'cross-chain-contracts.md' + - 'Create Token Transfer Contracts': 'cross-chain-token-contracts.md' \ No newline at end of file diff --git a/tutorials/messaging/cross-chain-contracts.md b/tutorials/by-product/contract-integrations/cross-chain-contracts.md similarity index 84% rename from tutorials/messaging/cross-chain-contracts.md rename to tutorials/by-product/contract-integrations/cross-chain-contracts.md index b18ece9b..485442d9 100644 --- a/tutorials/messaging/cross-chain-contracts.md +++ b/tutorials/by-product/contract-integrations/cross-chain-contracts.md @@ -3,7 +3,7 @@ title: Create Cross-Chain Contracts description: Learn how to create cross-chain contracts using Wormhole's Solidity SDK. Deploy contracts on Avalanche and Celo Testnets and send messages across chains. --- -# Create Cross-Chain Contracts +# Create Cross-Chain Messaging Contracts ## Introduction @@ -55,7 +55,7 @@ Key functions include: Here's the core of the contract: ```solidity ---8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-1.sol:24:43" +--8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-1.sol:24:43" ``` You can find the full code for the `MessageSender.sol` below. @@ -63,7 +63,7 @@ You can find the full code for the `MessageSender.sol` below. ??? code "MessageSender.sol" ```solidity - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-1.sol" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-1.sol" ``` ### Receiver Contract: MessageReceiver @@ -81,8 +81,8 @@ Key implementation details include: - **`isRegisteredSender`** - restricts the processing of messages to only those from registered senders, preventing unauthorized cross-chain communication ```solidity ---8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-2.sol:12:13" ---8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-2.sol:22:39" +--8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-2.sol:12:13" +--8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-2.sol:22:39" ``` #### Message Processing @@ -90,7 +90,7 @@ Key implementation details include: The `receiveWormholeMessages` is the core function that processes the received message. It checks that the Wormhole relayer sent the message, decodes the payload, and emits an event with the message content. It is essential to verify the message sender to prevent unauthorized messages. ```solidity ---8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-2.sol:42:64" +--8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-2.sol:42:64" ``` You can find the full code for the `MessageReceiver.sol` below. @@ -98,7 +98,7 @@ You can find the full code for the `MessageReceiver.sol` below. ??? code "MessageReceiver.sol" ```solidity - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-2.sol" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-2.sol" ``` ## Deploy Contracts @@ -165,7 +165,7 @@ The repository includes: The expected output should be similar to this: ---8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-7.html" +--8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-7.html" ### Deployment Process @@ -176,19 +176,19 @@ Both deployment scripts, `deploySender.js` and `deployReceiver.js`, perform the === "`chains.json`" ```json - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-9.json" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-9.json" ``` === "`deploySender.js`" ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-5.js:7:15" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-5.js:7:15" ``` === "`deployReceiver.js`" ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-6.js:7:15" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-6.js:7:15" ``` !!! note @@ -199,13 +199,13 @@ Both deployment scripts, `deploySender.js` and `deployReceiver.js`, perform the === "`deploySender.js`" ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-5.js:18:19" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-5.js:18:19" ``` === "`deployReceiver.js`" ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-6.js:18:19" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-6.js:18:19" ``` 3. **Deploy the contract** - the contract is deployed to the network specified in the configuration. Upon successful deployment, the contract address is returned, which is crucial for interacting with the contract later on @@ -213,13 +213,13 @@ Both deployment scripts, `deploySender.js` and `deployReceiver.js`, perform the === "`deploySender.js`" ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-5.js:36:39" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-5.js:36:39" ``` === "`deployReceiver.js`" ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-6.js:39:42" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-6.js:39:42" ``` 4. **Register the `MessageSender` on the target chain** - after you deploy the `MessageReceiver` contract on the Celo Alfajores network, the sender contract address from Avalanche Fuji needs to be registered. This ensures that only messages from the registered `MessageSender` contract are processed @@ -227,7 +227,7 @@ Both deployment scripts, `deploySender.js` and `deployReceiver.js`, perform the This additional step is essential to enforce emitter validation, preventing unauthorized senders from delivering messages to the `MessageReceiver` contract ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-6.js:55:66" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-6.js:55:66" ``` You can find the full code for the `deploySender.js` and `deployReceiver.js` below. @@ -235,13 +235,13 @@ You can find the full code for the `deploySender.js` and `deployReceiver.js` bel ??? code "deploySender.js" ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-5.js" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-5.js" ``` ??? code "deployReceiver.js" ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-6.js" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-6.js" ``` ### Deploy the Sender Contract @@ -256,7 +256,7 @@ The sender contract will handle quoting and sending messages cross-chain. 2. Once deployed, the contract address will be displayed. You may check the contract on the [Avalanche Fuji Explorer](https://testnet.snowtrace.io/){target=\_blank} ---8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-8.html" +--8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-8.html" ### Deploy the Receiver Contract @@ -286,7 +286,7 @@ Let's break down the script step by step. 2. **`deployedContracts.json`** - stores the addresses of the deployed sender and receiver contracts. This file is dynamically updated when contracts are deployed, but users can also manually add their own deployed contract addresses if needed ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-3.js:8:16" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js:8:16" ``` 2. **Configure the provider and signer** - the script first reads the chain configurations and extracts the contract addresses. One essential step in interacting with a blockchain is setting up a _provider_. A provider is your connection to the blockchain network. It allows your script to interact with the blockchain, retrieve data, and send transactions. In this case, we're using a JSON-RPC provider @@ -294,31 +294,31 @@ Let's break down the script step by step. Next, we configure the wallet, which will be used to sign transactions. The wallet is created using the private key and the provider. This ensures that all transactions sent from this wallet are broadcast to the Avalanche Fuji network: ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-3.js:34:35" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js:34:35" ``` After setting up the wallet, the script loads the ABI for the `MessageSender.sol` contract and creates an instance of it: ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-3.js:38:43" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js:38:43" ``` 3. **Set up the message details** - the next part of the script defines the target chain (Celo) and the target address (the receiver contract on Celo): ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-3.js:55:56" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js:55:56" ``` You can customize the message that will be sent across chains: ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-3.js:59:59" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js:59:59" ``` 4. **Estimate cross-chain cost** - before sending the message, we dynamically calculate the cross-chain cost using the `quoteCrossChainCost` function: ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-3.js:62:62" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js:62:62" ``` This ensures that the transaction includes enough funds to cover the gas fees for the cross-chain message. @@ -326,13 +326,13 @@ Let's break down the script step by step. 5. **Send a message** - with everything set up, the message is sent using the `sendMessage` function: ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-3.js:65:72" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js:65:72" ``` After sending, the script waits for the transaction to be confirmed: ```javascript - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-3.js:75:75" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js:75:75" ``` 6. **Run the script** - to send the message, run the following command: @@ -345,14 +345,14 @@ If everything is set up correctly, the message will be sent from the Avalanche F The console should output something similar to this: ---8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-4.html" +--8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-4.html" You can find the full code for the `sendMessage.js` below. ??? code "sendMessage.js" ```solidity - --8<-- "code/tutorials/messaging/cross-chain-contracts/snippet-3.js" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-contracts/snippet-3.js" ``` ## Conclusion diff --git a/tutorials/messaging/cross-chain-token-contracts.md b/tutorials/by-product/contract-integrations/cross-chain-token-contracts.md similarity index 86% rename from tutorials/messaging/cross-chain-token-contracts.md rename to tutorials/by-product/contract-integrations/cross-chain-token-contracts.md index 3c374c30..04fd1ee6 100644 --- a/tutorials/messaging/cross-chain-token-contracts.md +++ b/tutorials/by-product/contract-integrations/cross-chain-token-contracts.md @@ -3,7 +3,9 @@ title: Cross-Chain Token Transfers description: Learn how to create cross-chain token transfers using Wormhole's Solidity SDK. Build and deploy smart contracts to send tokens from one blockchain to another. --- -# Cross-Chain Token Transfers +# Create Cross-Chain Token Transfer Contracts + +:simple-github: [Source code on GitHub](https://github.com/wormhole-foundation/demo-cross-chain-token-transfer){target=\_blank} ## Introduction @@ -52,7 +54,7 @@ To simplify this process, we've included a tool for verifying if a token has an 5. The expected output when the token has an attestation: - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-10.html" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-10.html" Using this tool ensures that you only attempt to transfer tokens with verified attestations, avoiding any potential issues during the cross-chain transfer process. @@ -109,7 +111,7 @@ Let's start writing the `CrossChainSender` contract: 2. Open the file. First, we'll start with the imports and the contract setup: ```solidity - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-1.sol:1:14" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-1.sol:1:14" ``` This sets up the basic structure of the contract, including the necessary imports and the constructor that initializes the contract with the Wormhole-related addresses. @@ -117,7 +119,7 @@ Let's start writing the `CrossChainSender` contract: 3. Next, let's add a function that estimates the cost of sending tokens across chains: ```solidity - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-1.sol:17:28" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-1.sol:17:28" ``` This function, `quoteCrossChainDeposit`, helps calculate the cost of transferring tokens to a different chain. It factors in the delivery cost and the cost of publishing a message via the Wormhole protocol. @@ -125,7 +127,7 @@ Let's start writing the `CrossChainSender` contract: 4. Finally, we'll add the function that sends the tokens across chains: ```solidity - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-1.sol:31:58" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-1.sol:31:58" ``` This `sendCrossChainDeposit` function is where the actual token transfer happens. It sends the tokens to the recipient on the target chain using the Wormhole protocol. @@ -152,7 +154,7 @@ You can find the complete code for the `CrossChainSender.sol` below. ??? code "MessageSender.sol" ```solidity - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-1.sol" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-1.sol" ``` ### Receiver Contract: CrossChainReceiver @@ -170,7 +172,7 @@ Let's start writing the `CrossChainReceiver` contract: 2. Open the file. First, we'll start with the imports and the contract setup: ```solidity - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-2.sol:1:14" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-2.sol:1:14" ``` Similar to the `CrossChainSender` contract, this sets up the basic structure of the contract, including the necessary imports and the constructor that initializes the contract with the Wormhole-related addresses. @@ -178,7 +180,7 @@ Let's start writing the `CrossChainReceiver` contract: 3. Next, let's add a function to handle receiving the payload and tokens: ```solidity - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-2.sol:17:40" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-2.sol:17:40" ``` This `receivePayloadAndTokens` function processes the tokens and payload sent from another chain, decodes the recipient address, and transfers the tokens to them using the Wormhole protocol. This function also validates the emitter (`sourceAddress`) to ensure the message comes from a trusted sender. @@ -196,7 +198,7 @@ After we call `sendTokenWithPayloadToEvm` on the source chain, the message goes Let’s delve into the fields provided to us in the `TokenReceived` struct: ```solidity - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-11.sol" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-11.sol" ``` - **`tokenHomeAddress`** - the original address of the token on its native chain. This is the same as the token field in the call to `sendTokenWithPayloadToEvm` unless the original token sent is a Wormhole-wrapped token. In that case, this will be the address of the original version of the token (on its native chain) in Wormhole address format (left-padded with 12 zeros) @@ -214,7 +216,7 @@ You can find the complete code for the `CrossChainReceiver.sol` contract below: ??? code "CrossChainReceiver.sol" ```solidity - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-2.sol" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-2.sol" ``` ## Deploy the Contracts @@ -238,7 +240,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 3. Open the `config.json` file and add the following configuration: ```json - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-3.json" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-3.json" ``` This file specifies the details for each chain where you plan to deploy your contracts, including the RPC URL, the `TokenBridge` address, the Wormhole relayer, and the Wormhole Core Contract. @@ -284,7 +286,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract The expected output should be similar to this: - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-6.html" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-6.html" 4. **Write the deployment script** - you’ll need a script to automate the deployment of your contracts. Let’s create the deployment script @@ -297,7 +299,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 2. Open the file and load imports and configuration: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:1:7" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:1:7" ``` Import the required libraries and modules to interact with Ethereum, handle file paths, load environment variables, and enable user interaction via the terminal. @@ -305,7 +307,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 3. Define interfaces to use for chain configuration and contract deployment: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:9:25" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:9:25" ``` These interfaces define the structure of the chain configuration and the contract deployment details. @@ -313,7 +315,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 4. Load and select the chains for deployment: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:27:47" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:27:47" ``` The `loadConfig` function reads the chain configuration from the `config.json` file, and the `selectChain` function allows the user to choose the source and target chains for deployment interactively. The user is prompted in the terminal to select which chains to use, making the process interactive and user-friendly. @@ -321,7 +323,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 5. Define the main function for deployment and load the chain configuration: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:48:53" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:48:53" ``` - The `main` function is the entry point for the deployment script @@ -330,7 +332,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 6. Set up provider and wallet: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:54:57" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:54:57" ``` The scripts establish a connection to the blockchain using a provider and create a wallet instance using a private key. This wallet is responsible for signing the deployment transaction on the source chain. @@ -338,7 +340,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 7. Read the compiled contracts: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:58:66" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:58:66" ``` - This code reads the `CrossChainSender.json` file, the compiled output of the `CrossChainSender.sol` contract @@ -348,7 +350,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 8. Extract the contract ABI and bytecode: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:68:69" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:68:69" ``` - **ABI (Application Binary Interface)** - defines the structure of the contract’s functions, events, and data types, allowing the front end to interact with the contract on the blockchain @@ -357,7 +359,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 9. Create the Contract Factory: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:71:75" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:71:75" ``` - **`ethers.ContractFactory`** - creates a new contract factory using the ABI, bytecode, and a wallet (representing the signer). The contract factory is responsible for deploying instances of the contract to the blockchain @@ -367,12 +369,12 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract === "`CrossChainSender`" ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:77:83" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:77:83" ``` === "`CrossChainReceiver`" ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:91:115" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:91:115" ``` Both functions deploy the respective contracts to the selected chains. @@ -388,12 +390,12 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract === "`senderAddress`" ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:86:89" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:86:89" ``` === "`receiverAddress`" ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:118:121" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:118:121" ``` You may display the deployed contract addresses in the terminal or save them to a JSON file for future reference. @@ -401,7 +403,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 12. Register the `CrossChainSender` address on the target chain: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:128:139" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:128:139" ``` After you deploy the `CrossChainReceiver` contract on the target network, the sender contract address from the source chain needs to be registered. This ensures that only messages from the registered `CrossChainSender` contract are processed. @@ -412,7 +414,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract ???- example "Save Deployment Details Example" ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:145:185" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:145:185" ``` Add your desired logic to save the deployed contract addresses in a JSON file (or another format). This will be important later when transferring tokens, as you'll need these addresses to interact with the deployed contracts. @@ -420,7 +422,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract 14. Handle errors and finalize the script: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts:186:201" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts:186:201" ``` The try-catch block wraps the deployment logic to catch any errors that may occur. @@ -435,7 +437,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract ??? code "deploy.ts" ```solidity - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-4.ts" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-4.ts" ``` 5. **Add your private key** - you'll need to provide your private key. It allows your deployment script to sign the transactions that deploy the smart contracts to the blockchain. Without it, the script won't be able to interact with the blockchain on your behalf @@ -469,7 +471,7 @@ Now that you've written the `CrossChainSender` and `CrossChainReceiver` contract If you followed the logic provided in the full code above, your terminal output should look something like this: ---8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-7.html" +--8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-7.html" ## Transfer Tokens Across Chains @@ -493,7 +495,7 @@ In this step, you'll write a script to transfer tokens across chains using the ` 2. Open the file. Start with the necessary imports, interfaces and configurations: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-5.ts:1:25" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-5.ts:1:25" ``` These imports include the essential libraries for interacting with Ethereum, handling file paths, loading environment variables, and managing user input. @@ -502,7 +504,7 @@ In this step, you'll write a script to transfer tokens across chains using the ` ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-5.ts:27:47" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-5.ts:27:47" ``` These functions load the network and contract details that were saved during deployment. @@ -512,7 +514,7 @@ In this step, you'll write a script to transfer tokens across chains using the ` Refer to the deployed contracts and create logic as desired. In our example, we made this process interactive, allowing users to select the source and target chains from all the historically deployed contracts. This interactive approach helps ensure the correct chains are selected for the token transfer. ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-5.ts:49:101" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-5.ts:49:101" ``` 2. **Implement the token transfer logic** @@ -520,7 +522,7 @@ In this step, you'll write a script to transfer tokens across chains using the ` 1. Start the `main` function: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-5.ts:103:139" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-5.ts:103:139" ``` The `main` function is where the token transfer logic will reside. It loads the chain and contract details, sets up the wallet and provider, and loads the `CrossChainSender` contract. @@ -530,7 +532,7 @@ In this step, you'll write a script to transfer tokens across chains using the ` You'll now ask the user for the token contract address, the recipient address on the target chain, and the amount of tokens to transfer. ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-5.ts:147:171" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-5.ts:147:171" ``` This section of the script prompts the user for the token contract address and the recipient's address, fetches the token's decimal value, and parses the amount accordingly. @@ -540,7 +542,7 @@ In this step, you'll write a script to transfer tokens across chains using the ` Finally, initiate the cross-chain transfer and log the details. ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-5.ts:174:204" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-5.ts:174:204" ``` This part of the script first approves the token transfer, then initiates the cross-chain transfer using the `CrossChainSender` contract, and finally logs the transaction hash for the user to track. @@ -548,7 +550,7 @@ In this step, you'll write a script to transfer tokens across chains using the ` 4. Finalize the script: ```typescript - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-5.ts:205:208" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-5.ts:205:208" ``` This section finalizes the script by calling the `main` function and handling any errors that may occur during the token transfer process. @@ -558,7 +560,7 @@ You can find the full code for the `transfer.ts` file below: ??? code "transfer.ts" ```solidity - --8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-5.ts" + --8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-5.ts" ``` ### Transfer Tokens @@ -583,7 +585,7 @@ You can verify the transaction on the [Wormhole Explorer](https://wormholescan.i If you followed the logic provided in the `transfer.ts` file above, your terminal output should look something like this: ---8<-- "code/tutorials/messaging/cross-chain-token-transfers/snippet-8.html" +--8<-- "code/tutorials/by-product/contract-integrations/cross-chain-token-transfers/snippet-8.html" !!! note In this example, we demonstrated a token transfer from the Avalanche Fuji Testnet to the Celo Alfajores Testnet. We sent two units of USDC Testnet tokens using the token contract address `0x5425890298aed601595a70ab815c96711a31bc65`. You can replace these details with those relevant to your project or use the same for testing purposes. diff --git a/tutorials/by-product/contract-integrations/index.md b/tutorials/by-product/contract-integrations/index.md new file mode 100644 index 00000000..e0f7864b --- /dev/null +++ b/tutorials/by-product/contract-integrations/index.md @@ -0,0 +1,52 @@ +--- +title: Cross-Chain Contract Integration Tutorials +description: Master cross-chain smart contracts with Wormhole. Learn messaging, token transfers, and secure, scalable dApp deployments across blockchains. +--- + +# Cross-Chain Contract Tutorials + +Expand the reach of your decentralized applications by building smart contracts that can communicate across multiple blockchains. Through these tutorials, you’ll learn to create robust cross-chain contracts, enabling your dApps to tap into global liquidity, diverse functionalities, and a broader user base. + +
+ +- :octicons-repo-16:{ .lg .middle } **Create Cross-Chain Messaging Contracts** + + --- + + Learn how to build and deploy smart contracts that communicate seamlessly across multiple blockchains. This tutorial walks you through using Wormhole’s Solidity SDK to send and receive messages between Avalanche Fuji and Celo Alfajores, helping you master emitter validation, relayer usage, and cross-chain cost management. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/contract-integrations/cross-chain-contracts/) + +- :octicons-repo-16:{ .lg .middle } **Create Cross-Chain Token Transfer Contracts** + + --- + + Discover how to create a fully functional cross-chain token transfer system using Wormhole’s Solidity SDK. This tutorial guides you through token attestation, contract deployment, and secure transfers of ERC-20 tokens between test networks. By the end, you’ll know how to tap into global liquidity and enrich your dApps with seamless multi-chain asset movement. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/contract-integrations/cross-chain-token-contracts/) + +
+ +## Additional Resources + +
+ +- :octicons-book-16:{ .lg .middle } **Core Contracts** + + --- + + Dive deeper into Wormhole’s foundational concepts for cross-chain contracts. Discover how messaging, guardians, and VAAs work together to enable secure, scalable dApps. + + + [:octicons-arrow-right-16: Explore Core Contracts](/docs/learn/infrastructure/core-contracts/) + +- :octicons-tools-16:{ .lg .middle } **Build Contract Integrations** + + --- + + Explore advanced contract integrations with Wormhole. Access reference code, best practices, and guidance for deploying robust cross-chain smart contracts. + + + [:octicons-arrow-right-16: Build contract integrations](/docs/build/contract-integrations/) + +
\ No newline at end of file diff --git a/tutorials/by-product/index.md b/tutorials/by-product/index.md new file mode 100644 index 00000000..31268607 --- /dev/null +++ b/tutorials/by-product/index.md @@ -0,0 +1,52 @@ +--- +title: Tutorials by Product +description: Discover product-specific Wormhole tutorials. Learn setup, integration, and advanced features to develop cross-chain apps confidently. +--- + +# Tutorials by Product + +In this section, you'll find tutorials focused on individual Wormhole products. Each product folder contains detailed guides to help you integrate and use specific Wormhole services, such as Token Bridge, Wormhole Connect, and more. Whether setting up your first product or diving deeper into advanced features, these tutorials will walk you through the entire process, from installation to implementation. + +
+ +- :octicons-arrow-switch-16:{ .lg .middle } **Connect** + + --- + + With Wormhole Connect, you can enable seamless connectivity between different blockchain ecosystems. These tutorials guide you through integrating Connect into your projects, allowing you to easily leverage cross-chain interactions, simplify onboarding, and improve user experience. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/connect/) + +- :octicons-file-code-16:{ .lg .middle } **Contract Integrations** + + --- + + Learn to build smart contracts that communicate across multiple blockchains. These tutorials show you how to create robust cross-chain contracts, allowing your dApps to move beyond a single network and tap into global liquidity, functionality, and user bases. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/contract-integrations/) + +- :octicons-sync-16:{ .lg .middle } **Native Token Transfers** + + --- + + Discover how to move native assets across different chains. These tutorials will help you set up and execute cross-chain token transfers, ensuring secure, efficient, and scalable bridging solutions for your users and applications. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/native-token-transfers/) + +- :octicons-people-16:{ .lg .middle } **MultiGov** + + --- + + Unleash the power of cross-chain governance with Multigov. These tutorials guide you through setting up and managing governance structures spanning multiple blockchains, enabling collective decision-making and coordinated upgrades across decentralized ecosystems. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/multigov/) + +- :octicons-code-square-16:{ .lg .middle } **Wormhole SDK** + + --- + + Master the tools to build cross-chain applications with the Wormhole SDK. These tutorials cover installation to advanced functionality, helping you streamline development, reduce complexity, and quickly bring your ideas to life. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/wormhole-sdk/) + +
diff --git a/tutorials/multigov/.pages b/tutorials/by-product/multigov/.pages similarity index 100% rename from tutorials/multigov/.pages rename to tutorials/by-product/multigov/.pages diff --git a/tutorials/by-product/multigov/index.md b/tutorials/by-product/multigov/index.md new file mode 100644 index 00000000..364426f7 --- /dev/null +++ b/tutorials/by-product/multigov/index.md @@ -0,0 +1,45 @@ +--- +title: Step-by-Step MultiGov Tutorials +description: Access step-by-step guides for executing cross-chain governance actions, including treasury management proposals with MultiGov and Wormhole. +--- + +# MultiGov Tutorials + +Welcome to the MultiGov tutorials section. In this section, you will find tutorials that walk you through the key steps of working with MultiGov, providing clear instructions to help you get started. As you explore, you'll gain a deeper understanding of MultiGov's features and functionality. + +## Get Started + +
+ +- :octicons-repo-16:{ .lg .middle } **Cross-Chain Treasury Management Proposal** + + --- + + Learn how to propose governance actions on a hub chain, gather votes from spoke chains, aggregate the results, and carry out the final decision. Following these steps, you’ll master end-to-end governance workflows spanning multiple networks. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/multigov/treasury-proposal/) + +
+ +## Additional Resources + +
+ +- :octicons-book-16:{ .lg .middle } **Governance Fundamentals** + + --- + + Dive into Wormhole’s governance mechanisms. Understand how cross-chain governance works, proposal creation, voting, and execution. + + [:octicons-arrow-right-16: Explore governance](/docs/learn/governance/) + +- :octicons-tools-16:{ .lg .middle } **Implement MultiGov** + + --- + + Integrate MultiGov into your smart contracts. Access reference code, best practices, and guidance for deploying cross-chain governance systems. + + + [:octicons-arrow-right-16: Build with MultiGov](/docs/build/contract-integrations/multigov/) + +
diff --git a/tutorials/multigov/treasury-proposal.md b/tutorials/by-product/multigov/treasury-proposal.md similarity index 100% rename from tutorials/multigov/treasury-proposal.md rename to tutorials/by-product/multigov/treasury-proposal.md diff --git a/tutorials/by-product/native-token-transfers/.pages b/tutorials/by-product/native-token-transfers/.pages new file mode 100644 index 00000000..f90255c8 --- /dev/null +++ b/tutorials/by-product/native-token-transfers/.pages @@ -0,0 +1,4 @@ +title: Native Token Transfers (NTT) +nav: + - index.md + - 'Create Native Multichain Tokens': 'multichain-token.md' diff --git a/tutorials/by-product/native-token-transfers/index.md b/tutorials/by-product/native-token-transfers/index.md new file mode 100644 index 00000000..e65a2162 --- /dev/null +++ b/tutorials/by-product/native-token-transfers/index.md @@ -0,0 +1,42 @@ +--- +title: Native Token Transfers (NTT) Tutorials +description: Discover how to enable seamless native token transfers across chains, empowering dApps with secure, efficient cross-chain interoperability. +--- + +# Native Token Transfers (NTT) Tutorials + +Learn to move native assets between different blockchains seamlessly. These tutorials teach you how to set up and execute secure, efficient, and scalable cross-chain token transfers. Provide your users and applications with robust bridging solutions that unlock the power of an interconnected blockchain ecosystem. + +
+ +- :octicons-repo-16:{ .lg .middle } **Create Multichain Tokens** + + --- + + Learn how to register your token on the source chain, create a wrapped token on the target chain, and update its metadata for cross-chain compatibility. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/native-token-transfers/multichain-token) + +
+ +## Additional Resources + +
+ +- :octicons-book-16:{ .lg .middle } **Native Token Transfer Fundamentals** + + --- + + Dive into the core concepts of NTT. Understand the underlying mechanisms, security considerations, and best practices for seamless cross-chain asset movement. + + [:octicons-arrow-right-16: Explore Native Token Transfers](/docs/learn/messaging/native-token-transfers/) + +- :octicons-tools-16:{ .lg .middle } **Build Native Token Transfers** + + --- + + Implement robust native token transfer solutions with Wormhole’s SDK. Access comprehensive guides, reference code, and advanced techniques for deploying cross-chain token bridges. + + [:octicons-arrow-right-16: Build Native Token Transfers](/docs/build/contract-integrations/native-token-transfers/) + +
diff --git a/tutorials/by-product/native-token-transfers/multichain-token.md b/tutorials/by-product/native-token-transfers/multichain-token.md new file mode 100644 index 00000000..5951e039 --- /dev/null +++ b/tutorials/by-product/native-token-transfers/multichain-token.md @@ -0,0 +1,92 @@ +--- +title: Create Multichain Tokens +description: Learn how to create a multichain token, bridge tokens across blockchains, and update metadata for seamless multichain interoperability. +--- + +# Create Multichain Tokens + +## Introduction + +Blockchain ecosystems are becoming increasingly interconnected, with assets often needing to exist across multiple networks to maximize their utility and reach. For example, tokens created on one chain may want to expand to others to tap into broader audiences and liquidity pools. + +This guide explains how to create a multichain token—a token that seamlessly bridges across blockchains using the Wormhole protocol. The process is designed to be user-friendly. With just a few steps, your token can become multichain, enabling it to be traded or used on various networks. + +By the end of this tutorial, you'll learn: + +- How to register your token for bridging +- How to create a wrapped version of your token +- How to ensure its visibility on blockchain explorers + +Let’s begin with a straightforward, step-by-step process for creating a multichain token and expanding its reach. + +## Register the Token on the Source Chain + +The first step in creating a multichain token is registering your token on its source chain. This ensures the token is prepared for bridging across blockchains. Follow these steps: + +1. Open the [Portal Bridge](https://portalbridge.com/advanced-tools/#/register){target=\_blank} +2. Select the blockchain where your token is currently deployed (source chain) +3. Connect your wallet by following the on-screen instructions +4. Locate the **Asset** field and paste the token contract address +5. Click **Next** to proceed + +Source Chain Registration Screen + +## Register the Token on the Target Chain + +After registering your token on the source chain, the next step is to select the target chain—the blockchain where you want the wrapped version of your token to exist. This step connects your token to its destination network. + +1. Choose the blockchain where you want the token to be bridged (target chain) +2. Connect your wallet to the target chain +3. Click **Next** to finalize the registration process + +Target Chain Registration Screen + +## Send an Attestation +Attestation is a key step in the process. It verifies your token’s metadata, ensuring it is correctly recognized on the target chain’s blockchain explorer (e.g., [Etherscan](https://etherscan.io/){target=\_blank}). + +1. Click **Attest** to initiate the attestation process +2. Approve the transaction in your wallet when prompted + +Send Attestation Screen + +!!! note + - Attestation is crucial for token metadata to appear correctly on blockchain explorers like Etherscan, allowing users to identify and trust your token + - Ensure you have sufficient funds to cover transaction fees on the target chain + +## Create the Wrapped Token + +The final step is to create the wrapped token on the target chain. This token represents the original asset and enables its use within the target blockchain. + +1. Click **Create** to generate the wrapped token +2. Approve the transaction in your wallet when prompted + +Create Wrapped Token Screen + +Upon successful creation, you will see a confirmation screen displaying key details such as the source chain, target chain, and transaction status. This helps verify that the process was completed correctly. Refer to the image below as an example: + +Confirmation Screen + +## Additional Steps and Recommendations + +After creating your multichain token, there are a few optional but highly recommended steps to ensure the best experience for users interacting with your token. + +### Add Your Token to the Wormhole Metadata List (Legacy) + +For legacy compatibility in the [**Advanced Tools**](https://portalbridge.com/advanced-tools/){target=\_blank} section of Portal Bridge, you can request updates to your token metadata. Follow these steps: + +1. Join the [Wormhole Discord server](https://discord.com/invite/wormholecrypto){target=\_blank} +2. Submit a request for metadata updates in the appropriate support channel + +!!! note + These updates only apply to the **Advanced Tools** section of Portal Bridge and will not update how your token appears in other Wormhole-powered apps or on blockchain explorers like Etherscan. + +### Update Metadata on Blockchain Explorers + +It is recommended that you update your token’s metadata on blockchain explorers such as Etherscan. This includes adding details like the token logo, price, and contract verification. + +1. Create an account on the relevant scanner and go to the [token update section](https://etherscan.io/tokenupdate){target=\_blank} (or the relevant scanner that you would like to update metadata on) +2. Copy and paste the wrapped contract address in the **Token Update Application Form** +3. Before proceeding to the next step, you will need to verify as the contract address owner on [Etherscan’s address verification tool](https://etherscan.io/verifyAddress/){target=\_blank} +4. Follow the directions to verify contract address ownership via MetaMask by reviewing the [guide on verifying address ownership](https://info.etherscan.com/how-to-verify-address-ownership/){target=\_blank} + - Given that Wormhole may be the contract owner, use the manual verification process by reaching out through the [Etherscan contact form](https://etherscan.io/contactus){target=\_blank}. The team will provide support as needed +5. Once the step above is completed, follow the [instructions to update token information](https://info.etherscan.com/how-to-update-token-information-on-token-page/){target=\_blank} \ No newline at end of file diff --git a/tutorials/by-product/wormhole-sdk/.pages b/tutorials/by-product/wormhole-sdk/.pages new file mode 100644 index 00000000..3b898b94 --- /dev/null +++ b/tutorials/by-product/wormhole-sdk/.pages @@ -0,0 +1,5 @@ +title: Wormhole SDK +nav: + - index.md + - 'Transfer USDC via the CCTP Bridge': 'usdc-via-cctp.md' + - 'Transfer Tokens via the Token Bridge': 'tokens-via-token-bridge.md' diff --git a/tutorials/by-product/wormhole-sdk/index.md b/tutorials/by-product/wormhole-sdk/index.md new file mode 100644 index 00000000..c006801d --- /dev/null +++ b/tutorials/by-product/wormhole-sdk/index.md @@ -0,0 +1,42 @@ +--- +title: Wormhole SDK Tutorials +description: Master the Wormhole SDK. Build robust cross-chain dApps with messaging, token bridging, and governance across multiple networks. +--- + +# Wormhole SDK Tutorials + +The Wormhole SDK provides the essential building blocks for creating robust cross-chain applications. With its developer-friendly libraries, tools, and interfaces, you can quickly integrate Wormhole’s messaging, token transfer, and governance functionalities into your projects. Whether you’re building a simple cross-chain dApp or architecting a complex multi-chain ecosystem, these tutorials will guide you through mastering the SDK and unlocking the full potential of Wormhole’s infrastructure. + +
+ +- :octicons-repo-16:{ .lg .middle } **Transfer USDC via CCTP** + + --- + + Learn how to move native USDC across chains using Circle’s CCTP and Wormhole’s TypeScript SDK. This tutorial shows you how to streamline transfers with automated attestation and finalization or take complete control with manual steps. Gain the skills to handle seamless USDC bridging, optimize user experience, and improve the reliability of your cross-chain applications. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/wormhole-sdk/usdc-via-cctp/) + +- :octicons-repo-16:{ .lg .middle } **Transfer Tokens via the Token Bridge** + + --- + + Learn how to build a versatile cross-chain token transfer application using Wormhole’s TypeScript SDK. This tutorial walks you through leveraging the Token Bridge to securely and efficiently move assets between EVM and non-EVM chains. By the end, you’ll understand how to transfer tokens between networks like Ethereum, Solana, Sui, and beyond, opening the door to an interconnected blockchain ecosystem. + + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/) + +
+ +## Additional Resources + +
+ +- :octicons-tools-16:{ .lg .middle } **Wormhole SDK Documentation** + + --- + + Learn to build cross-chain dApps using the Wormhole SDK. Access detailed guides, reference code, and best practices for robust application development. + + [:octicons-arrow-right-16: Learn more](/docs/build/applications/wormhole-sdk/) + +
\ No newline at end of file diff --git a/tutorials/messaging/token-bridge.md b/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge.md similarity index 86% rename from tutorials/messaging/token-bridge.md rename to tutorials/by-product/wormhole-sdk/tokens-via-token-bridge.md index ff79cc9c..a6a7b817 100644 --- a/tutorials/messaging/token-bridge.md +++ b/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge.md @@ -1,9 +1,11 @@ --- -title: Token Bridge +title: Transfer Tokens via Token Bridge Tutorial description: Learn to build a cross-chain native token transfer app using Wormhole’s TypeScript SDK, supporting native token transfers across EVM and non-EVM chains --- -# Token Bridge +# Transfer Tokens via the Token Bridge + +:simple-github: [Source code on GitHub](https://github.com/wormhole-foundation/demo-basic-ts-sdk/){target=\_blank} ## Introduction @@ -80,7 +82,7 @@ In this section, we’ll guide you through initializing the project, installing 2. Open the `helpers.ts` file and add the following code ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-1.ts" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-1.ts" ``` - **`getEnv`** - this function fetches environment variables like your private key from the `.env` file @@ -105,7 +107,7 @@ Before initiating a cross-chain transfer, you must set up the chain context and 2. Open the `native-transfer.ts` file and begin by importing the necessary modules from the SDK and helper files ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:1:14" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:1:14" ``` - **`evm`** - this import is for working with EVM-compatible chains, like Avalanche, Ethereum, Base Sepolia, and more @@ -116,7 +118,7 @@ Before initiating a cross-chain transfer, you must set up the chain context and 3. **Initialize the Wormhole SDK** - initialize the `wormhole` function for the `Testnet` environment and specify the platforms (EVM, Solana, and Sui) to support. This allows us to interact with both EVM-compatible chains like Ethereum and non-EVM chains like Solana and Sui ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:15:16" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:15:16" ``` !!! note @@ -125,31 +127,31 @@ Before initiating a cross-chain transfer, you must set up the chain context and 4. **Set up source and destination chains** - specify the source chain (Sui) and the destination chain (Solana) using the `getChain` method. This allows us to define where to send the native tokens and where to receive them ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:19:20" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:19:20" ``` 5. **Configure the signers** - use the `getSigner` function to retrieve the signers responsible for signing transactions on the respective chains. This ensures that transactions are correctly authorized on both the source and destination chains ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:23:24" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:23:24" ``` 6. **Define the token to transfer** - specify the native token on the source chain (Sui in this example) by creating a `TokenId` object ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:27:27" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:27:27" ``` 7. **Define the transfer amount** - the amount of native tokens to transfer is specified. In this case, we're transferring 1 unit ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:30:30" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:30:30" ``` 8. **Set transfer mode** - specify that the transfer should be manual by setting `automatic = false`. This means you will need to handle the attestation and finalization steps yourself ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:33:33" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:33:33" ``` !!! note @@ -158,19 +160,19 @@ Before initiating a cross-chain transfer, you must set up the chain context and 9. **Define decimals** - fetch the number of decimals for the token on the source chain (Sui) using the `getTokenDecimals` function ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:36:36" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:36:36" ``` 10. **Perform the token transfer and exit the process** - initiate the transfer by calling the `tokenTransfer` function, which we’ll define in the next step. This function takes an object containing all required details for executing the transfer, including the `source` and `destination` chains, `token`, `mode`, and transfer `amount` ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:39:45" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:39:45" ``` Finally, we use `process.exit(0);` to close the script once the transfer completes ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:47:48" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:47:48" ``` ### Token Transfer Logic @@ -182,8 +184,8 @@ This section defines the `tokenTransfer` function, which manages the core steps The `tokenTransfer` function initiates and manages the transfer process, handling all necessary steps to move tokens across chains with the Wormhole SDK. This function uses types from the SDK and our `helpers.ts` file to ensure chain compatibility. ```typescript ---8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:50:61" ---8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:96" +--8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:50:61" +--8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:96" ``` #### Steps to Transfer Tokens @@ -193,19 +195,19 @@ The `tokenTransfer` function consists of several key steps to facilitate the cro 1. **Initialize the transfer object** - the `tokenTransfer` function begins by creating a `TokenTransfer` object, `xfer`, which tracks the state of the transfer process and provides access to relevant methods for each transfer step ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:63:70" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:63:70" ``` 2. **Estimate transfer fees and validate amount** - we obtain a fee quote for the transfer before proceeding. This step is significant in automatic mode (`automatic = true`), where the quote will include additional fees for relaying ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:72:80" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:72:80" ``` 3. **Submit the transaction to the source chain** - initiate the transfer on the source chain by submitting the transaction using `route.source.signer`, starting the token transfer process ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:84:85" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:84:85" ``` - **`srcTxids`** - the resulting transaction IDs are printed to the console. These IDs can be used to track the transfer’s progress on the source chain and [Wormhole network](https://wormholescan.io/#/?network=Testnet){target=\_blank} @@ -223,20 +225,20 @@ The `tokenTransfer` function consists of several key steps to facilitate the cro 4. **Wait for the attestation** - retrieve the Wormhole attestation (VAA), which serves as cryptographic proof of the transfer. In manual mode, you must wait for the VAA before redeeming the transfer on the destination chain ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:90:90" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:90:90" ``` 5. **Complete the transfer on the destination chain** - redeem the VAA on the destination chain to finalize the transfer ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts:94:95" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts:94:95" ``` You can find the complete native token transfer script below: ??? code "`native-transfer.ts`" ```typescript - --8<-- "code/tutorials/messaging/token-bridge/token-bridge-2.ts" + --8<-- "code/tutorials/by-product/wormhole-sdk/tokens-via-token-bridge/token-bridge-2.ts" ``` ### Run the Native Token Transfer diff --git a/tutorials/messaging/cctp.md b/tutorials/by-product/wormhole-sdk/usdc-via-cctp.md similarity index 89% rename from tutorials/messaging/cctp.md rename to tutorials/by-product/wormhole-sdk/usdc-via-cctp.md index d560eb94..3e5a8ed4 100644 --- a/tutorials/messaging/cctp.md +++ b/tutorials/by-product/wormhole-sdk/usdc-via-cctp.md @@ -5,6 +5,8 @@ description: Learn how to perform USDC cross-chain transfers using Wormhole SDK # Transfer USDC via CCTP and Wormhole SDK +:simple-github: [Source code on GitHub](https://github.com/wormhole-foundation/demo-cctp-transfer){target=\_blank} + ## Introduction In this guide, we will show you how to bridge native USDC across different blockchain networks using [Circle's Cross-Chain Transfer Protocol](/learn/messaging/cctp/){target=\_blank} (CCTP) and [Wormhole’s TypeScript SDK](https://github.com/wormhole-foundation/wormhole-sdk-ts/tree/main){target=\_blank}. @@ -82,7 +84,7 @@ In this section, you'll set up your project for transferring USDC across chains 2. Open the `helpers.ts` file and add the following code ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-1.ts" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-1.ts" ``` - **`getEnv`** - this function fetches environment variables like your private key from the `.env` file @@ -99,7 +101,7 @@ In this section, you'll set up your project for transferring USDC across chains 2. Open the `manual-transfer.ts` file and begin by importing the necessary modules from the SDK and helper files ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:1:4" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:1:4" ``` - **`evm`** - this import is for working with EVM-compatible chains, like Avalanche, Ethereum, Base Sepolia, and more @@ -121,7 +123,7 @@ Before initiating a cross-chain transfer, you must set up the chain context and 1. **Initialize the Wormhole SDK** - initialize the `wormhole` function for the `Testnet` environment and specify the platforms (EVM and Solana) to support. This allows us to interact with both EVM-compatible chains like Avalanche and non-EVM chains like Solana if needed ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:6:7" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:6:7" ``` !!! note @@ -130,25 +132,25 @@ Before initiating a cross-chain transfer, you must set up the chain context and 2. **Set up source and destination chains** - specify the source chain (Avalanche) and the destination chain (Sepolia) using the `getChain` method. This allows us to define where to send the USDC and where to receive them ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:10:11" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:10:11" ``` 3. **Configure the signers** - use the `getSigner` function to retrieve the signers responsible for signing transactions on the respective chains. This ensures that transactions are correctly authorized on both the source and destination chains ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:14:15" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:14:15" ``` 4. **Define the transfer amount** - the amount of USDC to transfer is specified. In this case, we're transferring 0.1 USDC, which is parsed and converted into the base units expected by the Wormhole SDK ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:18:18" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:18:18" ``` 5. **Set transfer mode** - we specify that the transfer should be manual by setting `automatic = false`. This means you will need to handle the attestation and finalization steps yourself ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:20:20" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:20:20" ``` #### Initiate the Transfer @@ -158,13 +160,13 @@ To begin the manual transfer process, you first need to create the transfer obje 1. **Create the Circle transfer object** - the `wh.circleTransfer()` function creates an object with the transfer details, such as the amount of USDC, the source and destination addresses, and the mode. However, this does not initiate the transfer itself ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:23:28" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:23:28" ``` 2. **Start the transfer** - the `initiateTransfer` function sends the transaction on the source chain. It involves signing and sending the transaction using the source signer. This will return a list of transaction IDs (`srcTxIds`) that you can use to track the transfer ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:34:35" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:34:35" ``` #### Fetch the Circle Attestation (VAA) @@ -175,13 +177,13 @@ Once you initialize the transfer on the source chain, you must fetch the VAA fro 1. **Set a timeout** - fetching the attestation can take some time, so setting a timeout is common. In this example, we set the timeout to 60 seconds ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:38:38" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:38:38" ``` 2. **Fetch the attestation** - after initiating the transfer, you can use the `fetchAttestation()` function to retrieve the VAA. This function will wait until the attestation is available or you reach the specified timeout ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:40:41" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:40:41" ``` The `attestIds` will contain the details of the fetched attestation, which Wormhole uses to complete the transfer on the destination chain @@ -193,7 +195,7 @@ Once you fetch the VAA correctly, the final step is to complete the transfer on Use the `completeTransfer()` function to finalize the transfer on the destination chain. This requires the destination signer to sign and submit the transaction to the destination chain ```typescript ---8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts:45:50" +--8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts:45:50" ``` The `dstTxIds` will hold the transaction IDs for the transfer on the destination chain, confirming that the transfer has been completed @@ -202,7 +204,7 @@ You can find the full code for the manual USDC transfer script below: ???- code "`manual-transfer.ts`" ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-2.ts" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-2.ts" ``` ### Run Manual Transfer @@ -226,7 +228,7 @@ This feature is handy for recovering an incomplete transfer or when debugging. Here’s how you can complete a partial transfer using just the source chain and transaction hash: ```typescript ---8<-- "code/tutorials/messaging/cctp/cctp-sdk-4.ts:19:29" +--8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-4.ts:19:29" ``` You will need to provide the below requirements to complete the partial transfer: @@ -240,7 +242,7 @@ You can find the full code for the manual USDC transfer script below: ??? code "`partial-transfer.ts`" ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-4.ts" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-4.ts" ``` ## Automatic Transfers @@ -254,7 +256,7 @@ The automatic transfer process simplifies the steps by automating the attestatio The setup for automatic transfers is similar to manual transfers, with the key difference being that the `automatic` flag is `true`. This indicates that Wormhole will handle the attestation and finalization steps for you ```typescript ---8<-- "code/tutorials/messaging/cctp/cctp-sdk-3.ts:21:21" +--8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-3.ts:21:21" ``` #### Initiate the Transfer @@ -262,7 +264,7 @@ The setup for automatic transfers is similar to manual transfers, with the key d The transfer process is the same as that for manual transfers. You create the transfer object and then start the transfer on the source chain ```typescript ---8<-- "code/tutorials/messaging/cctp/cctp-sdk-3.ts:24:29" +--8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-3.ts:24:29" ``` #### Log Transfer Details @@ -270,14 +272,14 @@ The transfer process is the same as that for manual transfers. You create the tr After initiating the transfer, you can log the transaction IDs for both the source and destination chains. This will help you track the progress of the transfer ```typescript ---8<-- "code/tutorials/messaging/cctp/cctp-sdk-3.ts:35:38" +--8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-3.ts:35:38" ``` You can find the full code for the automatic USDC transfer script below: ??? code "`automatic-transfer.ts`" ```typescript - --8<-- "code/tutorials/messaging/cctp/cctp-sdk-3.ts" + --8<-- "code/tutorials/by-product/wormhole-sdk/usdc-via-cctp/cctp-sdk-3.ts" ``` ### Run Automatic Transfer diff --git a/tutorials/index.md b/tutorials/index.md index 816600a2..567dc5f9 100644 --- a/tutorials/index.md +++ b/tutorials/index.md @@ -6,26 +6,18 @@ template: root-index-page.html # Tutorials -## Get Started +Welcome to the Wormhole tutorials section! Whether you're just getting started or looking to build advanced cross-chain applications, this collection of step-by-step tutorials will help you leverage the full power of the Wormhole ecosystem. -This section contains step-by-step tutorials to help you build with Wormhole. +These tutorials are designed to help you develop efficient, scalable, and innovative cross-chain applications, from integrating individual Wormhole products to creating comprehensive end-to-end solutions. Explore our tutorials to get hands-on experience with Wormhole!
-- :octicons-checklist-16:{ .lg .middle } **Messaging** +- :octicons-apps-16:{ .lg .middle } **By Product** --- - Follow these tutorials to use Wormhole's cross-chain messaging infrastructure to simplify data transmission, event triggering, and transaction initiation, allowing smart contracts to interact seamlessly across multiple blockchains. + Explore tutorials tailored to specific Wormhole products. Each section contains tutorials on integrating and using a single product. Whether you want to understand Token Bridge, Wormhole Connect, or other Wormhole services, these tutorials will guide you through the setup and implementation process. - [:octicons-arrow-right-16: Start building](/docs/tutorials/messaging/) - -- :octicons-law-16:{ .lg .middle } **MultiGov** - - --- - - Dive into the tutorials in this section to gain hands-on experience executing cross-chain governance actions, including treasury management proposals, using Wormhole's cross-chain governance solution, MultiGov. - - [:octicons-arrow-right-16: Start building](/docs/tutorials/multigov/) + [:octicons-arrow-right-16: Start building](/docs/tutorials/by-product/)
diff --git a/tutorials/messaging/.pages b/tutorials/messaging/.pages deleted file mode 100644 index 2816a21c..00000000 --- a/tutorials/messaging/.pages +++ /dev/null @@ -1,8 +0,0 @@ -title: Messaging -nav: - - index.md - - 'Create Cross-Chain Contracts': 'cross-chain-contracts.md' - - 'Create Cross-Chain Token Transfers': 'cross-chain-token-contracts.md' - - 'Transfer USDC via Wormhole SDK': 'cctp.md' - - 'Transfer Tokens Cross-Chain with Connect': 'sui-connect.md' - - 'Transfer Tokens via Token Bridge': 'token-bridge.md' \ No newline at end of file diff --git a/tutorials/messaging/index.md b/tutorials/messaging/index.md deleted file mode 100644 index 80ee00a4..00000000 --- a/tutorials/messaging/index.md +++ /dev/null @@ -1,54 +0,0 @@ ---- -title: Tutorials - Messaging -description: Step-by-step guides to using Wormhole's messaging infrastructure to simplify data transmission, event triggering, and transaction initiation across blockchains. ---- - -# Messaging Tutorials - -## Get Started - -Wormhole's cross-chain messaging infrastructure simplifies data transmission, event triggering, and transaction initiation, allowing smart contracts to interact seamlessly across multiple blockchains. The following sections include guides for building your own projects using Wormhole's cross-chain messaging capabilities. - -
- -- :octicons-tools-16:{ .lg .middle } **Create Cross-Chain Contracts** - - --- - - This tutorial guides you through building a fully functioning cross-chain message sender and receiver using Solidity, understanding how to interact with the Wormhole relayer, managing cross-chain costs, and configuring your smart contracts correctly on both source and target chains. - - [:octicons-arrow-right-16: Start building](/docs/tutorials/messaging/cross-chain-contracts/) - -- :octicons-rocket-16:{ .lg .middle } **Cross-Chain Token Transfers** - - --- - - Learn how to create cross-chain token transfers using Wormhole's Solidity SDK. Build and deploy smart contracts to send tokens from one blockchain to another. - - [:octicons-arrow-right-16: Get started](/docs/tutorials/messaging/cross-chain-token-contracts/) - -- :octicons-code-16:{ .lg .middle } **Transfer USDC via CCTP and Wormhole SDK** - - --- - - Learn how to perform USDC cross-chain transfers using Wormhole SDK and Circle's CCTP. This guide supports manual, automatic, and partial transfer recovery. - - [:octicons-arrow-right-16: Learn more](/docs/tutorials/messaging/cctp/) - -- :octicons-arrow-switch-16:{ .lg .middle } **Transfer Tokens with Connect** - - --- - - Learn how to use Wormhole Connect to transfers tokens cross-chain seamlessly between Sui and Avalanche Fuji with a step-by-step guide. - - [:octicons-arrow-right-16: Learn more](/docs/tutorials/messaging/cctp/) - -- :octicons-arrow-switch-16:{ .lg .middle } **Native Token Transfer with Token Bridge** - - --- - - This tutorial shows you how to build a cross-chain token transfer app with Wormhole’s TypeScript SDK, configure chains, manage transfers, and handle attestations. - - [:octicons-arrow-right-16: Start building](/docs/tutorials/messaging/token-bridge/) - -
diff --git a/tutorials/multigov/index.md b/tutorials/multigov/index.md deleted file mode 100644 index bb1e1f23..00000000 --- a/tutorials/multigov/index.md +++ /dev/null @@ -1,22 +0,0 @@ ---- -title: Step-by-Step MultiGov Tutorials -description: Access step-by-step guides for executing cross-chain governance actions, including treasury management proposals with MultiGov and Wormhole. ---- - -# MultiGov Tutorials - -Welcome to the MultiGov tutorials section. In this section, you will find tutorials that walk you through the key steps of working with MultiGov, providing clear instructions to help you get started. As you explore, you'll gain a deeper understanding of MultiGov's features and functionality. - -## Get Started - -
- -- :octicons-code-square-16:{ .lg .middle } **Cross-Chain Treasury Management Proposal** - - --- - - Learn how to initiate a proposal on a hub chain, vote from spoke chains, aggregate the votes, and execute the proposal using MultiGov. - - [:octicons-arrow-right-16: Start building](/docs/tutorials/multigov/treasury-proposal/) - -