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 6 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.


--8<-- 'code/products/token-bridge/guides/transfer-wrapped-assets/terminal01.html'

??? example "Need to register a token?"
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like this should be before defining the transfer.ts file because in the transfer.ts you mention:
"Open attestToken.ts, define the token address, and run npx tsx attest:token" and at that point the file hasn't been introduced yet.

Maybe first check if the token is attested, and then present the transfer logic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

See if the new flow feels better now that I've refactored things.

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!

npx tsx transfer.ts
```

If the token is registered on the destination chain, the address of the existing wrapped asset is returned, and you can continue to [initiate the transfer](#initiate-transfer-on-source-chain) on the source chain. If the token is not registered, you will see a message similar to the following advising the attestation flow will run:
Copy link
Collaborator

Choose a reason for hiding this comment

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

When I run it, the token address is not returned. I know the token is already wrapped because I used it in the past, and it doesn't throw an error.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just ran locally with a known token:

dawnkelly@Mac manual-tb-demo % npx tsx transfer.ts
✅ Token already registered on destination: SolanaAddress {
type: 'Native',
address: PublicKey [PublicKey(2qjSAGrpT2eTb673KuGAR5s6AJfQ1X5Sg177Qzuqt7yB)] {
_bn: <BN: 1b578bb9b7a04a1aab3b5b64b550d8fc4f73ab343c9cf8532d2976b77ec4a8ca>
}
}

And a brand new token:

dawnkelly@Mac manual-tb-demo % npx tsx transfer.ts
⚠️ Token is NOT registered on destination. Running attestation flow...

So idk???

@eshaben eshaben self-assigned this Jun 19, 2025
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