Signing Messages
import { useWallet } from '@aptos-labs/wallet-adapter-react'
const { signMessage } = useWallet()
const response = await signMessage({
message: 'Hello from your dApp',
nonce: Date.now().toString(),
address: true,
application: true,
chainId: true,
})Request parameters
| Param | Description |
|---|---|
message | Required. The content to sign. |
nonce | Required. A unique identifier generated by your dApp. |
address | Whether to include the account address. |
application | Whether to include the dApp domain. |
chainId | Whether to include the current chain ID. |
Response
signMessage resolves with a SignMessageResponse:
| Field | Description |
|---|---|
signature | Cryptographic signature over the full message. |
fullMessage | The complete signed message, formatted with an APTOS prefix and nonce. |
address, application, chainId, nonce | Echo of the request parameters that were included. |
Verification
Use signMessageAndVerify when you want signing and signature verification handled in a single call, instead of verifying the signature yourself. It resolves to a boolean — true if the signature is valid for the connected account.
const { signMessageAndVerify } = useWallet()
const isValid = await signMessageAndVerify({
message: 'Hello from your dApp',
nonce: Date.now().toString(),
})Related pages
Last updated on