# wallet_prepareSign

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

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

This method is used to translate raw data into a signature request

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

## Parameters

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

## Result

**prepareSignResponse** (object)

## Example

### Request

```json
{
  "jsonrpc": "2.0",
  "method": "wallet_prepareSign",
  "params": [
    {
      "from": "0xa363219d7C0b8673df17529D469Db9eFF0f35D2A",
      "chainId": "0x01",
      "signatureRequest": {
        "type": "personal_sign",
        "data": {
          "raw": "0x48656c6c6f20576f726c6421"
        }
      }
    }
  ],
  "id": 1
}
```

### Response

```json
{
  "jsonrpc": "2.0",
  "result": {
    "chainId": "0x66eee",
    "signatureRequest": {
      "type": "eth_signTypedData_v4",
      "data": {
        "domain": {
          "chainId": 421614,
          "verifyingContract": "0xafdABa1E09e82F780721963eba39bA9e6d9FE4d2"
        },
        "types": {
          "ReplaySafeHash": [
            {
              "name": "hash",
              "type": "bytes32"
            }
          ]
        },
        "primaryType": "ReplaySafeHash",
        "message": {
          "hash": "0xec3608877ecbf8084c29896b7eab2a368b2b3c8d003288584d145613dfa4706c"
        }
      }
    }
  },
  "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_prepareSign",
  "params": [
    {
      "from": "0xa363219d7C0b8673df17529D469Db9eFF0f35D2A",
      "chainId": "0x01",
      "signatureRequest": {
        "type": "personal_sign",
        "data": {
          "raw": "0x48656c6c6f20576f726c6421"
        }
      }
    }
  ]
}'
```

### JavaScript

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

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_prepareSign",
    "params": [
        {
            "from": "0xa363219d7C0b8673df17529D469Db9eFF0f35D2A",
            "chainId": "0x01",
            "signatureRequest": {
                "type": "personal_sign",
                "data": { "raw": "0x48656c6c6f20576f726c6421" }
            }
        }
    ]
}
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_prepareSign\",\n  \"params\": [\n    {\n      \"from\": \"0xa363219d7C0b8673df17529D469Db9eFF0f35D2A\",\n      \"chainId\": \"0x01\",\n      \"signatureRequest\": {\n        \"type\": \"personal_sign\",\n        \"data\": {\n          \"raw\": \"0x48656c6c6f20576f726c6421\"\n        }\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_prepareSign\",\n  \"params\": [\n    {\n      \"from\": \"0xa363219d7C0b8673df17529D469Db9eFF0f35D2A\",\n      \"chainId\": \"0x01\",\n      \"signatureRequest\": {\n        \"type\": \"personal_sign\",\n        \"data\": {\n          \"raw\": \"0x48656c6c6f20576f726c6421\"\n        }\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_prepareSign\",\n  \"params\": [\n    {\n      \"from\": \"0xa363219d7C0b8673df17529D469Db9eFF0f35D2A\",\n      \"chainId\": \"0x01\",\n      \"signatureRequest\": {\n        \"type\": \"personal_sign\",\n        \"data\": {\n          \"raw\": \"0x48656c6c6f20576f726c6421\"\n        }\n      }\n    }\n  ]\n}", false);
var response = await client.PostAsync(request);

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

```


## OpenRPC Method Specification

```yaml
name: wallet_prepareSign
description: This method is used to translate raw data into a signature request
params:
  - name: params[0]
    required: true
    schema:
      type: object
      required:
        - from
        - chainId
        - signatureRequest
      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'
        signatureRequest:
          anyOf:
            - type: object
              required:
                - type
                - data
              properties:
                type:
                  type: string
                  enum:
                    - personal_sign
                data:
                  anyOf:
                    - type: string
                      minLength: 1
                      description: Message
                    - type: object
                      required:
                        - raw
                      properties:
                        raw:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                      description: Raw message
              description: SignableMessage for personal_sign
            - type: object
              required:
                - type
                - data
              properties:
                type:
                  type: string
                  enum:
                    - eth_signTypedData_v4
                data:
                  type: object
                  required:
                    - types
                    - primaryType
                    - message
                  properties:
                    domain:
                      type: object
                      properties:
                        chainId:
                          type: integer
                        name:
                          type: string
                        salt:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid hex string starting with '0x'
                        verifyingContract:
                          type: string
                          pattern: ^0x.*$
                          errorMessage: Must be a valid Ethereum address starting with '0x' (e.g., '0xa363219d7C0b8673df17529D469Db9eFF0f35D2A')
                        version:
                          type: string
                    types:
                      type: object
                      description: Mapping from type name to array of field definitions
                      additionalProperties:
                        type: array
                        items:
                          type: object
                          required:
                            - name
                            - type
                          properties:
                            name:
                              type: string
                            type:
                              type: string
                    primaryType:
                      type: string
                    message:
                      type: object
                      description: Mapping from field name to value
              description: TypedDataDefinition for eth_signTypedData_v4
        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: prepareSignResponse
  schema:
    type: object
    required:
      - chainId
      - signatureRequest
    properties:
      chainId:
        type: string
        pattern: ^0x.*$
        errorMessage: Must be a valid hex string starting with '0x'
      signatureRequest:
        anyOf:
          - type: object
            required:
              - type
              - data
            properties:
              type:
                type: string
                enum:
                  - personal_sign
              data:
                anyOf:
                  - type: string
                    minLength: 1
                    description: Message
                  - type: object
                    required:
                      - raw
                    properties:
                      raw:
                        type: string
                        pattern: ^0x.*$
                        errorMessage: Must be a valid hex string starting with '0x'
                    description: Raw message
            description: SignableMessage for personal_sign
          - type: object
            required:
              - type
              - data
            properties:
              type:
                type: string
                enum:
                  - eth_signTypedData_v4
              data:
                type: object
                required:
                  - types
                  - primaryType
                  - message
                properties:
                  domain:
                    type: object
                    properties:
                      chainId:
                        type: integer
                      name:
                        type: string
                      salt:
                        type: string
                        pattern: ^0x.*$
                        errorMessage: Must be a valid hex string starting with '0x'
                      verifyingContract:
                        type: string
                        pattern: ^0x.*$
                        errorMessage: Must be a valid Ethereum address starting with '0x' (e.g., '0xa363219d7C0b8673df17529D469Db9eFF0f35D2A')
                      version:
                        type: string
                  types:
                    type: object
                    description: Mapping from type name to array of field definitions
                    additionalProperties:
                      type: array
                      items:
                        type: object
                        required:
                          - name
                          - type
                        properties:
                          name:
                            type: string
                          type:
                            type: string
                  primaryType:
                    type: string
                  message:
                    type: object
                    description: Mapping from field name to value
            description: TypedDataDefinition for eth_signTypedData_v4
examples:
  - name: wallet_prepareSign example
    params:
      - name: param0
        value:
          from: '0xa363219d7C0b8673df17529D469Db9eFF0f35D2A'
          chainId: '0x01'
          signatureRequest:
            type: personal_sign
            data:
              raw: '0x48656c6c6f20576f726c6421'
    result:
      name: Response
      value:
        chainId: '0x66eee'
        signatureRequest:
          type: eth_signTypedData_v4
          data:
            domain:
              chainId: 421614
              verifyingContract: '0xafdABa1E09e82F780721963eba39bA9e6d9FE4d2'
            types:
              ReplaySafeHash:
                - name: hash
                  type: bytes32
            primaryType: ReplaySafeHash
            message:
              hash: '0xec3608877ecbf8084c29896b7eab2a368b2b3c8d003288584d145613dfa4706c'
```
