# signMessage

## Method name

`signMessage`

## Parameters

<table><thead><tr><th width="188">Parameter</th><th width="376">Description</th><th width="101" data-type="checkbox">Required</th><th width="83">Type</th></tr></thead><tbody><tr><td>message</td><td>Arbitrary message for signing</td><td>true</td><td>string</td></tr><tr><td>paymentType</td><td>Address type to use. <code>p2wpkh</code> for Native Segwit (default) or <code>p2tr</code> for Taproot.</td><td>false</td><td>string</td></tr><tr><td>network</td><td>Network for signing: <code>mainnet</code> (default), <code>testnet</code>, <code>signet</code>, <code>sbtcDevenv</code> or <code>devnet</code></td><td>false</td><td>string</td></tr><tr><td>account</td><td>Index of account for signing (defaults to active account)</td><td>false</td><td>uint</td></tr></tbody></table>

## Example request

```typescript
import { Verifier } from "bip322-js";

try {
  // Request signature
  const response = await window.LeatherProvider.request("signMessage", {
    message: "Hello world",
    paymentType: "p2tr",
    network: "testnet",
    account: 0
  });

  console.log("Response:", response);

  // Verify signature
  try {
    const isValid = Verifier.verifySignature(
      response.result.address,
      response.result.message,
      response.result.signature
    );

    console.log("Signature is valid: ", isValid);
  } catch (error) {
    console.log("Verification error:", error);
  }
} catch (error) {
  console.log("Request error:", error.error.code, error.error.message);
}
```

## Example response

```json5
{
    "jsonrpc": "2.0",
    "id": "adc296e9-beb7-4685-a443-24c30d0d04dd",
    "result": {
        "signature": "AUDl4ZQJo585ldL0I9S+CjDpT7+5WB2Sspgh47Dsx0WX0iZSCLV+K6smOKJ1u4IUaN6grvNspaZ9GpqPOOHsTTVE",
        "address": "tb1pwfstsmedjfr84rzjsnsjly7x0utzlcfed0uqv26vmwsrvvzuf82qsad4uz",
        "message": "Hello world"
    }
}
```

## Sandbox

[Install the Leather extension](https://leather.io/install-extension) then try out this method below:

{% embed url="<https://codesandbox.io/embed/79qdnk?expanddevtools=1&hidenavigation=1&module=/src/index.ts&view=preview>" %}

## Preview

<figure><img src="https://2085786563-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F41U87FfDFo2dIKYr0ZNX%2Fuploads%2FnRyxaZourhSxmCYr03cP%2FSCR-20240419-mgkw.png?alt=media&#x26;token=5a217ec0-4783-4f2b-8464-89e643fba2ea" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://leather.gitbook.io/developers/bitcoin-methods/signmessage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
