-
Notifications
You must be signed in to change notification settings - Fork 149
Ton Gateway #588
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
Ton Gateway #588
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
510526c
TON Gateway docs
fadeev 2bdc8a6
docs
fadeev 008b04a
Update src/pages/developers/chains/ton.mdx
fadeev 57ba7b2
Update src/pages/developers/chains/ton.mdx
fadeev cc8eeda
Update src/pages/developers/chains/ton.mdx
fadeev 075a28a
Update src/pages/developers/chains/ton.mdx
fadeev e1d0279
remove gas fees
fadeev 78b12fb
remove comments
fadeev 0709f96
add ts examples
fadeev db05ff1
Merge branch 'main' into ton-docs
fadeev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| To interact with universal applications from TON, use the TON gateway. | ||
|
|
||
| TON gateway supports: | ||
|
|
||
| - Depositing TON to a universal app or an account on ZetaChain | ||
| - Depositing TON and calling a universal app | ||
| - Withdrawing TON from ZetaChain | ||
fadeev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Deposit TON | ||
|
|
||
| To deposit TON to an EOA or a universal contract, send an internal message to | ||
| the Gateway contract with the following structure: | ||
|
|
||
| ```func | ||
| op_code:uint32 query_id:uint64 evm_recipient:slice (160 bits) | ||
| ``` | ||
|
|
||
| The deposit `op_code` is `101`. `query_id` is reserved for future use, leave it | ||
| to `0`. | ||
|
|
||
| The `evm_recipient` specifies the address on ZetaChain that will receive the | ||
| deposited TON. This can be either an externally-owned account (EOA) or a | ||
| universal app address. | ||
|
|
||
| Here's an example of how to construct the deposit message in TypeScript: | ||
|
|
||
| ```typescript | ||
| const opDeposit = 101; | ||
| const body = beginCell().storeUint(opDeposit, 32).storeUint(0, 64).storeUint(zevmRecipient, 160).endCell(); | ||
| ``` | ||
|
|
||
| After the deposit is processed, the receiver receives the [ZRC-20 | ||
| version](/developers/tokens/zrc20) of the deposited TON. | ||
|
|
||
| ## Deposit TON and Call a Universal App | ||
|
|
||
| To deposit TON and call a universal app contract, send an internal message to | ||
| the Gateway contract with the following structure: | ||
|
|
||
| ```func | ||
| op_code:uint32 query_id:uint64 evm_recipient:slice (160 bits) call_data:cell | ||
| ``` | ||
|
|
||
| The depositAndCall `op_code` is `102`. `query_id` is reserved for future use, | ||
| leave it to `0`. Also note that call_data should be a cell encoded in ["snake | ||
| data"](https://docs.ton.org/v3/guidelines/dapps/asset-processing/nft-processing/metadata-parsing#snake-data-encoding) | ||
| format (supported by most TON libraries) | ||
|
|
||
| The `evm_recipient` must be the address of a universal app contract. | ||
|
|
||
| The `call_data` cell contains the payload that will be passed to the `onCall` | ||
| function of the universal app contract. | ||
|
|
||
| Here's an example of how to construct the deposit-and-call message in | ||
| TypeScript: | ||
|
|
||
| ```typescript | ||
| const opDepositAndCall = 102; | ||
| const body = beginCell() | ||
| .storeUint(opDepositAndCall, 32) | ||
| .storeUint(0, 64) | ||
| .storeUint(zevmRecipient, 160) | ||
| .storeRef(callDataCell) // callDataCell should be a cell containing the payload | ||
| .endCell(); | ||
| ``` | ||
|
|
||
| After the cross-chain transaction is processed, the `onCall` function of the | ||
| universal app contract is executed. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.