> For the complete documentation index, see [llms.txt](https://docs.megaeth.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.megaeth.com/moss-docs/methods/methods/sign-data.md).

# 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()`](/moss-docs/methods/methods/sign-message.md).

## 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:

```typescript
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

```typescript
type SignDataResponse = {
  status: 'success' | 'cancelled' | 'error';
  error?: string;
  signature?: string;
};
```

## 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](/moss-docs/wallet/server-verify.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.megaeth.com/moss-docs/methods/methods/sign-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
