API
Pull data programmatically from Ethernal
Last updated
Pull data programmatically from Ethernal
Last updated
At the moment, only one endpoint is available, if there is some data that you'd like to fetch from the API, please reach out to antoine@tryethernal.com, @antoinedc on Discord or @adechevigne on Twitter!
To authenticate, you'll need an auth token that you will find on the "Settings" page. The "API" integration needs to be enabled for requests to go through.
Once you've enabled the integration, the token will be displayed below.
Pass it in a token
GET parameter to the endpoint you'd like to use.
Each workspace has its own token
GET
https://api.tryethernal.com/contracts/:contractAddress/storage?token=xxx&paths[]=["balances", "0x123456789"]
Reads values of the variables of the contract at address contractAddress
. This makes available data you'll find in the "Storage" tab in contracts pages through an API.
You need to pass an array of arrays, where each element is the path to the variable you want to read.
Top level primitives are automatically decoded, you don't need to specify them in the path.
If a variable is not found, an error will be returned.
Example:
If we have a contract with the following variables declared:
(address => uint256) balances;
uint256 total;
And if we want to read the total and the balance for addresses 0x1234
and 0x5678
, we would call the following:
https://api.tryethernal.com/contracts/0xabcdef/storage?token=xxx&paths[]=["balances", "0x1234"]&paths[]=["balances", "0x5678"]
total
will always be returned.
The response will have two fields: a paths field that returns asked paths, and a storage field that will contains the values.
In this case, it would be:
{
paths: [
['balances', '0x1234'],
['balances', '0x5678']
],
storage: {
balances: {
'Ox1234': '10000',
'0x5678': '20000'
},
total: '30000'
}
}
You can find more details about variable reading in this section.
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
contractAddress
string
Address of the contract
paths
array
Paths of the variables you want to read
token
string
Authentication token