⚙️
Comet SDK Docs
  • Welcome to the Comet SDK!
  • Getting Started
  • Project Guides
    • Launch and mint your first NFT collection
  • Reference
    • Comet SDK Reference
      • Comet REST API
        • Collections
        • Airdrops
        • Gallery
        • Usage
      • Comet React SDK
        • Getting started
        • Components
        • Hooks
          • useAccount
          • useMint
          • useSignMessage
          • useSignTransaction
          • useGetSharedSecret
Powered by GitBook
On this page
  • API
  • Example
  1. Reference
  2. Comet SDK Reference
  3. Comet React SDK
  4. Hooks

useSignMessage

Sign any message with your customers' Comet wallet.

PrevioususeMintNextuseSignTransaction

Last updated 2 years ago

Since Comet accounts come with a built-in cloud wallet, you can use this wallet to cryptographically sign messages on behalf of the user using the useSignMessage hook. The user will be prompted to log in if necessary, and will be asked to confirm the message to be signed (similar to the flow for Metamask or Phantom wallets).

API

const { signMessage } = useSignMessage({ message: '<MESSAGE>' });

signMessage is a function that can be called later on, which will bring up the confirmation dialog. It returns a successful Promise containing the signed message, or a failed Promise if the user clicks "Cancel".

Example

App.js
import { useSignMessage } from '@comet-labs/react';

function App() {
  const { signMessage } = useSignMessage({ message: 'gm world' });

  return (
    <div className="App">
      <button onClick={signMessage}>
        click here to sign message
      </button>
    </div>
  );
}