Encode state overrides
curl --request POST \
--url https://api.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states \
--header 'Content-Type: application/json' \
--header 'X-Access-Key: <api-key>' \
--data '
{
"networkID": "1",
"stateOverrides": {
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
"value": {
"balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]": "1000"
}
}
},
"blockNumber": "-1"
}
'import requests
url = "https://api.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states"
payload = {
"networkID": "1",
"stateOverrides": { "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": { "value": { "balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]": "1000" } } },
"blockNumber": "-1"
}
headers = {
"X-Access-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Access-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
networkID: '1',
stateOverrides: {
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': {
value: {
'balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]': '1000'
}
}
},
blockNumber: '-1'
})
};
fetch('https://api.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states', 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.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states",
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([
'networkID' => '1',
'stateOverrides' => [
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' => [
'value' => [
'balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]' => '1000'
]
]
],
'blockNumber' => '-1'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Access-Key: <api-key>"
],
]);
$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.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states"
payload := strings.NewReader("{\n \"networkID\": \"1\",\n \"stateOverrides\": {\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\": {\n \"value\": {\n \"balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]\": \"1000\"\n }\n }\n },\n \"blockNumber\": \"-1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Access-Key", "<api-key>")
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.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states")
.header("X-Access-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"networkID\": \"1\",\n \"stateOverrides\": {\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\": {\n \"value\": {\n \"balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]\": \"1000\"\n }\n }\n },\n \"blockNumber\": \"-1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Access-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"networkID\": \"1\",\n \"stateOverrides\": {\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\": {\n \"value\": {\n \"balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]\": \"1000\"\n }\n }\n },\n \"blockNumber\": \"-1\"\n}"
response = http.request(request)
puts response.read_body{}{
"error": {
"id": "596b1dc7-af60-477b-aab3-6c93eb92ddfa",
"slug": "bad_request",
"message": "Bad request input parameters"
}
}{
"error": {
"id": "596b1dc7-af60-477b-aab3-6c93eb92ddfa",
"slug": "unauthorized",
"message": "Unauthorized"
}
}{
"error": {
"id": "596b1dc7-af60-477b-aab3-6c93eb92ddfa",
"slug": "insufficient_permissions",
"message": "Insufficient permissions"
}
}{
"error": {
"id": "596b1dc7-af60-477b-aab3-6c93eb92ddfa",
"slug": "resource_not_found",
"message": "The resource you requested could not be found."
}
}{
"error": {
"id": "596b1dc7-af60-477b-aab3-6c93eb92ddfa",
"slug": "internal_server_error",
"message": "Internal server error"
}
}Contracts
Encode state overrides
Encode state overrides of the smart contract.
POST
/
v1
/
account
/
{accountSlug}
/
project
/
{projectSlug}
/
contracts
/
encode-states
Encode state overrides
curl --request POST \
--url https://api.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states \
--header 'Content-Type: application/json' \
--header 'X-Access-Key: <api-key>' \
--data '
{
"networkID": "1",
"stateOverrides": {
"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": {
"value": {
"balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]": "1000"
}
}
},
"blockNumber": "-1"
}
'import requests
url = "https://api.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states"
payload = {
"networkID": "1",
"stateOverrides": { "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": { "value": { "balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]": "1000" } } },
"blockNumber": "-1"
}
headers = {
"X-Access-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-Access-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
networkID: '1',
stateOverrides: {
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48': {
value: {
'balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]': '1000'
}
}
},
blockNumber: '-1'
})
};
fetch('https://api.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states', 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.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states",
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([
'networkID' => '1',
'stateOverrides' => [
'0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48' => [
'value' => [
'balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]' => '1000'
]
]
],
'blockNumber' => '-1'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Access-Key: <api-key>"
],
]);
$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.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states"
payload := strings.NewReader("{\n \"networkID\": \"1\",\n \"stateOverrides\": {\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\": {\n \"value\": {\n \"balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]\": \"1000\"\n }\n }\n },\n \"blockNumber\": \"-1\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-Access-Key", "<api-key>")
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.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states")
.header("X-Access-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"networkID\": \"1\",\n \"stateOverrides\": {\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\": {\n \"value\": {\n \"balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]\": \"1000\"\n }\n }\n },\n \"blockNumber\": \"-1\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tenderly.co/api/v1/account/{accountSlug}/project/{projectSlug}/contracts/encode-states")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-Access-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"networkID\": \"1\",\n \"stateOverrides\": {\n \"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\": {\n \"value\": {\n \"balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]\": \"1000\"\n }\n }\n },\n \"blockNumber\": \"-1\"\n}"
response = http.request(request)
puts response.read_body{}{
"error": {
"id": "596b1dc7-af60-477b-aab3-6c93eb92ddfa",
"slug": "bad_request",
"message": "Bad request input parameters"
}
}{
"error": {
"id": "596b1dc7-af60-477b-aab3-6c93eb92ddfa",
"slug": "unauthorized",
"message": "Unauthorized"
}
}{
"error": {
"id": "596b1dc7-af60-477b-aab3-6c93eb92ddfa",
"slug": "insufficient_permissions",
"message": "Insufficient permissions"
}
}{
"error": {
"id": "596b1dc7-af60-477b-aab3-6c93eb92ddfa",
"slug": "resource_not_found",
"message": "The resource you requested could not be found."
}
}{
"error": {
"id": "596b1dc7-af60-477b-aab3-6c93eb92ddfa",
"slug": "internal_server_error",
"message": "Internal server error"
}
}Authorizations
ApiKeyAuthBearerAuth
An API key is a token that a client provides when making API calls. Send it as the X-Access-Key request header on any endpoint:
curl '<API_ENDPOINT>' \ -H 'X-Access-Key: ${TENDERLY_ACCESS_KEY}' \ ...
Learn how to generate API access tokens at Tenderly Docs.
Path Parameters
Account slug of the user
Project slug of the account
Body
application/json
Encode contract state overrides payload
ID of the network.
Example:
"1"
Overrides for specific state objects.
Example:
{ "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48": { "value": { "balanceAndBlacklistStates[0xAd4A638e2476C5645c1adF659EA8105FE3C1031e]": "1000" } } }
Number of the block to be used for the encoding states.
Example:
"-1"
Response
A successful response.
An object with details about state overrides.
Was this page helpful?
⌘I