Skip to content

Adds Transfer Wrapped Assets guide to Token Bridge section #461

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

dawnkelly09
Copy link
Collaborator

Description

Replaces PR #459, which I will close.

This PR creates the Transfer Wrapped Assets guide for the Token Bridge product section. The demo project does the following:

  • This is an end-to-end example of manually transferring an arbitrary ERC-20 token from Moonbase Alpha to Ethereum Sepolia via Token Bridge. (Solana/Sui guide(s) will be created under separate PR)
  • Starts from creating a new project. I have a demo repository I'd like to ask Evgeni about sharing, but I can't until he returns. I wrote the guide to work without it, and will update as needed in a separate PR if we get the ok to use the repo
  • Uses the "loading your private key values from a secure keystore of your choice" approach to private keys
  • Flow: Transfer check for attestation --> dropdown with attestation steps for those who need it --> initiate transfer --> fetch VAA --> redeem VAA to complete transfer

TODO items: missing links to pending Token Bridge-related guides for Next Steps

Checklist
[x ] Required - I have added a label to this PR 🏷️
[ x] Required - I have run my changes through Grammarly
[ n/a ] If pages have been moved, I have created redirects in the wormhole-mkdocs repo

@dawnkelly09 dawnkelly09 added A0 - New Content Pull request contains new content pages B0 - Needs Review Pull request is ready for review labels Jun 10, 2025
@dawnkelly09 dawnkelly09 requested a review from Copilot June 10, 2025 18:37
Copilot

This comment was marked as outdated.

Copy link
Collaborator

@Telucero Telucero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great Job!
Only two minor things.

@kapetan3sid kapetan3sid requested a review from martin0995 June 16, 2025 12:39
Copy link
Collaborator

@martin0995 martin0995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM from a technical perspective. The page needs to be added to the .pages file for visibility.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new end-to-end guide for transferring wrapped assets via the Token Bridge, updates navigation and index files, and provides full code and terminal snippets.

  • Introduces transfer-wrapped-assets.md with attestation, transfer, and redemption flows
  • Updates sidebar (.pages) and LLMS index to include the new guide
  • Supplies helper functions and TypeScript snippets demonstrating the complete transfer process

Reviewed Changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
products/token-bridge/guides/transfer-wrapped-assets.md New guide covering attestation, automatic/manual transfer, VAA fetching, and redemption
products/token-bridge/guides/.pages Added navigation entry for the new guide
llms.txt Added LLMS index entry pointing to the new guide
.snippets/code/products/token-bridge/guides/transfer-wrapped-assets/helpers.ts Helper functions for signer setup and decimal conversion
.snippets/code/products/token-bridge/guides/transfer-wrapped-assets/transfer01.ts Complete transfer flow implementation in TypeScript
.snippets/code/products/token-bridge/guides/transfer-wrapped-assets/terminal01.html Initial terminal output for attestation check
.snippets/code/products/token-bridge/guides/transfer-wrapped-assets/terminal02.html Terminal output for attestation flow
.snippets/code/products/token-bridge/guides/transfer-wrapped-assets/terminal03.html Terminal output for manual transfer completion
Comments suppressed due to low confidence (4)

products/token-bridge/guides/transfer-wrapped-assets.md:11

  • The introduction mentions transferring from Moonbase Alpha to Solana, but the PR description states Ethereum Sepolia. Update to reflect the correct source and destination chains consistently.
