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
1 change: 0 additions & 1 deletion next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
/// <reference types="next/navigation-types/compat/navigation" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
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 SOL from Solana"
"description": "Make calls to universal apps and deposit tokens from Solana"
},
"sui": {
"title": "Sui",
"description": "Make calls to universal apps and deposit tokens from Sui"
},
"bitcoin": {
"title": "Bitcoin",
Expand Down
96 changes: 96 additions & 0 deletions src/pages/developers/chains/sui.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Sui Gateway

To interact with universal applications from Sui chain, use the Sui Gateway.

For step-by-step examples of using the Sui gateway, see the [Sui
tutorial](/developers/tutorials/sui/).

The Sui Gateway supports:

- Depositing native SUI and other coins to a universal app or an account on
ZetaChain
- Depositing coins and calling a universal app

## Deposit Coins

To deposit coins to an EOA or a universal contract on ZetaChain, use the
`deposit` function:

```move
public entry fun deposit<T>(
gateway: &mut Gateway,
coins: Coin<T>,
receiver: String,
ctx: &mut TxContext,
)
```

The `deposit` function accepts any whitelisted coin type `T` (including native
SUI), which will be sent to the specified `receiver` on ZetaChain.

The `receiver` parameter should be a valid EVM-style address (0x-prefixed hex
string) representing either an externally-owned account (EOA) or a universal app
address on ZetaChain. Even if the receiver is a universal app contract, the
`deposit` function will not trigger a contract call. If you want to deposit and
call a universal app, use the `deposit_and_call` function instead.

After the deposit is processed, the receiver receives the ZRC-20 version of the
deposited token on ZetaChain.

## Deposit Coins and Call a Universal App

To deposit coins and call a universal app contract, use the `deposit_and_call`
function:

```move
public entry fun deposit_and_call<T>(
gateway: &mut Gateway,
coins: Coin<T>,
receiver: String,
payload: vector<u8>,
ctx: &mut TxContext,
)
```

The `receiver` must be the address of a universal app contract on ZetaChain. The
`payload` parameter will be passed to the `onCall` function of the universal app
contract.

The maximum payload size is 1024 bytes. The transaction will fail if the payload
exceeds this limit.

## Administrative Functions

The Sui Gateway includes several administrative functions that require special
capability objects:

- `whitelist<T>` - Enables deposits for a new coin type (requires
`WhitelistCap`)
- `withdraw<T>` - Called by the TSS address when tokens are withdrawn from
ZetaChain to Sui. This function requires a special capability object
(`WithdrawCap`) that is only held by the TSS nodes. The `nonce` parameter
prevents replay attacks by ensuring each withdrawal is processed exactly once.
- `unwhitelist<T>` - Disables deposits for a coin type (requires `AdminCap`)
- `pause` - Temporarily disables all deposits (requires `AdminCap`)
- `unpause` - Re-enables deposits (requires `AdminCap`)
- `issue_withdraw_and_whitelist_cap` - Rotates the TSS capabilities (requires
`AdminCap`)

## Events

The Gateway emits several events that can be monitored:

- `DepositEvent` - Emitted when coins are deposited
- `DepositAndCallEvent` - Emitted when coins are deposited with a contract call
- `WithdrawEvent` - Emitted when coins are withdrawn
- `NonceIncreaseEvent` - Emitted when the withdrawal nonce is increased

## View Functions

The Gateway provides several read-only functions:

- `nonce()` - Returns the current withdrawal nonce
- `vault_balance<T>()` - Returns the balance of a specific coin type in the
gateway
- `is_whitelisted<T>()` - Checks if a coin type is enabled for deposits
- `is_paused()` - Checks if deposits are currently paused