# wallet_formatSign

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

POST https://api.g.alchemy.com/v2/{apiKey}

This method is used to format ECDSA signatures

Reference: https://www.alchemy.com/docs/wallets/api-reference/smart-wallets/wallet-api-endpoints/wallet-format-sign

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| params[0] | object | Yes |  |

## Result

**formatSignResponse** (object)

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "wallet_formatSign",
  "params": [
    {
      "from": "0xa363219d7C0b8673df17529D469Db9eFF0f35D2A",
      "chainId": "0x01",
      "signature": {
        "type": "ecdsa",
        "data": "0xb1a055089b1ba8387ed435f2bd0afe7ff69f22b928cdfdea1b5323c64d6af387164de3fa6febf031b544de46a84d6fb7f084b9798ddfaba820950c257139a7321b"
      }
    }
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "signature": "0xb1a055089b1ba8387ed435f2bd0afe7ff69f22b928cdfdea1b5323c64d6af387164de3fa6febf031b544de46a84d6fb7f084b9798ddfaba820950c257139a7321b"
  },
  "id": 1
}
```

## Code Examples

### cURL

```bash
curl --request POST \
  --url https://api.g.alchemy.com/v2/docs-demo \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "wallet_formatSign",
  "params": [
    {
      "from": "0xa363219d7C0b8673df17529D469Db9eFF0f35D2A",
      "chainId": "0x01",
      "signature": {
        "type": "ecdsa",
        "data": "0xb1a055089b1ba8387ed435f2bd0afe7ff69f22b928cdfdea1b5323c64d6af387164de3fa6febf031b544de46a84d6fb7f084b9798ddfaba820950c257139a7321b"
      }
    }
  ]
}'
```

### JavaScript

```javascript
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json'},
  body: JSON.stringify({
    jsonrpc: '2.0',
    id: 1,
    method: 'wallet_formatSign',
    params: [
      {
        from: '0xa363219d7C0b8673df17529D469Db9eFF0f35D2A',
        chainId: '0x01',
        signature: {
          type: 'ecdsa',
          data: '0xb1a055089b1ba8387ed435f2bd0afe7ff69f22b928cdfdea1b5323c64d6af387164de3fa6febf031b544de46a84d6fb7f084b9798ddfaba820950c257139a7321b'
        }
      }
    ]
  })
};

fetch('https://api.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://api.g.alchemy.com/v2/docs-demo"

payload = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "wallet_formatSign",
    "params": [
        {
            "from": "0xa363219d7C0b8673df17529D469Db9eFF0f35D2A",
            "chainId": "0x01",
            "signature": {
                "type": "ecdsa",
                "data": "0xb1a055089b1ba8387ed435f2bd0afe7ff69f22b928cdfdea1b5323c64d6af387164de3fa6febf031b544de46a84d6fb7f084b9798ddfaba820950c257139a7321b"
            }
        }
    ]
}
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://api.g.alchemy.com/v2/docs-demo"

	payload := strings.NewReader("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"wallet_formatSign\",\n  \"params\": [\n    {\n      \"from\": \"0xa363219d7C0b8673df17529D469Db9eFF0f35D2A\",\n      \"chainId\": \"0x01\",\n      \"signature\": {\n        \"type\": \"ecdsa\",\n        \"data\": \"0xb1a055089b1ba8387ed435f2bd0afe7ff69f22b928cdfdea1b5323c64d6af387164de3fa6febf031b544de46a84d6fb7f084b9798ddfaba820950c257139a7321b\"\n      }\n    }\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://api.g.alchemy.com/v2/docs-demo")
  .header("Content-Type", "application/json")
  .body("{\n  \"jsonrpc\": \"2.0\",\n  \"id\": 1,\n  \"method\": \"wallet_formatSign\",\n  \"params\": [\n    {\n      \"from\": \"0xa363219d7C0b8673df17529D469Db9eFF0f35D2A\",\n      \"chainId\": \"0x01\",\n      \"signature\": {\n        \"type\": \"ecdsa\",\n        \"data\": \"0xb1a055089b1ba8387ed435f2bd0afe7ff69f22b928cdfdea1b5323c64d6af387164de3fa6febf031b544de46a84d6fb7f084b9798ddfaba820950c257139a7321b\"\n      }\n    }\n  ]\n}")
  .asString();
