The Sui implementation of the Relay Depository provides secure deposit and transfer functionality for Sui Coins using Move's strong type system, dynamic fields, and Ed25519 signature verification. It maintains consistent cross-chain behavior while leveraging Sui's unique object-centric model.
Source Code: /packages/sui-vm
- Escrow: Main shared object storing coins of different types
- AllocatorCap: Capability object for administrative functions
- ExecutedRequests: Tracks executed withdrawals for replay protection
- Dynamic Fields: Type-indexed storage for different coin balances
init: Creates and shares the Escrow and ExecutedRequests objectsset_allocator: Updates the authorized allocator address and public key (requires AllocatorCap)
deposit<T>(coin, id): Generic deposit function for any Sui coin typedeposit_coin<T>(coin, id): Entry wrapper for depositing coins
execute_transfer<T>(request_params, signature): Execute allocator-signed transfers
TransferRequest Structure:
public struct TransferRequest has copy, drop {
recipient: address, // Destination address
amount: u64, // Amount to transfer
coin_type: TypeName, // Type of coin to transfer
nonce: u64, // Unique nonce
expiration: u64 // Expiration timestamp
}- Validates allocator signatures using Sui's Ed25519 verification module
- Signature covers the hash of the serialized transfer request
- Prevents signature reuse through request tracking
- Replay Protection: Request hashes stored in ExecutedRequests object
- Time-based Expiration: Transfers expire after specified timestamp
- Object Ownership: Shared objects control access to funds
DepositEvent:
public struct DepositEvent has copy, drop {
coin_type: TypeName,
amount: u64,
from: address,
deposit_id: vector<u8>,
}TransferExecutedEvent:
public struct TransferExecutedEvent has copy, drop {
request_hash: vector<u8>,
recipient: address,
amount: u64,
coin_type: TypeName,
}AllocatorChangedEvent:
public struct AllocatorChangedEvent has copy, drop {
old_allocator: address,
new_allocator: address
}get_allocator: Returns current allocator address and public keyget_balance<T>: Returns balance of specific coin typecheck_request_executed: Checks if a request has been executed
- Native SUI coin
- Any custom coin type