For the complete documentation index, see llms.txt. This page is also available as Markdown.

Connection Lifecycle

The lifecycle methods control how your app checks wallet state, prompts the user, disconnects, or brings the wallet UI forward.

Status Shape

type ConnectionStatus = {
  status: 'connected' | 'disconnected' | 'cancelled';
  address?: `0x${string}`;
  network: 'mainnet' | 'testnet';
};

Status()

Read the current wallet connection state.

const status = await mega.status();

Use it after initialisation, on route transitions, or when restoring app state after a refresh.

Connect()

Prompt the user to connect MOSS and return the resulting connection state.

const result = await mega.connect();

if (result.status === 'connected') {
  console.log('Connected address:', result.address);
}

Disconnect()

Terminate the current wallet session and return the resulting disconnected state.

Open()

Bring the wallet UI forward without starting a specific signing or transaction flow.

This is useful when your product includes an explicit “Open wallet” affordance for account management or session inspection.

  1. Call initialise() once.

  2. Read status() to render initial UI.

  3. Trigger connect() from a deliberate user action.

  4. Subscribe to onStatusChange for session-driven UI updates.

  5. Use disconnect() only when the product clearly intends to terminate the session.

Treat cancelled as a normal user choice, not an error state. The cleanest partner integrations distinguish cancellation from transport or contract failures.

Last updated