This guide demonstrates the transfer of wrapped assets using the Token Bridge protocol via the TypeScript SDK. This example will transfer an arbitrary ERC-20 token from Moonbase Alpha to Solana but can be adapted for any supported chains. View this list of chains with [deployed Token Bridge contracts](/products/reference/contract-addresses/#token-bridge){target=\_blank} to verify if your desired source and destination chains are supported.

.snippets/code/products/token-bridge/guides/transfer-wrapped-assets/transfer01.ts:133

  • The comment says 'source chain' but the code uses destinationChain.config.nativeTokenDecimals. Update the comment to reference the destination chain or adjust the logic if needed.
  // Get the decimals for the source chain

.snippets/code/products/token-bridge/guides/transfer-wrapped-assets/transfer01.ts:82

  • Redeclaring const payer inside the same block shadows the earlier variable and will cause a syntax error. Rename this variable (e.g., destPayer) to avoid redeclaration.
      const payer = toNative(

.snippets/code/products/token-bridge/guides/transfer-wrapped-assets/helpers.ts:38

  • EVM_PRIVATE_KEY is referenced but not defined or imported. Use process.env.EVM_PRIVATE_KEY (or your keystore API) to load environment variables securely.
      ).getSigner(await chain.getRpc(), EVM_PRIVATE_KEY!);

Copy link
Collaborator

@martin0995 martin0995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! Just a few minor adjustments to make, almost ready to go!

@eshaben eshaben self-assigned this Jun 19, 2025
martin0995
martin0995 previously approved these changes Jun 25, 2025
Copy link
Collaborator

@martin0995 martin0995 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🚀

Copy link
Collaborator

@eshaben eshaben left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, it's looking good!

I added a few comments with ideas that came up while reviewing. Some might not belong on this page, but they could be useful to consider for elsewhere.

Also, I noticed there were some comments from my last review that weren't marked as resolved. They're hidden when you look at the main PR page, so maybe go through and expand all convos to just double-check all the things.


Follow these steps to add the rest of the logic to initiate the token transfer on the source chain:

1. Open your `transfer.ts` file and add the following code:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where in the transfer.ts file does this need to be added? Although might be obvious to add it to the end, let's make it super clear


- Defines the transfer as automatic or manual. To use automatic transfer, both the source and destination chain must have an existing `tokenBridgeRelayer` contract. You can check the list of [deployed `tokenBridgeRelayer` contracts](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/a48c9132015279ca6a2d3e9c238a54502b16fc7e/core/base/src/constants/contracts/tokenBridgeRelayer.ts){target=\_blank} in the Wormhole SDK repo to see if your desired chains are supported.
- Sets an optional amount for native gas drop-off. This option allows you to send a small amount of the destination chain's native token for gas fees. Native gas drop-off is currently only supported for automatic transfers.
- Builds the transfer object, initiates the transfer, signs and sends the transaction.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Builds the transfer object, initiates the transfer, signs and sends the transaction.
- Builds the transfer object, initiates the transfer, signs the transaction, and sends it.


This code does the following:

- Defines the transfer as automatic or manual. To use automatic transfer, both the source and destination chain must have an existing `tokenBridgeRelayer` contract. You can check the list of [deployed `tokenBridgeRelayer` contracts](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/a48c9132015279ca6a2d3e9c238a54502b16fc7e/core/base/src/constants/contracts/tokenBridgeRelayer.ts){target=\_blank} in the Wormhole SDK repo to see if your desired chains are supported.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Defines the transfer as automatic or manual. To use automatic transfer, both the source and destination chain must have an existing `tokenBridgeRelayer` contract. You can check the list of [deployed `tokenBridgeRelayer` contracts](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/a48c9132015279ca6a2d3e9c238a54502b16fc7e/core/base/src/constants/contracts/tokenBridgeRelayer.ts){target=\_blank} in the Wormhole SDK repo to see if your desired chains are supported.
- Defines the transfer as automatic or manual. For automatic transfers, both the source and destination chain must have an existing `TokenBridgeRelayer` contract, which listens for and completes transfers on your behalf. You can check the list of [deployed `TokenBridgeRelayer` contracts](https://github.com/wormhole-foundation/wormhole-sdk-ts/blob/a48c9132015279ca6a2d3e9c238a54502b16fc7e/core/base/src/constants/contracts/tokenBridgeRelayer.ts){target=\_blank} in the Wormhole SDK repo to see if your desired chains are supported.

I think it's implied, but can add a tiny bit more context here to make it super clear


You can now go on to [initiate the transfer](#initiate-transfer-on-source-chain) on the source chain.

## Initiate Transfer on Source Chain
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be nice to briefly describe the difference between automatic vs manual - it is sort of covered in the comments in the code but might be nice to provide this info explicitly and upfront.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to look at this as key differences that affect how you write the script. See what you think....


1. Open your `transfer.ts` file and add the following code:

```typescript title="transfer.ts"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still think tabs for automatic vs manual might be helpful here, because if going with manual there's some automatic variables that aren't necessary, and if going with automatic, there's extra unnecessary logic for completing the transfer

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For manual transfers, maybe showcase the isTransferCompleted function at the end?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the tabs and I like it! Attempted to separate these out to just what's needed for manual and auto on each tab but I haven't tested them yet.

- Sets an optional amount for native gas drop-off. This option allows you to send a small amount of the destination chain's native token for gas fees. Native gas drop-off is currently only supported for automatic transfers.
- Builds the transfer object, initiates the transfer, signs and sends the transaction.
- If the transfer is automatic, the flow ends. Otherwise, the script waits for the signed VAA confirming the transaction on the source chain. The signed VAA is then submitted to the destination chain to claim the tokens and complete the manual transfer.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if a user wants to send a payload? What would that look like? I think this is the time to go over all of the different options available

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I've started to think about automatic transfers a bit more, we don't really mention anything about fees, what are the fees, how do they paid for, how much can be swapped for native tokens. Maybe we can briefly mention some of these things here, maybe other items would be better addressed in a separate guide (i.e., reference docs on maxSwapAmount function could have an example on how to use that function to get the max amount)


2. Run the script with the following command:
```bash
npx tsx transfer.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment still applies

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A0 - New Content Pull request contains new content pages B0 - Needs Review Pull request is ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants