React
- Introduction to the SDK
- Configuration
- Upgrade Guides
- SDK/User Loading States
- Providers and Connectors
- UI Components
- Hooks
- Events
- Handlers
- Objects
- Utilities
- Examples
Sign a message
In this example, we are creating a button to sign a message and log the signature to the console.
import { useDynamicContext } from '@dynamic-labs/sdk-react-core';
const SignMessageButton = () => {
const { primaryWallet } = useDynamicContext();
const signMessage = async () => {
if (!primaryWallet) return;
const signer = await primaryWallet.connector.getSigner();
if (!signer) return;
const signature = await signer.signMessage('example');
console.log('signature', signature);
};
return <button onClick={signMessage}>Sign message</button>;
};
Was this page helpful?