Call Contract
The "Call Contract" functionality in the KrypC wallet-dev Service API allows users to interact with and execute specific functions within a deployed smart contract on the blockchain, enabling seamless integration and communication with decentralised applications.
This Call Contract Method using this method.
API Specification
Call Contract
POST
https://api.krypcore.com/api/v0/devWallet/callContract
Calls Contract under the given instance.
Headers
Request Body
{
"Data": {
"response": [
35
]
},
"Message": "",
"Status": "SUCCESS"
}
{
"Data": null,
"Message": "error calling contract : no contract code at given address",
"Status": "FAILURE"
}
{
"message": "Invalid API key in request"
}
Take a look at how you might call this method using our official libraries, or via curl
curl --location 'https://api.krypcore.com/api/v0/devWallet/callContract' \
--header 'DappId: **********' \
--header 'Authorization: **********' \
--header 'SubscriptionId: ********' \
--header 'ChainId: ********' \
--header 'Content-Type: application/json' \
--data '{
"to": "*********",
"chainId": 80001,
"method": "retrieve",
"params": [],
"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\"}]"
}'
var myHeaders = new Headers();
myHeaders.append("DappId", "**********");
myHeaders.append("Authorization", "**********");
myHeaders.append("SubscriptionId", "********");
myHeaders.append("ChainId", "********");
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"to": "*********",
"chainId": 80001,
"method": "retrieve",
"params": [],
"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\"}]"
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://api.krypcore.com/api/v0/devWallet/callContract", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
import requests
import json
url = "https://api.krypcore.com/api/v0/devWallet/callContract"
payload = json.dumps({
"to": "*********",
"chainId": 80001,
"method": "retrieve",
"params": [],
"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\"}]"
})
headers = {
'DappId': '**********',
'Authorization': '**********',
'SubscriptionId': '********',
'ChainId': '********',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.krypcore.com/api/v0/devWallet/callContract"
method := "POST"
payload := strings.NewReader(`{
"to": "*********",
"chainId": 80001,
"method": "retrieve",
"params": [],
"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\"}]"
}`)
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))
}
Last updated