|
| 1 | +To interact with universal applications from TON, use the TON gateway. |
| 2 | + |
| 3 | +TON gateway supports: |
| 4 | + |
| 5 | +- Depositing TON to a universal app or an account on ZetaChain |
| 6 | +- Depositing TON and calling a universal app |
| 7 | +- Withdrawing TON from ZetaChain |
| 8 | + |
| 9 | +## Deposit TON |
| 10 | + |
| 11 | +To deposit TON to an EOA or a universal contract, send an internal message to |
| 12 | +the Gateway contract with the following structure: |
| 13 | + |
| 14 | +```fc |
| 15 | +;; Message body structure |
| 16 | +;; op_code: 32 bits |
| 17 | +;; query_id: 64 bits |
| 18 | +;; evm_recipient: 160 bits (20 bytes) |
| 19 | +``` |
| 20 | + |
| 21 | +The `op_code` should be set to `101` for deposits. |
| 22 | + |
| 23 | +The `evm_recipient` specifies the address on ZetaChain that will receive the |
| 24 | +deposited TON. This can be either an externally-owned account (EOA) or a |
| 25 | +universal app address. |
| 26 | + |
| 27 | +After the deposit is processed, the receiver receives the [ZRC-20 |
| 28 | +version](/developers/tokens/zrc20) of the deposited TON. |
| 29 | + |
| 30 | +## Deposit TON and Call a Universal App |
| 31 | + |
| 32 | +To deposit TON and call a universal app contract, send an internal message to |
| 33 | +the Gateway contract with the following structure: |
| 34 | + |
| 35 | +```fc |
| 36 | +;; Message body structure |
| 37 | +;; op_code: 32 bits |
| 38 | +;; query_id: 64 bits |
| 39 | +;; evm_recipient: 160 bits (20 bytes) |
| 40 | +;; call_data: cell (up to 2KB) |
| 41 | +``` |
| 42 | + |
| 43 | +The `op_code` should be set to `102` for deposit and call operations. |
| 44 | + |
| 45 | +The `evm_recipient` must be the address of a universal app contract. |
| 46 | + |
| 47 | +The `call_data` cell contains the payload that will be passed to the `onCall` |
| 48 | +function of the universal app contract. |
| 49 | + |
| 50 | +After the cross-chain transaction is processed, the `onCall` function of the |
| 51 | +universal app contract is executed. |
| 52 | + |
| 53 | +## Gas Fees |
| 54 | + |
| 55 | +The Gateway contract charges gas fees for different operations: |
| 56 | + |
| 57 | +- Deposit: 10,000 gas units |
| 58 | +- Deposit and Call: 13,000 gas units |
| 59 | +- Authority operations: 20,000 gas units |
| 60 | +- Withdraw: 17,500 gas units |
| 61 | + |
| 62 | +These fees are deducted from the deposited or withdrawn amount to cover the cost |
| 63 | +of processing the transaction on ZetaChain. |
0 commit comments