Skip to content
Docs

Client: signing

Sign a message

Sign login or auth messages for an explicit chain or family.

Overview

Signs an arbitrary message for a specific chain or family. Not tied to activeChain—always pass chainOrFamily explicitly. Watch-only wallets cannot sign.

Signature

js
await account.signMessage(message, chainOrFamily, options?)

Parameters

FieldRequiredDescription
messageYes`string` — message to sign.
chainOrFamilyYes`GrayChainId | ChainFamily` — e.g. `"ethereum"` or `"evm"`.
options.recipientNo`string` — NEAR (NEP-413) only, and required there: the app or recipient identifier.
options.nonceNo`Uint8Array` — NEAR only: 32-byte nonce. Random when omitted; returned in the result.
options.callbackUrlNo`string` — NEAR only: optional NEP-413 callback URL.
options.cosmosChainIdNo`string` — Cosmos (ADR-036) only: chain ID in the sign document. Defaults to an empty string.

Response

Promise<SignMessageResult>

ts
{
  signature: string;   // encoding depends on the standard
  address: string;     // signer address
  standard: MessageSignStandard;
  publicKey?: string;  // Cosmos and NEAR, where verifiers need the key
  nonce?: string;      // NEAR only: base64 nonce that was signed
}

The standard field tells verifiers how the message was signed:

FieldRequiredDescription
eip191NoEVM personal_sign.
tip191NoTron signed message.
adr036NoCosmos ADR-036 sign document.
bip137NoBitcoin-style signed message on UTXO chains that define one.
nep413NoNEAR NEP-413 (requires options.recipient).
algorand-mxNoAlgorand MX-prefixed message.
sui-personal-messageNoSui personal message.
solana-rawNoEd25519 signature over the raw message bytes.
sep53NoStellar SEP-53 message.
kaspaNoKaspa message signing (Node.js only).

Usage

js
const a = wallet.account(0);
const { signature, address, standard } = await a.signMessage(
  "Login to Acme",
  "ethereum",
);
// standard === "eip191"

const near = await a.signMessage("Login to Acme", "near", { recipient: "acme.near" });
// near.standard === "nep413"; near.publicKey and near.nonce are set

Throws

FieldRequiredDescription
unsupported_capabilityNoWatch-only account, a family without a message-signing standard, or Kaspa outside Node.js.
invalid_argumentNoUnknown chain/family for this account.
unauthorizedNoSecrets unavailable (locked storage / watch).