-
Notifications
You must be signed in to change notification settings - Fork 26
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
There was a problem hiding this 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?" |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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. Useprocess.env.EVM_PRIVATE_KEY
(or your keystore API) to load environment variables securely.
).getSigner(await chain.getRpc(), EVM_PRIVATE_KEY!);
.snippets/code/products/token-bridge/guides/transfer-wrapped-assets/transfer01.ts
Show resolved
Hide resolved
.snippets/code/products/token-bridge/guides/transfer-wrapped-assets/helpers.ts
Show resolved
Hide resolved
There was a problem hiding this 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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
So idk???
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:
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