# Sign EIP712 Txn

The "Sign EIP712 Transaction" functionality in the KrypC wallet-dev Service API allows users to securely sign transactions following the EthereumImprovement Proposal 712 (EIP-712) standard. This feature enhances transaction security and ensures compatibility with applications using EIP-712 for cryptographic signatures on the Ethereum blockchain.

## API Specification

## Sign EIP72 Txn API

<mark style="color:green;">`POST`</mark> `https://api.krypcore.com/api/v0/devWallet/signEIP712Tx`

To sign EIP72 Txn API under given instance.

#### Headers

| Name                                            | Type   | Description            |
| ----------------------------------------------- | ------ | ---------------------- |
| DappId<mark style="color:red;">\*</mark>        | String | DappId                 |
| Authorization<mark style="color:red;">\*</mark> | String | User Auth key obtained |
| ChainId                                         | String | ChainId                |
| SubscriptionId                                  | String | SubscriptionId         |

#### Request Body

| Name                                         | Type   | Description |
| -------------------------------------------- | ------ | ----------- |
| privateKey<mark style="color:red;">\*</mark> | String | Private key |
| data<mark style="color:red;">\*</mark>       | String | Data        |

{% tabs %}
{% tab title="200: OK SUCCESS" %}

```javascript
{
    "Data": "0x67d638cbbdfd0a0e8fe45789681c93c6dd6d44fa16907052d31acd41c6d3838e23de6a9c5d46e23d4c48a4fea53d902a57bcd802aa87b29308b002e46128833f1c",
    "Message": "Data signed successfully",
    "Status": "SUCCESS"
}
```

{% endtab %}

{% tab title="401: Unauthorized Failure in authentication" %}

```javascript
{
    "message": "Invalid API key in request"
}
```

{% endtab %}

{% tab title="500: Internal Server Error Key values should be given" %}

```json
{
    "message": "Internal Server Error"
}
```

{% endtab %}
{% endtabs %}

Take a look at how you might call this method using our official libraries, or via `curl`

{% tabs %}
{% tab title="curl" %}

```bash

curl --location 'https://api.krypcore.com/api/v0/devWallet/signEIP712Tx' \
--header 'DappId: **********' \
--header 'Authorization: **********' \
--header 'SubscriptionId: ********' \
--header 'ChainId: ********' \
--header 'Content-Type: application/json' \
--data '{
    "privateKey": "**********",
    "data":"{\"domain\":{\"chainId\":80001,\"name\":\"MinimalForwarder\",\"verifyingContract\":\"0xdB4dFB11b6B74487c744c251d01718fEEb19279a\",\"version\":\"0.0.1\"},\"message\":{\"data\":\"0x14f710fe\",\"from\":\"0x11266906F2Eb9422924F3471F159377E2ED7c44C\",\"gas\":84762,\"nonce\":1,\"to\":\"0x0E762313219aE4dD7C674367a39901Ac1c28Cef3\",\"value\":0},\"primaryType\":\"ForwardRequest\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"ForwardRequest\":[{\"name\":\"from\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"gas\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"data\",\"type\":\"bytes\"}]}}"
}'
```

{% endtab %}

{% tab title="Node.js (Fetch)" %}

```javascript

import requests
import json

url = "https://api.krypcore.com/api/v0/devWallet/signEIP712Tx"

payload = json.dumps({
  "privateKey": "**********",
  "data": "{\"domain\":{\"chainId\":80001,\"name\":\"MinimalForwarder\",\"verifyingContract\":\"0xdB4dFB11b6B74487c744c251d01718fEEb19279a\",\"version\":\"0.0.1\"},\"message\":{\"data\":\"0x14f710fe\",\"from\":\"0x11266906F2Eb9422924F3471F159377E2ED7c44C\",\"gas\":84762,\"nonce\":1,\"to\":\"0x0E762313219aE4dD7C674367a39901Ac1c28Cef3\",\"value\":0},\"primaryType\":\"ForwardRequest\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"ForwardRequest\":[{\"name\":\"from\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"gas\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"data\",\"type\":\"bytes\"}]}}"
})
headers = {
  'DappId': '**********',
  'Authorization': '**********',
  'SubscriptionId': '********',
  'ChainId': '********',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="Python " %}

```python

import requests
import json

url = "https://api.krypcore.com/api/v0/devWallet/signEIP712Tx"

payload = json.dumps({
  "privateKey": "0xcadaf8776c2cd050c3d964e9371106ce6031994f83153f36a961d897ffe6ead7",
  "data": "{\"domain\":{\"chainId\":80001,\"name\":\"MinimalForwarder\",\"verifyingContract\":\"0xdB4dFB11b6B74487c744c251d01718fEEb19279a\",\"version\":\"0.0.1\"},\"message\":{\"data\":\"0x14f710fe\",\"from\":\"0x11266906F2Eb9422924F3471F159377E2ED7c44C\",\"gas\":84762,\"nonce\":1,\"to\":\"0x0E762313219aE4dD7C674367a39901Ac1c28Cef3\",\"value\":0},\"primaryType\":\"ForwardRequest\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"ForwardRequest\":[{\"name\":\"from\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"gas\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"data\",\"type\":\"bytes\"}]}}"
})
headers = {
  'DappId': 'INS_DE_52_2023124',
  'Authorization': '7a31fef8-2f45-4c5f-8483-a0dcc38ce201',
  'SubscriptionId': '4526772010',
  'ChainId': '********',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="Golang" %}

```go

package main

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

func main() {

  url := "https://api.krypcore.com/api/v0/devWallet/signEIP712Tx"
  method := "POST"

  payload := strings.NewReader(`{
    "privateKey": "**********",
    "data":"{\"domain\":{\"chainId\":80001,\"name\":\"MinimalForwarder\",\"verifyingContract\":\"0xdB4dFB11b6B74487c744c251d01718fEEb19279a\",\"version\":\"0.0.1\"},\"message\":{\"data\":\"0x14f710fe\",\"from\":\"0x11266906F2Eb9422924F3471F159377E2ED7c44C\",\"gas\":84762,\"nonce\":1,\"to\":\"0x0E762313219aE4dD7C674367a39901Ac1c28Cef3\",\"value\":0},\"primaryType\":\"ForwardRequest\",\"types\":{\"EIP712Domain\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"version\",\"type\":\"string\"},{\"name\":\"chainId\",\"type\":\"uint256\"},{\"name\":\"verifyingContract\",\"type\":\"address\"}],\"ForwardRequest\":[{\"name\":\"from\",\"type\":\"address\"},{\"name\":\"to\",\"type\":\"address\"},{\"name\":\"value\",\"type\":\"uint256\"},{\"name\":\"gas\",\"type\":\"uint256\"},{\"name\":\"nonce\",\"type\":\"uint256\"},{\"name\":\"data\",\"type\":\"bytes\"}]}}"
}`)

  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("DappId", "**********")
  req.Header.Add("Authorization", "**********")
  req.Header.Add("SubscriptionId", "********")
  req.Header.Add("ChainId", "********")
  req.Header.Add("Content-Type", "application/json")

  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}
```

{% endtab %}
{% endtabs %}
