Skip to main content

Method Signature

align.blockchain.wallets.signMessage(
  wallet: Wallet,
  message: string
): Promise<string>

Parameters

wallet
Wallet
required
The wallet to sign with (must have private key)
message
string
required
The message to sign

Returns

Returns the signature as a hex string (e.g., "0x1234...").

Examples

import Align from "@tolbel/align";

const align = new Align({
  apiKey: process.env.ALIGN_API_KEY!,
  environment: "sandbox",
});

const wallet = await align.blockchain.wallets.create();

// Sign a simple message
const signature = await align.blockchain.wallets.signMessage(
  wallet,
  "Hello, World!"
);

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

Proof of Ownership

// Create a timestamped ownership proof
const message = `I own this address. Timestamp: ${Date.now()}`;
const signature = await align.blockchain.wallets.signMessage(wallet, message);

// Send to server for verification
await fetch("/api/verify", {
  method: "POST",
  body: JSON.stringify({
    address: wallet.address,
    message,
    signature,
  }),
});

Sign-In with Ethereum (SIWE)

const siweMessage = `example.com wants you to sign in with your Ethereum account:
${wallet.address}

Sign in to Example App

Nonce: ${nonce}`;

const signature = await align.blockchain.wallets.signMessage(
  wallet,
  siweMessage
);
Never sign messages from untrusted sources! Signatures can authorize actions - always review what you’re signing.