Skip to content
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
6 changes: 5 additions & 1 deletion src/pages/developers/chains/_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
},
"solana": {
"title": "Solana",
"description": "Make calls to universal apps and deposit tokens from Solana"
"description": "Make calls to universal apps and deposit from Solana"
},
"ton": {
"title": "Ton",
"description": "Make calls to universal apps and deposit from TON"
},
"sui": {
"title": "Sui",
Expand Down
8 changes: 4 additions & 4 deletions src/pages/developers/chains/evm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,10 @@ universal contract and passes the `payload` as the `message` parameter.

The `call` function doesn't support revert handling. If
`revertOptions.callOnRevert` is set to `true`, the transaction will fail. This
is because executing a contract call on revert requires tokens to cover gas
fees on ZetaChain, and the `call` function doesn't transfer any assets. If you
need to handle reverts, use `depositAndCall` instead and ensure sufficient
tokens are deposited to cover potential gas fees.
is because executing a contract call on revert requires tokens to cover gas fees
on ZetaChain, and the `call` function doesn't transfer any assets. If you need
to handle reverts, use `depositAndCall` instead and ensure sufficient tokens are
deposited to cover potential gas fees.

## Revert Transactions

Expand Down
68 changes: 68 additions & 0 deletions src/pages/developers/chains/ton.mdx
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

## 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.