Deploy Contract
This Deploys contract using this method.
API Specification
Deploy Contract
POST http://localhost:8889/wallet/deployContract
Deploys the contract under the given instance.
Headers
Name
Type
Description
ChainId*
String
ChainId
Request Body
Name
Type
Description
byteCode*
String
Bytecode of the Contract
abi*
String
The Application Binary Interface (ABI) of the contract
params*
String
Additional parameters for the transaction
walletId*
String
The ID of the wallet
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.
curl -X POST http://localhost:8889/wallet/deployContract \
-H "Content-Type: application/json" \
-H "ChainId: xxxx" \
-d '{
  "walletId": "xxxxxxxxxxx",
  "byteCode": "",
  "abi": "",
  "params": [],
  "chainId":"xxxx"
}'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);
  });
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)
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))
}Last updated
Was this helpful?