diff --git a/.snippets/code/build/core-messaging/core-contracts/attestToken.sol b/.snippets/code/build/core-messaging/core-contracts/attestToken.sol index bebc0382c..67f9c73e0 100644 --- a/.snippets/code/build/core-messaging/core-contracts/attestToken.sol +++ b/.snippets/code/build/core-messaging/core-contracts/attestToken.sol @@ -1,8 +1,9 @@ IWormhole wormhole = IWormhole(wormholeAddr); +ITokenBridge tokenBridge = ITokenBridge(tokenBridgeAddr); uint256 wormholeFee = wormhole.messageFee(); -wormhole.attestToken{value: wormholeFee}( +tokenBridge.attestToken{value: wormholeFee}( address(tokenImpl), // the token contract to attest 234 // nonce for the transfer ); \ No newline at end of file diff --git a/.snippets/code/build/transfers/cctp/CircleIntegration.sol b/.snippets/code/build/transfers/cctp/CircleIntegration.sol index 2a2bbe973..68b54b367 100644 --- a/.snippets/code/build/transfers/cctp/CircleIntegration.sol +++ b/.snippets/code/build/transfers/cctp/CircleIntegration.sol @@ -69,7 +69,7 @@ contract CircleIntegration is // Call the circle bridge and `depositForBurnWithCaller`. The `mintRecipient` // should be the target contract (or wallet) composing on this contract. - (uint64 nonce, uint256 amountReceived) = _transferTokens{value: wormholeFee}( + (uint64 nonce, uint256 amountReceived) = _transferTokens( transferParams.token, transferParams.amount, transferParams.targetChain, diff --git a/build/transfers/token-bridge.md b/build/transfers/token-bridge.md index 350125143..a9ae5ae15 100644 --- a/build/transfers/token-bridge.md +++ b/build/transfers/token-bridge.md @@ -27,7 +27,7 @@ The primary functions of the Token Bridge contracts revolve around: - **Transferring tokens** - locking and minting tokens across chains - **Transferring tokens with a payload** - including additional data with transfers -### Attest a token +### Attest a Token Suppose a token has never been transferred to the target chain before transferring it cross-chain. In that case, its metadata must be registered so the Token Bridge can recognize it and create a wrapped version if necessary. @@ -58,6 +58,12 @@ function attestToken( A unique identifier for the attestation transaction. +??? interface "Example" + + ```solidity + --8<-- 'code/build/core-messaging/core-contracts/attestToken.sol' + ``` + When `attestToken()` is called, the contract emits a Verifiable Action Approval (VAA) containing the token's metadata, which the Guardians sign and publish. You must ensure the token is ERC-20 compliant. If it does not implement the standard functions, the attestation may fail or produce incomplete metadata. @@ -116,6 +122,12 @@ function transferTokens( A unique identifier for the transfer transaction. +??? interface "Example" + + ```solidity + --8<-- 'code/build/core-messaging/core-contracts/transferTokens.sol' + ``` + Once a transfer VAA is obtained from the Wormhole Guardian network, the final step is to redeem the tokens on the destination chain. Redemption verifies the VAA's authenticity and releases (or mints) tokens to the specified recipient. To redeem the tokens, call `completeTransfer()`. ```solidity @@ -132,7 +144,7 @@ function completeTransfer(bytes memory encodedVm) external; - The Token Bridge normalizes token amounts to 8 decimals when passing them between chains. Make sure your application accounts for potential decimal truncation - The VAA ensures the integrity of the message. Only after the Guardians sign the VAA can it be redeemed on the destination chain -### Transfer tokens with payload +### Transfer Tokens with Payload While a standard token transfer moves tokens between chains, a transfer with a payload allows you to embed arbitrary data in the VAA. This data can be used on the destination chain to execute additional logic—such as automatically depositing tokens into a DeFi protocol, initiating a swap on a DEX, or interacting with a custom smart contract. @@ -186,6 +198,12 @@ function transferTokensWithPayload( A unique identifier for the transfer transaction. +??? interface "Example" + + ```solidity + --8<-- 'code/build/core-messaging/core-contracts/transferTokensWithPayload.sol' + ``` + After initiating a transfer on the source chain, the Wormhole Guardian network observes and signs the resulting message, creating a Verifiable Action Approval (VAA). You'll need to fetch this VAA and then call `completeTransferWithPayload()`. Only the designated recipient contract can redeem tokens. This ensures that the intended contract securely handles the attached payload. On successful redemption, the tokens are minted (if foreign) or released (if native) to the recipient address on the destination chain. For payload transfers, the designated contract can execute the payload's logic at this time. diff --git a/llms-files/llms-token-bridge.txt b/llms-files/llms-token-bridge.txt index 1cf4add75..7320fc9b3 100644 --- a/llms-files/llms-token-bridge.txt +++ b/llms-files/llms-token-bridge.txt @@ -119,7 +119,7 @@ The primary functions of the Token Bridge contracts revolve around: - **Transferring tokens** - locking and minting tokens across chains - **Transferring tokens with a payload** - including additional data with transfers -### Attest a token +### Attest a Token Suppose a token has never been transferred to the target chain before transferring it cross-chain. In that case, its metadata must be registered so the Token Bridge can recognize it and create a wrapped version if necessary. @@ -150,6 +150,20 @@ function attestToken( A unique identifier for the attestation transaction. +??? interface "Example" + + ```solidity + IWormhole wormhole = IWormhole(wormholeAddr); +ITokenBridge tokenBridge = ITokenBridge(tokenBridgeAddr); + +uint256 wormholeFee = wormhole.messageFee(); + +tokenBridge.attestToken{value: wormholeFee}( + address(tokenImpl), // the token contract to attest + 234 // nonce for the transfer +); + ``` + When `attestToken()` is called, the contract emits a Verifiable Action Approval (VAA) containing the token's metadata, which the Guardians sign and publish. You must ensure the token is ERC-20 compliant. If it does not implement the standard functions, the attestation may fail or produce incomplete metadata. @@ -208,6 +222,25 @@ function transferTokens( A unique identifier for the transfer transaction. +??? interface "Example" + + ```solidity + IWormhole wormhole = IWormhole(wormholeAddr); +ITokenBridge tokenBridge = ITokenBridge(tokenBridgeAddr); + +// Get the fee for publishing a message +uint256 wormholeFee = wormhole.messageFee(); + +tokenBridge.transferTokens{value: wormholeFee}( + token, // address of the ERC-20 token to transfer + amount, // amount of tokens to transfer + recipientChain, // Wormhole chain ID of the destination chain + recipient, // recipient address on the destination chain (as bytes32) + arbiterFee, // fee for relayer + nonce // nonce for this transfer +); + ``` + Once a transfer VAA is obtained from the Wormhole Guardian network, the final step is to redeem the tokens on the destination chain. Redemption verifies the VAA's authenticity and releases (or mints) tokens to the specified recipient. To redeem the tokens, call `completeTransfer()`. ```solidity @@ -224,7 +257,7 @@ function completeTransfer(bytes memory encodedVm) external; - The Token Bridge normalizes token amounts to 8 decimals when passing them between chains. Make sure your application accounts for potential decimal truncation - The VAA ensures the integrity of the message. Only after the Guardians sign the VAA can it be redeemed on the destination chain -### Transfer tokens with payload +### Transfer Tokens with Payload While a standard token transfer moves tokens between chains, a transfer with a payload allows you to embed arbitrary data in the VAA. This data can be used on the destination chain to execute additional logic—such as automatically depositing tokens into a DeFi protocol, initiating a swap on a DEX, or interacting with a custom smart contract. @@ -278,6 +311,25 @@ function transferTokensWithPayload( A unique identifier for the transfer transaction. +??? interface "Example" + + ```solidity + IWormhole wormhole = IWormhole(wormholeAddr); +ITokenBridge tokenBridge = ITokenBridge(tokenBridgeAddr); + +// Get the fee for publishing a message +uint256 wormholeFee = wormhole.messageFee(); + +tokenBridge.transferTokensWithPayload{value: wormholeFee}( + token, // address of the ERC-20 token to transfer + amount, // amount of tokens to transfer + recipientChain, // Wormhole chain ID of the destination chain + recipient, // recipient address on the destination chain (as bytes32) + nonce, // nonce for this transfer + additionalPayload // additional payload data +); + ``` + After initiating a transfer on the source chain, the Wormhole Guardian network observes and signs the resulting message, creating a Verifiable Action Approval (VAA). You'll need to fetch this VAA and then call `completeTransferWithPayload()`. Only the designated recipient contract can redeem tokens. This ensures that the intended contract securely handles the attached payload. On successful redemption, the tokens are minted (if foreign) or released (if native) to the recipient address on the destination chain. For payload transfers, the designated contract can execute the payload's logic at this time. diff --git a/llms-files/llms-transfer.txt b/llms-files/llms-transfer.txt index 048815152..fd6708df6 100644 --- a/llms-files/llms-transfer.txt +++ b/llms-files/llms-transfer.txt @@ -954,7 +954,7 @@ contract CircleIntegration is // Call the circle bridge and `depositForBurnWithCaller`. The `mintRecipient` // should be the target contract (or wallet) composing on this contract. - (uint64 nonce, uint256 amountReceived) = _transferTokens{value: wormholeFee}( + (uint64 nonce, uint256 amountReceived) = _transferTokens( transferParams.token, transferParams.amount, transferParams.targetChain, @@ -7136,7 +7136,7 @@ The primary functions of the Token Bridge contracts revolve around: - **Transferring tokens** - locking and minting tokens across chains - **Transferring tokens with a payload** - including additional data with transfers -### Attest a token +### Attest a Token Suppose a token has never been transferred to the target chain before transferring it cross-chain. In that case, its metadata must be registered so the Token Bridge can recognize it and create a wrapped version if necessary. @@ -7167,6 +7167,20 @@ function attestToken( A unique identifier for the attestation transaction. +??? interface "Example" + + ```solidity + IWormhole wormhole = IWormhole(wormholeAddr); +ITokenBridge tokenBridge = ITokenBridge(tokenBridgeAddr); + +uint256 wormholeFee = wormhole.messageFee(); + +tokenBridge.attestToken{value: wormholeFee}( + address(tokenImpl), // the token contract to attest + 234 // nonce for the transfer +); + ``` + When `attestToken()` is called, the contract emits a Verifiable Action Approval (VAA) containing the token's metadata, which the Guardians sign and publish. You must ensure the token is ERC-20 compliant. If it does not implement the standard functions, the attestation may fail or produce incomplete metadata. @@ -7225,6 +7239,25 @@ function transferTokens( A unique identifier for the transfer transaction. +??? interface "Example" + + ```solidity + IWormhole wormhole = IWormhole(wormholeAddr); +ITokenBridge tokenBridge = ITokenBridge(tokenBridgeAddr); + +// Get the fee for publishing a message +uint256 wormholeFee = wormhole.messageFee(); + +tokenBridge.transferTokens{value: wormholeFee}( + token, // address of the ERC-20 token to transfer + amount, // amount of tokens to transfer + recipientChain, // Wormhole chain ID of the destination chain + recipient, // recipient address on the destination chain (as bytes32) + arbiterFee, // fee for relayer + nonce // nonce for this transfer +); + ``` + Once a transfer VAA is obtained from the Wormhole Guardian network, the final step is to redeem the tokens on the destination chain. Redemption verifies the VAA's authenticity and releases (or mints) tokens to the specified recipient. To redeem the tokens, call `completeTransfer()`. ```solidity @@ -7241,7 +7274,7 @@ function completeTransfer(bytes memory encodedVm) external; - The Token Bridge normalizes token amounts to 8 decimals when passing them between chains. Make sure your application accounts for potential decimal truncation - The VAA ensures the integrity of the message. Only after the Guardians sign the VAA can it be redeemed on the destination chain -### Transfer tokens with payload +### Transfer Tokens with Payload While a standard token transfer moves tokens between chains, a transfer with a payload allows you to embed arbitrary data in the VAA. This data can be used on the destination chain to execute additional logic—such as automatically depositing tokens into a DeFi protocol, initiating a swap on a DEX, or interacting with a custom smart contract. @@ -7295,6 +7328,25 @@ function transferTokensWithPayload( A unique identifier for the transfer transaction. +??? interface "Example" + + ```solidity + IWormhole wormhole = IWormhole(wormholeAddr); +ITokenBridge tokenBridge = ITokenBridge(tokenBridgeAddr); + +// Get the fee for publishing a message +uint256 wormholeFee = wormhole.messageFee(); + +tokenBridge.transferTokensWithPayload{value: wormholeFee}( + token, // address of the ERC-20 token to transfer + amount, // amount of tokens to transfer + recipientChain, // Wormhole chain ID of the destination chain + recipient, // recipient address on the destination chain (as bytes32) + nonce, // nonce for this transfer + additionalPayload // additional payload data +); + ``` + After initiating a transfer on the source chain, the Wormhole Guardian network observes and signs the resulting message, creating a Verifiable Action Approval (VAA). You'll need to fetch this VAA and then call `completeTransferWithPayload()`. Only the designated recipient contract can redeem tokens. This ensures that the intended contract securely handles the attached payload. On successful redemption, the tokens are minted (if foreign) or released (if native) to the recipient address on the destination chain. For payload transfers, the designated contract can execute the payload's logic at this time. diff --git a/llms-full.txt b/llms-full.txt index 3aba5f180..a0cfa522c 100644 --- a/llms-full.txt +++ b/llms-full.txt @@ -8106,7 +8106,7 @@ contract CircleIntegration is // Call the circle bridge and `depositForBurnWithCaller`. The `mintRecipient` // should be the target contract (or wallet) composing on this contract. - (uint64 nonce, uint256 amountReceived) = _transferTokens{value: wormholeFee}( + (uint64 nonce, uint256 amountReceived) = _transferTokens( transferParams.token, transferParams.amount, transferParams.targetChain, @@ -15102,7 +15102,7 @@ The primary functions of the Token Bridge contracts revolve around: - **Transferring tokens** - locking and minting tokens across chains - **Transferring tokens with a payload** - including additional data with transfers -### Attest a token +### Attest a Token Suppose a token has never been transferred to the target chain before transferring it cross-chain. In that case, its metadata must be registered so the Token Bridge can recognize it and create a wrapped version if necessary. @@ -15133,6 +15133,20 @@ function attestToken( A unique identifier for the attestation transaction. +??? interface "Example" + + ```solidity + IWormhole wormhole = IWormhole(wormholeAddr); +ITokenBridge tokenBridge = ITokenBridge(tokenBridgeAddr); + +uint256 wormholeFee = wormhole.messageFee(); + +tokenBridge.attestToken{value: wormholeFee}( + address(tokenImpl), // the token contract to attest + 234 // nonce for the transfer +); + ``` + When `attestToken()` is called, the contract emits a Verifiable Action Approval (VAA) containing the token's metadata, which the Guardians sign and publish. You must ensure the token is ERC-20 compliant. If it does not implement the standard functions, the attestation may fail or produce incomplete metadata. @@ -15191,6 +15205,25 @@ function transferTokens( A unique identifier for the transfer transaction. +??? interface "Example" + + ```solidity + IWormhole wormhole = IWormhole(wormholeAddr); +ITokenBridge tokenBridge = ITokenBridge(tokenBridgeAddr); + +// Get the fee for publishing a message +uint256 wormholeFee = wormhole.messageFee(); + +tokenBridge.transferTokens{value: wormholeFee}( + token, // address of the ERC-20 token to transfer + amount, // amount of tokens to transfer + recipientChain, // Wormhole chain ID of the destination chain + recipient, // recipient address on the destination chain (as bytes32) + arbiterFee, // fee for relayer + nonce // nonce for this transfer +); + ``` + Once a transfer VAA is obtained from the Wormhole Guardian network, the final step is to redeem the tokens on the destination chain. Redemption verifies the VAA's authenticity and releases (or mints) tokens to the specified recipient. To redeem the tokens, call `completeTransfer()`. ```solidity @@ -15207,7 +15240,7 @@ function completeTransfer(bytes memory encodedVm) external; - The Token Bridge normalizes token amounts to 8 decimals when passing them between chains. Make sure your application accounts for potential decimal truncation - The VAA ensures the integrity of the message. Only after the Guardians sign the VAA can it be redeemed on the destination chain -### Transfer tokens with payload +### Transfer Tokens with Payload While a standard token transfer moves tokens between chains, a transfer with a payload allows you to embed arbitrary data in the VAA. This data can be used on the destination chain to execute additional logic—such as automatically depositing tokens into a DeFi protocol, initiating a swap on a DEX, or interacting with a custom smart contract. @@ -15261,6 +15294,25 @@ function transferTokensWithPayload( A unique identifier for the transfer transaction. +??? interface "Example" + + ```solidity + IWormhole wormhole = IWormhole(wormholeAddr); +ITokenBridge tokenBridge = ITokenBridge(tokenBridgeAddr); + +// Get the fee for publishing a message +uint256 wormholeFee = wormhole.messageFee(); + +tokenBridge.transferTokensWithPayload{value: wormholeFee}( + token, // address of the ERC-20 token to transfer + amount, // amount of tokens to transfer + recipientChain, // Wormhole chain ID of the destination chain + recipient, // recipient address on the destination chain (as bytes32) + nonce, // nonce for this transfer + additionalPayload // additional payload data +); + ``` + After initiating a transfer on the source chain, the Wormhole Guardian network observes and signs the resulting message, creating a Verifiable Action Approval (VAA). You'll need to fetch this VAA and then call `completeTransferWithPayload()`. Only the designated recipient contract can redeem tokens. This ensures that the intended contract securely handles the attached payload. On successful redemption, the tokens are minted (if foreign) or released (if native) to the recipient address on the destination chain. For payload transfers, the designated contract can execute the payload's logic at this time.