> ## Documentation Index
> Fetch the complete documentation index at: https://docs.portalhq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# signMessage

> Sign a personal message using personal_sign.

## Function Signature

```dart theme={null}
Future<String> signMessage({
  required String chainId,
  required String message,
})
```

## Description

Signs a personal message using the `personal_sign` RPC method, which prepends the standard Ethereum message prefix (`"\x19Ethereum Signed Message:\n" + len(message)`) before signing.

For signing EIP-712 typed structured data, see [`signTypedData`](./signtypeddata) instead.

## Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `chainId` | `String` | Yes | The chain ID in CAIP-2 format (e.g., `eip155:1`). |
| `message` | `String` | Yes | The message to sign (plain text or hex). |

## Returns

**`String`** — The signature as a hex string.

## Example

```dart theme={null}
import 'package:portal_flutter/portal_flutter.dart';

final portal = Portal();

final signature = await portal.signMessage(
  chainId: 'eip155:1',
  message: 'Hello, Portal!',
);

print('Signature: $signature');
```

## Errors

Throws a `PortalException` on failure:

| Code | Description |
| - | - |
| `NOT_INITIALIZED` | Portal was not initialized. |
| `SIGN_MESSAGE_ERROR` | The signing operation failed. |

```dart theme={null}
try {
  final signature = await portal.signMessage(
    chainId: 'eip155:1',
    message: 'Hello, Portal!',
  );
} on PortalException catch (e) {
  print('Failed to sign message: ${e.code} - ${e.message}');
}
```

## Related

* [signTypedData](./signtypeddata) — sign EIP-712 typed structured data
* [rawSign](./rawsign)
* [request](./request)
* [Sign a transaction guide](../guide/sign-a-transaction)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.