> For the complete documentation index, see [llms.txt](/llms.txt)

# Sign Personal Message

Sign an arbitrary message with the connected wallet



The `signPersonalMessage` action prompts the connected wallet to sign a personal message. This is
useful for authentication, proof of ownership, or other scenarios where you need cryptographic proof
that a user controls a specific account.

## Usage

```typescript
import { createDAppKit } from '@mysten/dapp-kit-core';

const dAppKit = createDAppKit({
	/* config */
});

const message = new TextEncoder().encode('Please sign this message');
const result = await dAppKit.signPersonalMessage({
	message,
});

console.log('Message bytes:', result.bytes);
console.log('Signature:', result.signature);
```

## Parameters

* **`message`** - `Uint8Array` - The message to sign as a byte array

## Return Value

Returns a `Promise` that resolves to an object containing:

* **`bytes`** - `string` - Base64 encoded message bytes
* **`signature`** - `string` - Base64 encoded signature

## Message Format

The message parameter must be a `Uint8Array`. Common patterns for creating byte arrays:

```typescript
const textMessage = new TextEncoder().encode('Hello, Sui!');
await dAppKit.signPersonalMessage({ message: textMessage });

const jsonMessage = new TextEncoder().encode(
	JSON.stringify({ action: 'sign', timestamp: Date.now() }),
);
await dAppKit.signPersonalMessage({ message: jsonMessage });
```

## Security Considerations

### Message Content

* Always display the message content clearly to users before signing
* Avoid signing opaque or encoded data that users cannot understand
* Include human-readable prefixes for different message types
* Consider adding timestamps to prevent replay attacks
