# Deploy Contract

This Deploys contract using this method.&#x20;

## API Specification

## Deploy Contract

<mark style="color:green;">`POST`</mark> `http://localhost:8889/wallet/deployContract`

Deploys the contract  under the given instance.&#x20;

**Headers**

<table><thead><tr><th>Name</th><th width="239">Type</th><th>Description</th></tr></thead><tbody><tr><td>ChainId*</td><td>String</td><td>ChainId</td></tr></tbody></table>

#### Request Body

<table><thead><tr><th>Name</th><th width="236">Type</th><th>Description</th></tr></thead><tbody><tr><td>byteCode<mark style="color:red;">*</mark></td><td>String</td><td>Bytecode of the Contract</td></tr><tr><td>abi<mark style="color:red;">*</mark></td><td>String</td><td>The Application Binary Interface (ABI) of the contract</td></tr><tr><td>params<mark style="color:red;">*</mark></td><td>String</td><td>Additional parameters for the transaction</td></tr><tr><td>walletId<mark style="color:red;">*</mark></td><td>String</td><td>The ID of the wallet</td></tr></tbody></table>

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

Here we need to compile a contract ( eg. via remix ide) which will give "bytecode" and "abi".

Here "abi" will be in json format which we need to convert to base64.

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

```bash
curl -X POST http://localhost:8889/wallet/deployContract \
-H "Content-Type: application/json" \
-H "ChainId: xxxx" \
-d '{
  "walletId": "xxxxxxxxxxx",
  "byteCode": "",
  "abi": "",
  "params": [],
  "chainId":"xxxx"
}'
```

{% endtab %}

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

```javascript
const axios = require('axios');

const apiUrl = 'http://localhost:8889/wallet/deployContract';
const headers = {
  'Content-Type': 'application/json',
  'ChainId': 'xxxx',
};

const requestData = {
  abi: 'Base64 of the abi',
  byteCode: 'byte code of the contract',
  walletId: 'xxxxxxxxxxxx',
  ChainId: 'xxxx',
  params: [],
};

axios.post(apiUrl, requestData, { headers })
  .then((response) => {
    console.log('Response:', response.data);
  })
  .catch((error) => {
    console.error('Error:', error);
  });

```

{% endtab %}

{% tab title="Python " %}

```python
import requests
import json

url = 'http://localhost:8889/wallet/deployContract'

headers = {
    'Content-Type': 'application/json',
    'ChainId': 'xxxx',
}

data = {
    "abi": "Base64 of the abi",
    "byteCode": "byte code of the contract",
    "walletId": "xxxxxxxxxxxx",
    "ChainId": "xxxx",
    "params": [],
}

try:
    response = requests.post(url, json=data, headers=headers)
    response.raise_for_status()  # Raise an exception for 4xx or 5xx status codes

    print('Response:', response.json())
except requests.exceptions.RequestException as error:
    print('Error:', error)

```

{% endtab %}

{% tab title="Golang" %}

```go
package main

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

func main() {

  url := "http://localhost:8889/wallet/deployContract"
  method := "POST"

  payload := strings.NewReader(`{
  "walletId": "xxxxxxxxxxx",
  "byteCode": "",
  "abi": "",
  "params": [],
  "chainId":"xxxx"
}`)

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

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Add("ChainId", "xxxxxx")
  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 %}


---

# 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://docs.krypcore.com/dev-docs/api-reference/core-service-apis/wallet-manager/self-managed-wallet/deploy-contract.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.
