Overview

Message signing allows you to apply a unique cryptographic signature to messages, ensuring authenticity and integrity. This is particularly useful for verifying ownership of accounts or authorizing actions without sending a transaction. Using the CDP-SDK, developers can sign messages for Solana. In this guide, you will learn how to:
  • Sign a message using the CDP v2 Wallet API

Prerequisites

It is assumed you have already completed the Quickstart guide.

Sign message

Input a message to sign. The CDP v2 Wallet API will return a signature that can be used to verify the message.
import { CdpClient } from "@coinbase/cdp-sdk";
import "dotenv/config";

const cdp = new CdpClient();

const account = await cdp.solana.getOrCreateAccount({ name: "MyAccount" });
const { signature } = await account.signMessage({
  message: "Hello, world!",
});

console.log(
  `Signed message: ${signature}`
);