Simulate a transaction
curl --request POST \
--url https://api.portalhq.io/api/v3/clients/me/simulate-transaction \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"data": "0xa9059cbb000000000000000000000000...",
"value": "0x0"
}
'import requests
url = "https://api.portalhq.io/api/v3/clients/me/simulate-transaction"
payload = {
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"data": "0xa9059cbb000000000000000000000000...",
"value": "0x0"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
to: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
data: '0xa9059cbb000000000000000000000000...',
value: '0x0'
})
};
fetch('https://api.portalhq.io/api/v3/clients/me/simulate-transaction', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.portalhq.io/api/v3/clients/me/simulate-transaction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'to' => '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
'data' => '0xa9059cbb000000000000000000000000...',
'value' => '0x0'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.portalhq.io/api/v3/clients/me/simulate-transaction"
payload := strings.NewReader("{\n \"to\": \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\n \"data\": \"0xa9059cbb000000000000000000000000...\",\n \"value\": \"0x0\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.portalhq.io/api/v3/clients/me/simulate-transaction")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"to\": \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\n \"data\": \"0xa9059cbb000000000000000000000000...\",\n \"value\": \"0x0\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.portalhq.io/api/v3/clients/me/simulate-transaction")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"to\": \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\n \"data\": \"0xa9059cbb000000000000000000000000...\",\n \"value\": \"0x0\"\n}"
response = http.request(request)
puts response.read_body{
"changes": [
{
"type": "transfer",
"from": "0x54968898742c08da211a1cd355447cd1f37f0649",
"to": "0xdFd8302f44727A6348F702fF7B594f127dE3A902",
"amount": "10000",
"token": "USDC"
}
],
"gasUsed": "65000"
}Deprecated
Simulate a transaction
deprecated
Simulates an EVM transaction and returns the expected state changes and gas usage. Only supports EIP-155 chains.
Deprecated: Use the evaluate-transaction endpoint instead.
POST
/
clients
/
me
/
simulate-transaction
Simulate a transaction
curl --request POST \
--url https://api.portalhq.io/api/v3/clients/me/simulate-transaction \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"data": "0xa9059cbb000000000000000000000000...",
"value": "0x0"
}
'import requests
url = "https://api.portalhq.io/api/v3/clients/me/simulate-transaction"
payload = {
"to": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
"data": "0xa9059cbb000000000000000000000000...",
"value": "0x0"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
to: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
data: '0xa9059cbb000000000000000000000000...',
value: '0x0'
})
};
fetch('https://api.portalhq.io/api/v3/clients/me/simulate-transaction', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.portalhq.io/api/v3/clients/me/simulate-transaction",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'to' => '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
'data' => '0xa9059cbb000000000000000000000000...',
'value' => '0x0'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.portalhq.io/api/v3/clients/me/simulate-transaction"
payload := strings.NewReader("{\n \"to\": \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\n \"data\": \"0xa9059cbb000000000000000000000000...\",\n \"value\": \"0x0\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.portalhq.io/api/v3/clients/me/simulate-transaction")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"to\": \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\n \"data\": \"0xa9059cbb000000000000000000000000...\",\n \"value\": \"0x0\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.portalhq.io/api/v3/clients/me/simulate-transaction")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"to\": \"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48\",\n \"data\": \"0xa9059cbb000000000000000000000000...\",\n \"value\": \"0x0\"\n}"
response = http.request(request)
puts response.read_body{
"changes": [
{
"type": "transfer",
"from": "0x54968898742c08da211a1cd355447cd1f37f0649",
"to": "0xdFd8302f44727A6348F702fF7B594f127dE3A902",
"amount": "10000",
"token": "USDC"
}
],
"gasUsed": "65000"
}Authorizations
Client API Key or Client Session Token (CST). Pass as a Bearer token in the Authorization header.
Query Parameters
Chain ID in CAIP-2 format (EIP-155 only). For example, eip155:1 for
Ethereum mainnet.
Body
application/json
The target contract or recipient address.
Encoded transaction data (hex string).
Value to send in wei (hex string).
Gas limit.
Gas price in wei.
Maximum fee per gas (EIP-1559).
Maximum priority fee per gas (EIP-1559).
Was this page helpful?
⌘I