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)
React
React Native
Flutter
Swift
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);
Raw signing is not currently exposed as a first-class API in React Native. If you only need standard message signing, use the chain-specific signing methods for your wallet.
Raw signing is not currently exposed as a first-class API in Flutter. If you only need standard message signing, use the chain-specific signing methods for your wallet.
Raw signing is not currently exposed as a first-class API in Swift. If you only need standard message signing, use the chain-specific signing methods for your wallet.
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"
import Foundation
let message = "Hello World"
let data = Data(message.utf8)
let hexEncoded = "0x" + data.map { String(format: "%02x", $0) }.joined()
// Result: 0x48656c6c6f20576f726c64
UTF-8 text encoding
For plain text messages that don’t require hex encoding.
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));