Call Contract Method
This Call Contract Method using this method.
API Specification
Call Contract Method
POST http://localhost:8889/wallet/callContract
Call Contract Method under the given instance.
Headers
Name
Type
Description
ChainId*
String
ChainId
Request Body
Name
Type
Description
to*
String
The recipient's address
walletId*
String
The ID of the wallet
params*
String
Additional parameters for the transaction
method*
String
The method for the transaction
contractABI*
String
The Application Binary Interface (ABI) of the contract
{
  "Status": "SUCCESS",
  "Message": "",
  "Data": {
    "response": []
  }
}{
    "Status": "FAILURE",
    "Message": "error reading ABI : EOF",
    "Data": null
}Take a look at how you might call this method using our official libraries, or via curl:
curl -X POST http://localhost:8889/wallet/callContract \
-H "Content-Type: application/json" \
-H "ChainId: xxxx" \
-d '{
  "walletId": "effae2b6-3ee3-48cb-9528-87c29152c89e",
  "to": "0xc2de797fab7d2d2b26246e93fcf2cd5873a90b10",
  "method": "store",
  "params": [
    {
      "type": "uint256",
      "value": "35"
    }
  ],
  "contractABI": "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"store\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"retrieve\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]"
}'
const axios = require('axios');
const data = JSON.stringify({
  walletId: 'effae2b6-3ee3-48cb-9528-87c29152c89e',
  to: '0xc2de797fab7d2d2b26246e93fcf2cd5873a90b10',
  method: 'store',
  params: [{ type: 'uint256', value: '35' }],
  contractABI: '[{"inputs":[{"internalType":"uint256","name":"num","type":"uint256"}],"name":"store","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"retrieve","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}]'
});
const config = {
  method: 'post',
  url: 'http://localhost:8889/wallet/callContract',
  headers: {
    'Content-Type': 'application/json',
    'ChainId': 'xxxx',
  },
  data: data,
};
axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data));
  })
  .catch(function (error) {
    console.log(error);
  });
import requests
import json
url = 'http://localhost:8889/wallet/callContract'
headers = {
    'Content-Type': 'application/json',
    'ChainId': 'xxxx' \
}
data = {
    "walletId": "effae2b6-3ee3-48cb-9528-87c29152c89e",
    "to": "0xc2de797fab7d2d2b26246e93fcf2cd5873a90b10",
    "method": "store",
    "params": [{"type": "uint256", "value": "35"}],
    "contractABI": "[{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"num\",\"type\":\"uint256\"}],\"name\":\"store\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"retrieve\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]"
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())
package main
import (
  "fmt"
  "strings"
  "net/http"
  "io/ioutil"
)
func main() {
  url := "http://localhost:8889/wallet/callContract"
  method := "POST"
  payload := strings.NewReader(`{
  "walletId": "effae2b6-3ee3-48cb-9528-87c29152c89e",
  "to": "0xc2de797fab7d2d2b26246e93fcf2cd5873a90b10",
  "method": "store",
  "params": [
    {
      "type": "uint256",
      "value": "35"
    }
  ],
  "contractABI": "[]"
}`)
  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?