Embedded Wallets (MPC)
Raw Signing
Was this page helpful?
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
🚀 Stablecoin Accounts are live! Learn more
import { DynamicWaasEVMConnector } from '@dynamic-labs/sdk-react-core';
const connector = primaryWallet.connector as DynamicWaasEVMConnector;
import { keccak256, stringToHex } from 'viem';
import { DynamicWaasEVMConnector } from '@dynamic-labs/sdk-react-core';
const rawMessage = "Hello World";
const connector = primaryWallet.connector as DynamicWaasEVMConnector;
const hash = keccak256(stringToHex(rawMessage)).slice(2);
const signature = await connector.signRawMessage({
accountAddress: primaryWallet.address,
message: hash,
});
console.log("Signature:", signature);
import { stringToHex } from 'viem';
const message = "Hello World";
const hexEncoded = stringToHex(message);
// Result: "0x48656c6c6f20576f726c64"
const message = "Hello World";
// Use directly as string
import { keccak256, stringToHex } from 'viem';
const message = "Hello World";
const hash = keccak256(stringToHex(message));
import { createHash } from 'crypto';
const message = "Hello World";
const hash = createHash('sha256').update(message).digest('hex');
// Example: Custom prefix for a specific blockchain
const customPrefix = "\x19MyChain Signed Message:\n";
const message = "Hello World";
const formattedMessage = customPrefix + message.length + message;
const hash = keccak256(stringToHex(formattedMessage)).slice(2);
const signature = await connector.signRawMessage({
accountAddress: primaryWallet.address,
message: hash,
});
// Example: Signing a binary payload
const binaryData = new Uint8Array([0x01, 0x02, 0x03, 0x04]);
const hexData = Array.from(binaryData)
.map(b => b.toString(16).padStart(2, '0'))
.join('');
const signature = await connector.signRawMessage({
accountAddress: primaryWallet.address,
message: hexData,
});
Was this page helpful?