Best Practices
Patterns, pitfalls, and production-ready examples for building on MOSS.
UX Patterns
1. Initialise Early, Not on Click
// DO this — initialise when your app loads
// app.ts or main.ts
import { mega } from '@megaeth-labs/wallet-sdk';
await mega.initialise({ network: 'mainnet' });
// DON'T do this — initialise on button click
connectButton.onclick = async () => {
await mega.initialise({ network: 'mainnet' }); // Delay here
await mega.connect();
};2. Always Subscribe to Status Changes
3. Handle Every Transaction Result
4. Design Permissions Narrowly
5. Silent Mode Requires Granted Permissions
6. Next.js and SSR
Security Hardening
7. Sponsor Gas with a Paymaster
Mode
Who pays
Who controls logic
When to use
8. Server-Side Verification
Error
What it means
Action
Last updated