Skip to main content

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) to get started.
Raw signing lets you sign arbitrary data with an embedded MPC wallet when you need full control over hashing and formatting. This is most useful for non-standard signing flows or chain/app-specific message formats.
Raw signing is currently only available for EVM embedded wallets.

Basic raw signing (hash then sign)

    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.
    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.
Hello World

Hash functions

Different hash functions serve different purposes in cryptographic signing.

Keccak256 (Ethereum standard)

import { keccak256, stringToHex } from 'viem';

const message = "Hello World";
const hash = keccak256(stringToHex(message));
Last modified on June 25, 2026