Skip to main content
This method uses Ethereum’s personal_sign RPC method. If you are looking for a low-level raw signature over a input hash, see secp256k1_sign.
When using Privy’s server-side SDKs to sign messages, you can use the authorization context to automatically sign requests. Learn more about signing on the server.
Use the signMessage method exported from the useSignMessage hook to sign a message with an Ethereum embedded wallet.

Usage

Parameters

string
required
Message to be signed.
Object

Returns

string
The signature produced by the wallet.

Callbacks

Configure callbacks for Privy’s signMessage method on the useSignMessage hook:
As parameters to useSignMessage, you may include an onSuccess callback and/or an onError callback.While this component is mounted, any invocation of signMessage will trigger the onSuccess callback or onError callback on completion, depending on if the message was successfully signed or not.

onSuccess

If set, the onSuccess callback will execute after a user has successfully signed the message. Within this callback, you can access a signature parameter, which is the signature string value generated by the wallet to sign the message.

onError

If set, the onError callback will execute after a user attempts to sign a message and there is an error, or if the user exits the signature flow prematurely. Within this callback, you may access an error code with more information about the error.
Looking to send USDC or another ERC-20 token? See our Send USDC recipe.