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

mega.signData()

Sign structured data through the wallet approval surface — typically EIP-712 typed payloads for permits, structured approvals, or attestations. For plain string signing use signMessage().

Signature

mega.signData(request: SignDataRequest): Promise<SignDataResponse>

Parameters

Field
Type
Required
Notes

data

any

required

Structured payload. For EIP-712, include domain, types, primaryType, and message.

Example

EIP-712 typed payload:

const typed = await mega.signData({
  data: {
    domain: {
      name: 'MyApp',
      version: '1',
      chainId: 4326,
      verifyingContract: '0xContractAddress',
    },
    primaryType: 'Permit',
    types: {
      Permit: [
        { name: 'owner', type: 'address' },
        { name: 'spender', type: 'address' },
        { name: 'value', type: 'uint256' },
      ],
    },
    message: {
      owner: '0xOwnerAddress',
      spender: '0xSpenderAddress',
      value: '1000000',
    },
  },
});

if (typed.status === 'success') {
  console.log(typed.signature);
}

Response

Notes

  • User rejection resolves with cancelled — treat as neutral.

  • Reconnect disconnected wallets before signing.

  • Verify signatures server-side before issuing app sessions — see Server Verify.

Last updated