Signing Blockchain Messages

Developers can sign blockchain messages using their API keys and the wallets they have access to.

📘

This feature is only available for Solana and EVM based blockchains.

Endpoint

POST /api/v1-alpha1/wallets/<chain>:<address>/signMessage

Required Scope

wallets:messages.sign

📘

Alpha API

This API is in alpha. You'll need to contact us via support to get the scope added to your API key.

How to sign a message

🚧

Server Side APIs

All of our APIs should be run from a server and NOT in the browser. Using these APIs in the client exposes your client secret, which WILL result in unauthorized access to your project.

import fetch from 'node-fetch';

const projectId = "";    // your project id (found in API Keys section of dev console)
const clientSecret = ""; // your client secret (found in API Keys section of dev console)

const env = "staging";   // staging, www
const chain = "polygon"; // ethereum, polygon
const address = "_WALLET_ADDRESS_OWNED_BY_YOUR_PROJECT_"; // 0x1234...

const message = "Hello, world!";

fetch(`https://${env}.crossmint.com/api/v1-alpha1/wallets/${chain}:${address}/signMessage`, {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "x-project-id": projectId,
        "x-client-secret": clientSecret
    },
    body: JSON.stringify({ chain, address, message })
})
.then(response => response.json())
.then(data => console.log("Signed message:", data))
.catch(error => console.error("Error:", error));

Parameter Details

ParameterTypeDescription
chainstringThe blockchain network you're using (ethereum, polygon, or bsc). For Optimism or Arbitrum support, please reach out to us.
addressstringThe wallet address you want to sign the message with. This MUST be a wallet owned by your project.
messagestringThe message to be signed.

Response

On successful execution, the API will return a JSON object with the signedMessage property.

Example Response:

{ 
  "signedMessage": "0x7b226d657373616765223a202268656c6c6f2c20776f726c6421222c20227369676e6174757265223a2022307837316237386537333732333430303132303930653130313562323439373335333339656135303737323438333333613833653635373831326438653534373639373333333334227d"
}

Error Handling

The following errors may be returned by the API:

  • BadRequestException (400 error): If the requested blockchain is not supported.
  • NotFoundException (404 error): If the specified wallet address is not found.
  • ForbiddenException (401 error): If the project does not have access to the requested wallet.