Transaction Relay (TX)
Create Blockchain Transactions
Transfer native currency (ETH, MATIC), call contract functions, and deploy contracts.
Sending transactions is available via HTTP API. Tx Relay can handle all types of transactions such as contract deployment, contract functions, and transferring ether.
Creating transactions transfer event
Make a POST request to /transactions in order to send native currency (ETH, MATIC). The request will return the transaction id which may be used to query its status.
const response = await fetch('https://api.utiliti.ai/transactions', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-key': '<YOUR_API_KEY_HERE>', }, body: JSON.stringify({ chain_id: 80001, // Polygon Mumbai type: 'TRANSFER', from_address: '0xC96524bbeB102d9246ED6a4A07909c7f1Dd2AF8e', to_address: '0x5ee648Bc911676ad1fC500e36F138DeE967D1FEC', params: { value: 1, // transfer amount }, gas_limit: 21000, gas_strategy: 'FAST', // "SLOW" | "MEDIUM" | "FAST" }), })
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"); 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\":80001,\"type\":\"TRANSFER\",\"from_address\":\"0xC96524bbeB102d9246ED6a4A07909c7f1Dd2AF8e\",\"to_address\":\"0x5ee648Bc911676ad1fC500e36F138DeE967D1FEC\",\"params\":\"{value: 1}\",\"gas_limit\":21000,\"gas_strategy\":\"FAST\"}"); CURLcode ret = curl_easy_perform(hnd);
curl --request POST \ --url https://api.utiliti.ai/transactions \ --header 'X-API-key: <YOUR_API_KEY_HERE>' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data ' { "chain_id": 80001, "type": "TRANSFER", "from_address": "0xC96524bbeB102d9246ED6a4A07909c7f1Dd2AF8e", "to_address": "0x5ee648Bc911676ad1fC500e36F138DeE967D1FEC", "params": "{value: 1}", "gas_limit": 21000, "gas_strategy": "FAST" } '
$python -m pip install requests --- import requests url = "https://api.utiliti.ai/transactions" payload = { "chain_id": 80001, "type": "TRANSFER", "from_address": "0xC96524bbeB102d9246ED6a4A07909c7f1Dd2AF8e", "to_address": "0x5ee648Bc911676ad1fC500e36F138DeE967D1FEC", "params": "{value: 1}", "gas_limit": 21000, "gas_strategy": "FAST" } 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)
Calling contract functions
Making a function call to a contract is simple.
Make a POST request to /transactions for calling contract functions. The query will return the transaction id which may be used to query its status.
const response = await fetch('https://api.utiliti.ai/transactions', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-key': '<YOUR_API_KEY_HERE>', }, body: JSON.stringify({ chain_id: 80001, // Polygon Mumbai from_address: '0xC96524bbeB102d9246ED6a4A07909c7f1Dd2AF8e', to_address: '0xb7ed1cd744352047dde87cc2ffb1e486ba8780f9', type: 'CONTRACT_FUNCTION', contract_function_name: 'approve', params: { spender: '0xfaFF85CAe0C8E460B1103D393D42e74bf099F775', amount: 1, }, abi: '<CONTRACT_ABI>', gas_limit: 200000, gas_strategy: 'FAST', // "SLOW" | "MEDIUM" | "FAST" }), })
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"); 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\":80001,\"type\":\"CONTRACT_FUNCTION\",\"from_address\":\"0xC96524bbeB102d9246ED6a4A07909c7f1Dd2AF8e\",\"to_address\":\"0x5ee648Bc911676ad1fC500e36F138DeE967D1FEC\",\"params\":\"{spender: '0xfaFF85CAe0C8E460B1103D393D42e74bf099F775',amount: 1}\",\"gas_limit\":21000,\"gas_strategy\":\"FAST\",\"contract_function_name\":\"approve\",\"abi\":\"<CONTRACT_ABI>\"}"); CURLcode ret = curl_easy_perform(hnd);
curl --request POST \ --url https://api.utiliti.ai/transactions \ --header 'X-API-key: <YOUR_API_KEY_HERE>' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data @- <<EOF { "chain_id": 80001, "type": "CONTRACT_FUNCTION", "from_address": "0xC96524bbeB102d9246ED6a4A07909c7f1Dd2AF8e", "to_address": "0x5ee648Bc911676ad1fC500e36F138DeE967D1FEC", "params": "{spender: '0xfaFF85CAe0C8E460B1103D393D42e74bf099F775',amount: 1}", "gas_limit": 21000, "gas_strategy": "FAST", "contract_function_name": "approve", "abi": "<CONTRACT_ABI>" } EOF
$python -m pip install requests --- import requests url = "https://api.utiliti.ai/transactions" payload = { "chain_id": 80001, "type": "CONTRACT_FUNCTION", "from_address": "0xC96524bbeB102d9246ED6a4A07909c7f1Dd2AF8e", "to_address": "0x5ee648Bc911676ad1fC500e36F138DeE967D1FEC", "params": "{spender: '0xfaFF85CAe0C8E460B1103D393D42e74bf099F775',amount: 1}", "gas_limit": 21000, "gas_strategy": "FAST", "contract_function_name": "approve", "abi": "<CONTRACT_ABI>" } 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)
Mint an NFT from Identity wallet example
const response = await fetch('https://api.utiliti.ai/transactions', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-key': '<YOUR_API_KEY_HERE>', }, body: JSON.stringify({ chain_id: 5, // Ethereum Goerli type: 'CONTRACT_FUNCTION', from_address: '0x23c96144969a9d7c802a96cbf0d539210d176b38', // Identity Wallet Address to_address: '0x62d100283c2af67452e91cf4d5bad4f2cc9a5947', // NFT Contract Address params: { // Contract Parameters to: '0x57a3cdee5886f8f0508f6c0e77c8ec4e74b0238a', tokenId: 7, }, contract_function_name: 'safeMint', // Name of contract function to invoke abi: '<CONTRACT_ABI>', gas_limit: 200000, gas_strategy: 'FAST', }), })
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"); 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,\"type\":\"CONTRACT_FUNCTION\",\"from_address\":\"0x23c96144969a9d7c802a96cbf0d539210d176b38\",\"to_address\":\"0x62d100283c2af67452e91cf4d5bad4f2cc9a5947\",\"params\":\"{to: '0x57a3cdee5886f8f0508f6c0e77c8ec4e74b0238a',tokenId: 7}\",\"gas_limit\":21000,\"gas_strategy\":\"FAST\",\"contract_function_name\":\"safeMint\",\"abi\":\"<CONTRACT_ABI>\"}"); CURLcode ret = curl_easy_perform(hnd);
curl --request POST \ --url https://api.utiliti.ai/transactions \ --header 'X-API-key: <YOUR_API_KEY_HERE>' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data @- <<EOF { "chain_id": 5, "type": "CONTRACT_FUNCTION", "from_address": "0x23c96144969a9d7c802a96cbf0d539210d176b38", "to_address": "0x62d100283c2af67452e91cf4d5bad4f2cc9a5947", "params": "{to: '0x57a3cdee5886f8f0508f6c0e77c8ec4e74b0238a',tokenId: 7}", "gas_limit": 21000, "gas_strategy": "FAST", "contract_function_name": "safeMint", "abi": "<CONTRACT_ABI>" } EOF
$python -m pip install requests --- import requests url = "https://api.utiliti.ai/transactions" payload = { "chain_id": 5, "type": "CONTRACT_FUNCTION", "from_address": "0x23c96144969a9d7c802a96cbf0d539210d176b38", "to_address": "0x62d100283c2af67452e91cf4d5bad4f2cc9a5947", "params": "{to: '0x57a3cdee5886f8f0508f6c0e77c8ec4e74b0238a',tokenId: 7}", "gas_limit": 21000, "gas_strategy": "FAST", "contract_function_name": "safeMint", "abi": "<CONTRACT_ABI>" } headers = { "accept": "application/json", "content-type": "application/json", "X-API-key": "<YOUR_API_KEY_HERE>" }
Deploy Smart Contracts (Beta)
Your Identity Wallet can be used to deploy and verify smart contracts. Currently, imports are only supported for some OpenZeppelin contracts.
const response = await fetch('https://api.utiliti.ai/transactions', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-API-key': '<YOUR_API_KEY_HERE>', }, body: JSON.stringify({ chain_id: 5, // Ethereum Goerli type: 'CONTRACT_DEPLOY', from_address: '0x23c96144969a9d7c802a96cbf0d539210d176b38', // Identity Wallet Address params: { // Contract Parameters name: 'UtilitiDemo', }, contract: '<CONTRACT_SOURCE_CODE>', gas_limit: 200000, gas_strategy: 'FAST', }), })
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"); 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,\"type\":\"CONTRACT_FUNCTION\",\"from_address\":\"0x23c96144969a9d7c802a96cbf0d539210d176b38\",\"to_address\":\"0x62d100283c2af67452e91cf4d5bad4f2cc9a5947\",\"params\":\"{to: '0x57a3cdee5886f8f0508f6c0e77c8ec4e74b0238a',tokenId: 7}\",\"gas_limit\":21000,\"gas_strategy\":\"FAST\",\"contract_function_name\":\"safeMint\",\"abi\":\"<CONTRACT_ABI>\"}"); CURLcode ret = curl_easy_perform(hnd);
curl --request POST \ --url https://api.utiliti.ai/transactions \ --header 'X-API-key: <YOUR_API_KEY_HERE>' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data @- <<EOF { "chain_id": 5, "type": "CONTRACT_FUNCTION", "from_address": "0x23c96144969a9d7c802a96cbf0d539210d176b38", "to_address": "0x62d100283c2af67452e91cf4d5bad4f2cc9a5947", "params": "{to: '0x57a3cdee5886f8f0508f6c0e77c8ec4e74b0238a',tokenId: 7}", "gas_limit": 21000, "gas_strategy": "FAST", "contract_function_name": "safeMint", "abi": "<CONTRACT_ABI>" } EOF
$python -m pip install requests --- import requests url = "https://api.utiliti.ai/transactions" payload = { "chain_id": 5, "type": "CONTRACT_FUNCTION", "from_address": "0x23c96144969a9d7c802a96cbf0d539210d176b38", "to_address": "0x62d100283c2af67452e91cf4d5bad4f2cc9a5947", "params": "{to: '0x57a3cdee5886f8f0508f6c0e77c8ec4e74b0238a',tokenId: 7}", "gas_limit": 21000, "gas_strategy": "FAST", "contract_function_name": "safeMint", "abi": "<CONTRACT_ABI>" } 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)