Closed Alpha: TSS-MPC Embedded Wallets

Our TSS-MPC offering is currently in closed alpha - contact us for early access or to learn more. If you’re looking to start using Dynamic today, we recommend starting with our TEE wallets. When our TSS-MPC wallets are rolled out, you’ll have a clear upgrade path to transition your users to the new system.

Overview

Raw signing allows you to sign arbitrary data with your MPC wallet, giving you full control over the message format and hashing process. This is useful for custom signing scenarios, non-standard message formats, or when you need to implement chain-specific signing requirements.

Connector Types

Dynamic provides different connectors depending on the signing algorithm you need:

EVM Connector (ECDSA Signing)

Use the EVM connector for ECDSA-based signing, which is used by Ethereum, Bitcoin, and most other blockchains:

import { DynamicWaasEVMConnector } from '@dynamic-labs/sdk-react-core';

const connector = primaryWallet.connector as DynamicWaasEVMConnector;

SVM Connector (EdDSA Signing)

Use the SVM connector for EdDSA-based signing, which is used by Solana and other Ed25519-based chains:

import { DynamicWaasSVMConnector } from '@dynamic-labs/sdk-react-core';

const connector = primaryWallet.connector as DynamicWaasSVMConnector;

Basic Raw Signing

Here’s how to sign a raw message using Dynamic’s MPC wallets with the EVM connector:

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);

Encoding Options

Dynamic supports different encoding formats for your raw messages:

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.

const message = "Hello World";
// Use directly as string

Hash Functions

Different hash functions serve different purposes in cryptographic signing:

Keccak256 (Ethereum Standard)

Most commonly used for Ethereum and EVM-compatible chains:

import { keccak256, stringToHex } from 'viem';

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

SHA256

Standard cryptographic hash function:

import { createHash } from 'crypto';

const message = "Hello World";
const hash = createHash('sha256').update(message).digest('hex');

Advanced Examples

Custom Message Formatting

For chains with specific message formatting requirements:

// 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,
});

Binary Data Signing

For signing binary data or structured payloads:

// 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,
});