Skip to content

adjust tokenbridge function & llms generation #440

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

Merged
merged 2 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
);
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
22 changes: 20 additions & 2 deletions build/transfers/token-bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
56 changes: 54 additions & 2 deletions llms-files/llms-token-bridge.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
58 changes: 55 additions & 3 deletions llms-files/llms-transfer.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
58 changes: 55 additions & 3 deletions llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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.

Expand Down Expand Up @@ -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.
Expand Down