Core Concepts
Payment Handling
All dWallet protocol operations require fees paid in both IKA (protocol fees) and SUI (gas fees). This guide covers how to manage these payments in your Move contracts.
Fee Structure
| Operation | IKA Fee | SUI Fee |
|---|---|---|
| DKG (Create dWallet) | Protocol-defined | Gas costs |
| Presign | Protocol-defined | Gas costs |
| Sign | Protocol-defined | Gas costs |
| Future Sign | Protocol-defined | Gas costs |
Fee amounts are determined by the network and can be queried from the coordinator.
Balance Management Pattern
The recommended pattern is to:
- Store IKA and SUI balances in your contract
- Withdraw coins before operations
- Return unused coins after operations
Contract Structure
Funding Functions
Withdraw and Return Pattern
Using Payments in Operations
Here's the complete pattern for a protocol operation:
Complete Example
Here's a full contract with payment handling:
Querying Fee Amounts
You can query the current pricing from the coordinator:
From TypeScript:
Handling Insufficient Funds
Always check balances before operations or handle potential failures:
Auto-Replenishment Pattern
For contracts that need continuous operation, implement auto-replenishment:
Best Practices
- Always Return Unused Funds: Protocol operations only deduct what's needed
- Check Balances: Verify sufficient funds before operations
- Batch Operations: Multiple operations in one transaction share the withdraw/return pattern
- Monitor Balances: Emit events when balances are low
- Allow Refunding: Provide admin functions to withdraw excess balances if needed
Next Steps
- Continue to Protocols to learn about DKG, presigning, and signing