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

Method reference

Complete reference for @megaeth-labs/wallet-sdk — 19 methods covering connection, signing, transactions, contract calls, Smart Approvals, balances, and deposits. Zero framework dependencies; works in any browser environment.

The SDK embeds https://account.megaeth.com in a hidden iframe, communicates via Penpal, and exposes one object: mega.

npm install @megaeth-labs/wallet-sdk

Typical lifecycle: initialise → connect → [transfer / callContract / signMessage / grantPermissions / send / swap] → disconnect.

Setup & Connection

Method
Purpose

mega.initialise(config)

Create the wallet iframe and bridge, wait for ready.

mega.connect()

Prompt the user to authenticate; resolves with connection status.

mega.disconnect()

Terminate the active wallet session.

mega.status()

Read current connection state without prompting.

mega.open()

Show the wallet UI overlay without an explicit action.

Subscribe to connection state changes.

Transactions

Method
Purpose

mega.transfer(request)

Send native or ERC-20/721/1155 transfers.

Execute contract write functions, single or batch.

Read contract state.

Signing

Method
Purpose

mega.signMessage(message)

Sign an arbitrary text payload.

mega.signData(request)

Sign structured (EIP-712) data.

mega.authenticate()

Request a MOSS-issued JWT for backend session exchange.

Smart Approvals (Policy Engine)

Method
Purpose

Grant scoped delegated permissions for silent execution.

mega.revokePermissions()

Revoke all active delegated permissions.

Read active permission grants.

For the conceptual model, see Smart Approvals (Policy Engine).

Wallet

Method
Purpose

mega.deposit()

Open the built-in deposit/funding UI.

mega.balances(request)

Fetch wallet token balances.

mega.send(request)

Open the wallet-managed send flow.

mega.swap(request)

Open the wallet-managed swap flow.

Shared Types

Per-method response shapes (e.g., SignMessageResponse, OwnedTokenResponse, Permission) live on their respective method pages.

Cross-Cutting Guides

Last updated