```

### C#

```csharp
using RestSharp;


var options = new RestClientOptions("https://api.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\": \"wallet_formatSign\",\n  \"params\": [\n    {\n      \"from\": \"0xa363219d7C0b8673df17529D469Db9eFF0f35D2A\",\n      \"chainId\": \"0x01\",\n      \"signature\": {\n        \"type\": \"ecdsa\",\n        \"data\": \"0xb1a055089b1ba8387ed435f2bd0afe7ff69f22b928cdfdea1b5323c64d6af387164de3fa6febf031b544de46a84d6fb7f084b9798ddfaba820950c257139a7321b\"\n      }\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: wallet_formatSign
description: This method is used to format ECDSA signatures
params:
  - name: params[0]
    required: true
    schema:
      type: object
      required:
        - from
        - chainId
        - signature
      properties:
        from:
          type: string
          pattern: ^0x.*$
          errorMessage: Must be a valid Ethereum address starting with '0x' (e.g., '0xa363219d7C0b8673df17529D469Db9eFF0f35D2A')
        chainId:
          type: string
          pattern: ^0x.*$
          errorMessage: Must be a valid hex string starting with '0x'
        signature:
          anyOf:
            - type: object
              required:
                - type
                - data
              properties:
                type:
                  type: string
                  enum:
                    - secp256k1
                data:
                  anyOf:
                    - type: string
                      pattern: ^0x.*$
                      errorMessage: Must be a valid hex string starting with '0x'
                      description: Hex-encoded signature
                    - type: object
                      required:
                        - r
                        - s
                        - yParity
                      properties:
                        r:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                        s:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                        yParity:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                      description: r, s, yParity
                    - type: object
                      required:
                        - r
                        - s
                        - v
                      properties:
                        r:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                        s:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                        v:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                      description: r, s, v
              description: Secp256k1 signature
            - type: object
              required:
                - type
                - data
              properties:
                type:
                  type: string
                  enum:
                    - ecdsa
                data:
                  anyOf:
                    - type: string
                      pattern: ^0x.*$
                      errorMessage: Must be a valid hex string starting with '0x'
                      description: Hex-encoded signature
                    - type: object
                      required:
                        - r
                        - s
                        - yParity
                      properties:
                        r:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                        s:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                        yParity:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                      description: r, s, yParity
                    - type: object
                      required:
                        - r
                        - s
                        - v
                      properties:
                        r:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                        s:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                        v:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                      description: r, s, v
              description: ECDSA signature (alias for secp256k1)
        capabilities:
          type: object
          required:
            - permissions
          properties:
            permissions:
              anyOf:
                - type: object
                  required:
                    - context
                  properties:
                    context:
                      type: string
                      pattern: ^0x.*$
                      errorMessage: Must be a valid hex string starting with '0x'
                  description: Permissions context
                - type: object
                  required:
                    - sessionId
                    - signature
                  properties:
                    sessionId:
                      type: string
                      pattern: ^0x.*$
                      errorMessage: Must be a valid hex string starting with '0x'
                    signature:
                      type: string
                      pattern: ^0x.*$
                      errorMessage: Must be a valid hex string starting with '0x'
                  description: Remote permission
result:
  name: formatSignResponse
  schema:
    type: object
    required:
      - signature
    properties:
      signature:
        type: string
        pattern: ^0x.*$
        errorMessage: Must be a valid hex string starting with '0x'
examples:
  - name: wallet_formatSign example
    params:
      - name: param0
        value:
          from: '0xa363219d7C0b8673df17529D469Db9eFF0f35D2A'
          chainId: '0x01'
          signature:
            type: ecdsa
            data: '0xb1a055089b1ba8387ed435f2bd0afe7ff69f22b928cdfdea1b5323c64d6af387164de3fa6febf031b544de46a84d6fb7f084b9798ddfaba820950c257139a7321b'
    result:
      name: Response
      value:
        signature: '0xb1a055089b1ba8387ed435f2bd0afe7ff69f22b928cdfdea1b5323c64d6af387164de3fa6febf031b544de46a84d6fb7f084b9798ddfaba820950c257139a7321b'
```
