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

MOSS Authentication

Use MOSS auth when you want wallet-backed login UX without implementing a direct SIWE prompt flow in your app UI.

Core SDK Flow

import { mega } from '@megaeth-labs/wallet-sdk';

await mega.initialise({ network: 'mainnet' });

const auth = await mega.authenticate();

if (auth.status === 'success' && auth.jwt) {
  await fetch('/api/auth/moss', {
    method: 'POST',
    headers: { 'content-type': 'application/json' },
    body: JSON.stringify({ jwt: auth.jwt }),
  });
}

React SDK Flow

function AuthButton() {
  const authenticate = useAuthenticate();

  return (
    <button
      onClick={() =>
        authenticate.mutate(undefined, {
          onSuccess: async (result) => {
            if (result.status === 'success' && result.jwt) {
              await fetch('/api/auth/moss', {
                method: 'POST',
                headers: { 'content-type': 'application/json' },
                body: JSON.stringify({ jwt: result.jwt }),
              });
            }
          },
        })
      }
    >
      Authenticate with MOSS
    </button>
  );
}

Response Contract

  • success + jwt: send to backend verification/session exchange.

  • cancelled: user dismissed auth flow; show neutral retry UX.

  • error: operational failure; log and show retry guidance.

Backend Verification

Verify the returned JWT server-side before issuing an app session.

Example verification request:

If your auth stack uses Privy, map this into your backend auth exchange layer:

Coming Soon

Social login flows (Google, Apple, email) are on the roadmap but not yet shipped. This page will update with API contracts when they release.

  • mega.authenticate() — full method signature and response contract.

  • Server Verify — explicit message-signature verification when you need it instead of JWT auth.

Last updated