Transaction Relay (TX)
Read Contract and View Functions
For your convenience, we've added a simple way to invoke view functions on already deployed contracts. These functions will fail if they modify the blockchain in any way.
DO NOT use this API to:
- Modify state variables.
- Emit events.
- Deploy contracts.
- Send ether.
- Call any function which is not marked view or pure.
Read Contract View Function Example
const response = await fetch('https://api.utiliti.ai/transactions/read', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-key': '<YOUR_API_KEY_HERE>', //replace }, body: JSON.stringify({ chain_id: 5, params: { tokenId: 0, }, contract_address: '0x62d100283c2af67452e91cf4d5bad4f2cc9a5947', abi: '<YOUR_CONTRACT_ABI>', contract_function_name: 'ownerOf', }), })
SDK coming soon...
CURL *hnd = curl_easy_init(); curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST"); curl_easy_setopt(hnd, CURLOPT_URL, "https://api.utiliti.ai/transactions/read"); struct curl_slist *headers = NULL; headers = curl_slist_append(headers, "accept: application/json"); headers = curl_slist_append(headers, "content-type: application/json"); headers = curl_slist_append(headers, "X-API-key: <YOUR_API_KEY_HERE>"); curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\"chain_id\":5,\"params\":\"{tokenId: 0}\",\"contract_address\":\"0x62d100283c2af67452e91cf4d5bad4f2cc9a5947\",\"abi\":\"<YOUR_CONTRACT_ABI>\",\"contract_function_name\":\"ownerOf\"}"); CURLcode ret = curl_easy_perform(hnd);
curl --request POST \ --url https://api.utiliti.ai/transactions/read \ --header 'X-API-key: <YOUR_API_KEY_HERE>' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "chain_id": 5, "params": "{tokenId: 0}", "contract_address": "0x62d100283c2af67452e91cf4d5bad4f2cc9a5947", "abi": "<YOUR_CONTRACT_ABI>", "contract_function_name": "ownerOf" } '
$python -m pip install requests --- import requests url = "https://api.utiliti.ai/transactions/read" payload = { "chain_id": 5, "params": "{tokenId: 0}", "contract_address": "0x62d100283c2af67452e91cf4d5bad4f2cc9a5947", "abi": "<YOUR_CONTRACT_ABI>", "contract_function_name": "ownerOf" } headers = { "accept": "application/json", "content-type": "application/json", "X-API-key": "<YOUR_API_KEY_HERE>" } response = requests.post(url, json=payload, headers=headers) print(response.text)