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

# Raw Signing (EVM)

> [card] Recommended: JavaScript SDK with React Hooks
>
> For new React apps, we recommend the JavaScript SDK with React Hooks (`@dynamic-labs-sdk/react-hooks`) instead of the legacy React SDK documented here. The JS SDK comes with many benefits such as a much smaller bundle size and other optimizations. Use the [React quickstart (JavaScript SDK)](https://docs.dynamic.xyz/docs/javascript/reference/react-quickstart.md) to get started.

`signRawMessage` lets you sign a digest exactly as you supply it, with no prefixing or re-hashing by the SDK. Use it when you need full control over hashing and formatting: non-standard signing flows, or chain/app-specific message formats.

> [!NOTE]
>
> **`signRawMessage` is EVM-specific, and EVM is the only wallet that needs it.** On EVM, `signMessage` follows [ERC-191](https://eips.ethereum.org/EIPS/eip-191): it prefixes your input with `\x19Ethereum Signed Message:\n<length>` before hashing. `signRawMessage` exists to bypass that prefix.
>
> On Ed25519 chains there is no prefix to bypass: `signMessage` already produces a raw signature over the exact bytes you pass. To sign transaction digests for Solana, or for any chain derived from the Solana wallet, use [`signMessage`](https://docs.dynamic.xyz/docs/javascript/reference/wallets/sign-message) and see the [Tier 2 and 3 chains technical overview](https://docs.dynamic.xyz/docs/javascript/reference/tier-2-chains/overview.md).

> [!WARNING]
>
> Raw signing is denied on any wallet that carries policy rules. See [Raw signing](https://docs.dynamic.xyz/docs/embedded-wallets/mpc/policies/overview.md#raw-signing) in the policies overview for how policies interact with raw signing.

## Basic raw signing (hash then sign)

```typescript theme={"system"}
    import { keccak256, stringToHex } from 'viem';
    import { DynamicWaasEVMConnector } from '@dynamic-labs/sdk-react-core';

    const rawMessage = "Hello World";

    // primaryWallet should be an EVM embedded wallet
    const connector = primaryWallet.connector as DynamicWaasEVMConnector;

    // Dynamic expects the message as a hex string (no 0x) when signing a pre-hashed payload
    const hash = keccak256(stringToHex(rawMessage)).slice(2);

    const signature = await connector.signRawMessage({
      accountAddress: primaryWallet.address,
      message: hash,
    });

    console.log("Signature:", signature);
```

## Encoding options

Dynamic supports different encoding formats for your raw messages depending on what you need to hash/sign.

### Hexadecimal encoding

Most common for blockchain applications. The message is encoded as a hex string.

```typescript theme={"system"}
    import { stringToHex } from 'viem';

    const message = "Hello World";
    const hexEncoded = stringToHex(message);
    // Result: "0x48656c6c6f20576f726c64"
```

### UTF-8 text encoding

For plain text messages that don't require hex encoding.

```text theme={"system"}
Hello World
```

## Hash functions

Different hash functions serve different purposes in cryptographic signing.

### Keccak256 (Ethereum standard)

```typescript theme={"system"}
import { keccak256, stringToHex } from 'viem';

const message = "Hello World";
const hash = keccak256(stringToHex(message));
```

## Raw signing on non-EVM chains

Every Dynamic embedded wallet can sign arbitrary digests. Which method you call depends on whether the chain's default `signMessage` wraps your input:

| Curve family | Root wallet | Method | Why |
| - | - | - | - |
| secp256k1 | EVM | `signRawMessage` | `signMessage` adds the ERC-191 prefix, so a raw digest needs `signRawMessage` |
| Ed25519 | Solana | `signMessage` | Signs the exact bytes you pass: no prefix, so no separate raw API is needed |

Chains built on top of these wallets: Aptos, NEAR, Cardano and Mavryk from the Solana wallet; Cosmos, XRP and Tron from the EVM wallet: follow the same rule. See the [Tier 2 and 3 chains technical overview](https://docs.dynamic.xyz/docs/javascript/reference/tier-2-chains/overview.md) for the complete derive-and-sign pattern, and [Aptos](https://docs.dynamic.xyz/docs/javascript/reference/tier-2-chains/aptos.md) for a worked Ed25519 example.


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