Function Signature
Description
Signs a message on behalf of a user who has granted delegation permission. This function requires delegation credentials (wallet ID, wallet API key, and key share) that are provided to your webhook endpoint when a user approves delegation. The message is automatically formatted for EVM signing and returns a serialized ECDSA signature.Parameters
Required Parameters
client
(DelegatedEvmWalletClient
) - The delegated client instance created withcreateDelegatedEvmWalletClient()
walletId
(string
) - The wallet ID from the delegation webhookwalletApiKey
(string
) - The wallet-specific API key from the delegation webhookkeyShare
(ServerKeyShare
) - The server key share from the delegation webhookmessage
(string
) - The message to sign
Optional Parameters
context
(SignMessageContext
) - Additional context for the signing operation. Defaults to{ evmMessage: message }
onError
((error: Error) => void
) - Error callback function
Returns
Promise<string>
- A hex-encoded ECDSA signature
Example
Basic Message Signing
With Context
With Error Handling
Complete Example with Try-Catch
Type Definitions
Common Use Cases
Authentication
Proof of Ownership
Error Handling
The function throws an error if:- Any required parameter is missing or invalid
- The delegation credentials are expired or revoked
- The MPC signing operation fails
- Network communication with Dynamic services fails
Security Considerations
- Credential Validation: Always validate delegation credentials before using them
- Message Validation: Validate message content to prevent signing malicious data
- Credential Storage: Never log or expose wallet API keys or key shares
Related Functions
createDelegatedEvmWalletClient()
- Create the client for delegated operationsdelegatedSignTransaction()
- Sign transactions instead of messagesrevokeDelegation()
- Revoke delegation permissionsverifyMessageSignature()
- Verify message signatures- Delegated Access Guide - Complete guide on using delegated access