# verifymessage

> For the complete documentation index, see [llms.txt](/docs/llms.txt).

POST https://bitcoin-mainnet.g.alchemy.com/v2/{apiKey}

Verifies a message signature using the corresponding Bitcoin address. Returns true if the signature is valid and matches the given address.


Reference: https://www.alchemy.com/docs/chains/bitcoin/bitcoin-api-endpoints/verifymessage

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| address | string | Yes | The Bitcoin address to use for the signature. |
| signature | string | Yes | The base64-encoded signature provided by the signer. |
| message | string | Yes | The message that was signed. |

## Result

**result** (boolean): Whether the signature is valid for the message and address.

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "verifymessage",
  "params": [
    "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY",
    "G9oR+mz9QwPZq2boSmjdtbX0VNdD+dLOFRzJ93ZDHNwhnOtJb1EDAKCK3NmPIzctQDAazX9gh3d+zdoFKc69bQ4=",
    "Test message from Bitcoin"
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": true,
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "verifymessage",
  "params": [
    "1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY",
    "G9oR+mz9QwPZq2boSmjdtbX0VNdD+dLOFRzJ93ZDHNwhnOtJb1EDAKCK3NmPIzctQDAazX9gh3d+zdoFKc69bQ4=",
    "Test message from Bitcoin"
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'verifymessage',
    params: [
      '1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY',
      'G9oR+mz9QwPZq2boSmjdtbX0VNdD+dLOFRzJ93ZDHNwhnOtJb1EDAKCK3NmPIzctQDAazX9gh3d+zdoFKc69bQ4=',
      'Test message from Bitcoin'
    ]
  })
};

fetch('https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "verifymessage",
    "params": ["1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY", "G9oR+mz9QwPZq2boSmjdtbX0VNdD+dLOFRzJ93ZDHNwhnOtJb1EDAKCK3NmPIzctQDAazX9gh3d+zdoFKc69bQ4=", "Test message from Bitcoin"]
}
headers = {"Content-Type": "application/json"}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

### Go

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"verifymessage\",\n  \"params\": [\n    \"1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY\",\n    \"G9oR+mz9QwPZq2boSmjdtbX0VNdD+dLOFRzJ93ZDHNwhnOtJb1EDAKCK3NmPIzctQDAazX9gh3d+zdoFKc69bQ4=\",\n    \"Test message from Bitcoin\"\n  ]\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
```

### Java

```java
HttpResponse<String> response = Unirest.post("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"verifymessage\",\n  \"params\": [\n    \"1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY\",\n    \"G9oR+mz9QwPZq2boSmjdtbX0VNdD+dLOFRzJ93ZDHNwhnOtJb1EDAKCK3NmPIzctQDAazX9gh3d+zdoFKc69bQ4=\",\n    \"Test message from Bitcoin\"\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://bitcoin-mainnet.g.alchemy.com/v2/docs-demo");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"verifymessage\",\n  \"params\": [\n    \"1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY\",\n    \"G9oR+mz9QwPZq2boSmjdtbX0VNdD+dLOFRzJ93ZDHNwhnOtJb1EDAKCK3NmPIzctQDAazX9gh3d+zdoFKc69bQ4=\",\n    \"Test message from Bitcoin\"\n  ]\n}", false);
var response = await client.PostAsync(request);

Console.WriteLine("{0}", response.Content);

```


## OpenRPC Method Specification

```yaml
name: verifymessage
summary: Verify a signed message
description: |
  Verifies a message signature using the corresponding Bitcoin address. Returns true if the signature is valid and matches the given address.
params:
  - name: address
    required: true
    description: The Bitcoin address to use for the signature.
    schema:
      title: Bitcoin Address
      type: string
      pattern: ^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$
      description: A valid Bitcoin address.
  - name: signature
    required: true
    description: The base64-encoded signature provided by the signer.
    schema:
      title: Base64-encoded Signature
      type: string
      description: A cryptographic signature encoded in Base64.
  - name: message
    required: true
    description: The message that was signed.
    schema:
      type: string
result:
  name: result
  description: Whether the signature is valid for the message and address.
  schema:
    type: boolean
examples:
  - name: verifymessage example
    params:
      - name: address
        value: 1KFHE7w8BhaENAswwryaoccDb6qcT6DbYY
      - name: signature
        value: G9oR+mz9QwPZq2boSmjdtbX0VNdD+dLOFRzJ93ZDHNwhnOtJb1EDAKCK3NmPIzctQDAazX9gh3d+zdoFKc69bQ4=
      - name: message
        value: Test message from Bitcoin
    result:
      name: result
      value: true
```
