SSV Subgraph Examples
This page provides example queries you can use to retrieve data from the SSV Network subgraph.
Examples are provided in:
- GraphQL for direct use in the subgraph playground
- JavaScript for use in your application code
- cURL for use in a terminal
You can use these examples with either official subgraph deployment:
- Ethereum Mainnet
- Hoodi Testnet, used on all of the examples below.
Queries are case-sensitive. Use lowercase values for query parameters where required. For example, account ID 0x09cef28c35a5fab6f5fdbf45603b8eaac7b8b797 will work, while 0x09CeF28c35A5FaB6F5FdBf45603b8eAaC7B8B797 will return null.
Account Nonce
Returns the nonce of an account.
- GraphQL
- JavaScript
- cURL
query AccountNonceQuery { account(id: "0x09cef28c35a5fab6f5fdbf45603b8eaac7b8b797") { nonce }}const url = "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest";const query = 'query AccountNonceQuery { account(id: "0x09cef28c35a5fab6f5fdbf45603b8eaac7b8b797") { nonce }}';
const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query })});
const responseData = await response.json();console.log(responseData);curl -X POST "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest" -H "Content-Type: application/json" -d '{ "query": "query AccountNonceQuery { account(id: "0x09cef28c35a5fab6f5fdbf45603b8eaac7b8b797") { nonce }}"}'Output:
{
"data": {
"account": {
"nonce": "0"
}
}
}
Cluster Snapshot
Returns the cluster snapshot required by several smart contract functions, such as validator registration.
The cluster's id is generated by concatenating the owner address and the operator IDs using a dash (-) separator.
- GraphQL
- JavaScript
- cURL
query ClusterSnapshot { cluster(id: "0x0f1651507bdd33d3d18a5732c22d4713020cd100-5-6-7-8") { validatorCount networkFeeIndex index active balance }}const url = "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest";const query = 'query ClusterSnapshot { cluster(id: "0x0f1651507bdd33d3d18a5732c22d4713020cd100-5-6-7-8") { validatorCount networkFeeIndex index active balance }}';
const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query })});
const responseData = await response.json();console.log(responseData);curl -X POST "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest" -H "Content-Type: application/json" -d '{ "query": "query ClusterSnapshot { cluster(id: "0x0f1651507bdd33d3d18a5732c22d4713020cd100-5-6-7-8") { active balance index lastUpdateBlockNumber networkFeeIndex validatorCount } }" }'Output
{
"data": {
"cluster": {
"active": true,
"balance": "5353643967300000000",
"index": "34520824200",
"lastUpdateBlockNumber": "232527",
"networkFeeIndex": "0",
"validatorCount": "3"
}
}
}
DAO constants and protocol network fee index
Returns important DAO-set values, such as minimum liquidation collateral and liquidation threshold period, along with the protocol-wide network fee index. These values are used to calculate cluster balances, evaluate liquidation risk, and determine the ETH amount per SSV share.
The id of daovalues is the address of the SSVNetwork smart contract deployed on the current chain. So in the case of Hoodi it's 0x58410Bef803ECd7E63B23664C586A6DB72DAf59c, the Mainnet one is 0xDD9BC35aE942eF0cFa76930954a156B3fF30a4E1.
- GraphQL
- JavaScript
- cURL
query daoValues { daovalues(id: "0x58410Bef803ECd7E63B23664C586A6DB72DAf59c") { declareOperatorFeePeriod executeOperatorFeePeriod liquidationThreshold minimumLiquidationCollateral networkFee networkFeeIndex networkFeeIndexBlockNumber operatorFeeIncreaseLimit operatorMaximumFee quorum accEthPerShare latestMerkleRoot totalEffectiveBalance networkFeeSSV networkFeeIndexSSV operatorMaximumFeeSSV liquidationThresholdSSV networkFeeIndexBlockNumberSSV minimumLiquidationCollateralSSV }}const url = "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest";const query = 'query daoValues { daovalues(id: "0x58410Bef803ECd7E63B23664C586A6DB72DAf59c") { declareOperatorFeePeriod executeOperatorFeePeriod liquidationThreshold minimumLiquidationCollateral networkFee networkFeeIndex networkFeeIndexBlockNumber operatorFeeIncreaseLimit operatorMaximumFee quorum accEthPerShare latestMerkleRoot totalEffectiveBalance networkFeeSSV networkFeeIndexSSV operatorMaximumFeeSSV liquidationThresholdSSV networkFeeIndexBlockNumberSSV minimumLiquidationCollateralSSV }}';
const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query })});
const responseData = await response.json();console.log(responseData);curl -X POST "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest" -H "Content-Type: application/json" -d '{ "query": "query daoValues { daovalues(id: "0x58410Bef803ECd7E63B23664C586A6DB72DAf59c") { declareOperatorFeePeriod executeOperatorFeePeriod liquidationThreshold minimumLiquidationCollateral networkFee networkFeeIndex networkFeeIndexBlockNumber operatorFeeIncreaseLimit operatorMaximumFee quorum accEthPerShare latestMerkleRoot totalEffectiveBalance networkFeeSSV networkFeeIndexSSV operatorMaximumFeeSSV liquidationThresholdSSV networkFeeIndexBlockNumberSSV minimumLiquidationCollateralSSV }}"}'Output
{
"data": {
"daovalues": {
"declareOperatorFeePeriod": "180",
"executeOperatorFeePeriod": "180",
"liquidationThreshold": "50190",
"minimumLiquidationCollateral": "940000000000000",
"networkFee": "3550000000",
"networkFeeIndex": "704794182000000000",
"networkFeeIndexBlockNumber": "2122845",
"operatorFeeIncreaseLimit": "1000",
"operatorMaximumFee": "13900000000",
"quorum": 7500,
"accEthPerShare": "8640821385400000",
"latestMerkleRoot": "0x00000000",
"totalEffectiveBalance": "1685694",
"networkFeeSSV": "0",
"networkFeeIndexSSV": "0",
"operatorMaximumFeeSSV": "0",
"liquidationThresholdSSV": "214800",
"networkFeeIndexBlockNumberSSV": "0",
"minimumLiquidationCollateralSSV": "1000000000000000000"
}
}
}
Cluster Balance Values
Returns the data needed to compute the cluster balance.
- GraphQL
- JavaScript
- cURL
query clusterBalanceValues { _meta { block { number } } daovalues(id: "0x58410Bef803ECd7E63B23664C586A6DB72DAf59c") { networkFee networkFeeIndex networkFeeIndexBlockNumber } operators(where: {id_in: ["5", "6", "7", "8"]}) { fee feeIndex feeIndexBlockNumber } cluster(id: "0x0f1651507bdd33d3d18a5732c22d4713020cd100-5-6-7-8") { validatorCount networkFeeIndex index balance }}const url = "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest";const query = 'query clusterBalanceValues { _meta { block { number } } daovalues(id: "0x58410Bef803ECd7E63B23664C586A6DB72DAf59c") { networkFee networkFeeIndex networkFeeIndexBlockNumber } operators(where: {id_in: ["5", "6", "7", "8"]}) { fee feeIndex feeIndexBlockNumber } cluster(id: "0x0f1651507bdd33d3d18a5732c22d4713020cd100-5-6-7-8") { validatorCount networkFeeIndex index balance }}';
const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query })});
const responseData = await response.json();console.log(responseData);curl -X POST "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest" -H "Content-Type: application/json" -d '{ "query": "query clusterBalanceValues { _meta { block { number }} daovalues(id: "0x58410Bef803ECd7E63B23664C586A6DB72DAf59c") { networkFee networkFeeIndex networkFeeIndexBlockNumber } operators(where: {id_in: ["5", "6", "7", "8"]}) { fee feeIndex feeIndexBlockNumber } cluster(id: "0x0f1651507bdd33d3d18a5732c22d4713020cd100-5-6-7-8") { validatorCount networkFeeIndex index balance }}"}'Output
{
"data": {
"daovalues": {
"networkFee": "382640000000",
"networkFeeIndex": "215784140000000",
"networkFeeIndexBlockNumber": "131572"
},
"operators": [
{
"fee": "956600000000",
"feeIndex": "0",
"feeIndexBlockNumber": "20761"
},
{
"fee": "956600000000",
"feeIndex": "0",
"feeIndexBlockNumber": "20762"
},
{
"fee": "956600000000",
"feeIndex": "0",
"feeIndexBlockNumber": "20763"
},
{
"fee": "956600000000",
"feeIndex": "0",
"feeIndexBlockNumber": "20764"
}
],
"cluster": {
"validatorCount": "3",
"networkFeeIndex": "0",
"index": "34520824200",
"balance": "5353643967300000000"
},
"_meta": {
"block": {
"number": 239528
}
}
}
}
List of Validators for an owner
Returns a list of validators for an owner and whether they are active. This query fetches the first 5 validators owned by the address.
It is best to limit queries to avoid unnecessary load, reduce performance issues, and avoid spending too many credits in production.
- GraphQL
- JavaScript
- cURL
query ListOfValidatorsPerOwner { validators( where: {owner: "0x0f1651507bdd33d3d18a5732c22d4713020cd100"} first: 5 ) { id owner { id } active }}const url = "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest";const query = 'query ListOfValidatorsPerOwner { validators( where: {owner: "0x0f1651507bdd33d3d18a5732c22d4713020cd100"} first: 5 ) { id owner { id } active }}';
const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query })});
const responseData = await response.json();console.log(responseData);curl -X POST "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest" -H "Content-Type: application/json" -d '{ "query": "query ListOfValidatorsPerOwner { validators(where: {owner: "0x0f1651507bdd33d3d18a5732c22d4713020cd100"}) { id owner { id }}}"}'Output
{
"data": {
"validators": [
{
"id": "0x82808139fefab04eec339d1e4137b0e7d05eb75ec5eacdfe0b6f8d1cf2151b9f46ff3854e3ac5f44467fdc86bdbca345",
"owner": {
"id": "0x0f1651507bdd33d3d18a5732c22d4713020cd100"
}
},
{
"id": "0x86825ffcf382b1202e9280ec91d32f9d81cb38281438091839da60a2e9429af09fc9b643f8f4bcd81361bd0a53de5789",
"owner": {
"id": "0x0f1651507bdd33d3d18a5732c22d4713020cd100"
}
},
{
"id": "0x8bd2ecade0c1569802ef23fcde281ea27c7b3a005840808addcfa33d838d599b518ac189f10591d76f74d67190ffe460",
"owner": {
"id": "0x0f1651507bdd33d3d18a5732c22d4713020cd100"
}
}
]
}
}
Validator Data by ID (Active status and Operator IDs)
Returns operator IDs and status data for a validator public key.
- GraphQL
- JavaScript
- cURL
query ValidatorData { validator( id: "0x80033d71f582fb41315ed3e697d7012b8101fb2e9153a9cd3dc3bf9ff3da240c92848fba366c619bdb2aca3e4b0367ef" ) { removed operators(first: 10) { operatorId } }}const url = "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest";const query = 'query ValidatorData { validator( id: "0x80033d71f582fb41315ed3e697d7012b8101fb2e9153a9cd3dc3bf9ff3da240c92848fba366c619bdb2aca3e4b0367ef" ) { removed operators(first: 10) { operatorId } }}';
const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query })});
const responseData = await response.json();console.log(responseData);curl -X POST "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest" -H "Content-Type: application/json" -d '{ "query": "query ValidatorData { validator(id: "0x80033d71f582fb41315ed3e697d7012b8101fb2e9153a9cd3dc3bf9ff3da240c92848fba366c619bdb2aca3e4b0367ef") { removed operators(first: 10) { operatorId }}}"}'Output
{
"data": {
"validator": {
"removed": false,
"operators": [
{
"operatorId": "108"
},
{
"operatorId": "111"
},
{
"operatorId": "74"
},
{
"operatorId": "88"
}
]
}
}
}
Cluster Data by ID (Balance, Active status and Operator IDs)
Returns active status, effective balance, fee asset type (ETH or SSV), validator count, and validator public keys for a cluster.
The cluster's id is generated by concatenating the owner address and the operator IDs using a dash (-) separator.
- GraphQL
- JavaScript
- cURL
query ClusterData { cluster(id: "0x0f1651507bdd33d3d18a5732c22d4713020cd100-5-6-7-8") { active effectiveBalance feeAsset validatorCount validators { id } }}const url = "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest";const query = 'query ClusterData { cluster(id: "0x0f1651507bdd33d3d18a5732c22d4713020cd100-5-6-7-8") { active effectiveBalance feeAsset validatorCount validators { id } }}';
const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query })});
const responseData = await response.json();console.log(responseData);curl -X POST "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest" -H "Content-Type: application/json" -d '{ "query": "query ClusterData { cluster(id: "0x0f1651507bdd33d3d18a5732c22d4713020cd100-5-6-7-8") { active effectiveBalance feeAsset validatorCount validators { id } }}"}'Output:
{
"data": {
"cluster": {
"active": true,
"effectiveBalance": "110000000000000000000",
"feeAsset": "ETH",
"validatorCount": "3"
"validators": [
{
"id": "0x82808139fefab04eec339d1e4137b0e7d05eb75ec5eacdfe0b6f8d1cf2151b9f46ff3854e3ac5f44467fdc86bdbca345",
"owner": {
"id": "0x0f1651507bdd33d3d18a5732c22d4713020cd100"
}
},
{
"id": "0x86825ffcf382b1202e9280ec91d32f9d81cb38281438091839da60a2e9429af09fc9b643f8f4bcd81361bd0a53de5789",
"owner": {
"id": "0x0f1651507bdd33d3d18a5732c22d4713020cd100"
}
},
{
"id": "0x8bd2ecade0c1569802ef23fcde281ea27c7b3a005840808addcfa33d838d599b518ac189f10591d76f74d67190ffe460",
"owner": {
"id": "0x0f1651507bdd33d3d18a5732c22d4713020cd100"
}
}
],
}
}
}
Operator data by ID (Validator count, Fee, private and active status)
Returns validator count, fee, and status data.
- GraphQL
- JavaScript
- cURL
query ValidatorCountPerOperator {operator(id: "7") { fee removed totalWithdrawn isPrivate validatorCount totalEffectiveBalance whitelisted { id }}}const url = "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest";const query = 'query ValidatorCountPerOperator { operator(id: "7") { fee removed totalWithdrawn isPrivate validatorCount totalEffectiveBalance whitelisted { id } }}';
const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query })});
const responseData = await response.json();console.log(responseData);curl -X POST "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest" -H "Content-Type: application/json" -d '{ "query": "query ValidatorCountPerOperator { operator(id: "7") { fee removed totalWithdrawn validatorCount totalEffectiveBalance isPrivate whitelisted { id } }}"}'Output:
{
"data": {
"operator": {
"fee": "956600000000",
"removed": false,
"totalWithdrawn": "0",
"validatorCount": "318",
"totalEffectiveBalance": "651264",
"isPrivate": false,
"whitelisted": []
}
}
}
Oracle data by ID (oracle ID, address, total delegated amount and its delegators)
Returns the oracle ID, address, total delegated amount, and delegators for a given oracle.
- GraphQL
- JavaScript
- cURL
query OracleData {operator(id: "1") { totalDelegatedAmount oracleId oracleAddress id delegators { amount delegator { id } }}}}const url = "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest";const query = 'query OracleData { operator(id: "1") { totalDelegatedAmount oracleId oracleAddress id delegators { amount delegator { id } } } }}';
const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query })});
const responseData = await response.json();console.log(responseData);curl -X POST "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest" -H "Content-Type: application/json" -d '{ "query": "query OracleData { operator(id: "1") { totalDelegatedAmount oracleId oracleAddress id delegators { amount delegator { id } } } } }"}'Output:
{
"data": {
"oracle": {
"totalDelegatedAmount": "5421250000000000000000",
"oracleId": "1",
"oracleAddress": "0x011684890d10ecc4473f2a4a8b0f2cb7f19c66eb",
"id": "1",
"delegators": [
{
"amount": "7750000000000000000",
"delegator": {
"id": "0x4f0f5ab30f62b62ed0466b697f0ec7b30560ee48"
}
},
{
"amount": "6250000000000000000",
"delegator": {
"id": "0x599fdcd9b73052226721f093fe7b0bddd393fbdf"
}
}
]
}
}
}
10 most recent clusters with a validator count of 4
Returns data for the 10 most recently updated clusters with 4 validators by sorting on lastUpdateBlockNumber in descending order.
- GraphQL
- JavaScript
- cURL
query ClusterQuery { clusters( first: 10 where: {validatorCount: "4"} orderBy: lastUpdateBlockNumber orderDirection: desc ) { validatorCount lastUpdateBlockNumber id }}const url = "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest";const query = 'query ClusterQuery { clusters( first: 10 where: {validatorCount: "4"} orderBy: lastUpdateBlockNumber orderDirection: desc ) { validatorCount lastUpdateBlockNumber id }}';
const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ query })});
const responseData = await response.json();console.log(responseData);curl -X POST "https://api.studio.thegraph.com/query/71118/ssv-network-hoodi/version/latest" -H "Content-Type: application/json" -d '{ "query": "query ClusterQuery { clusters(first: 10 where: {validatorCount: "4"} orderBy: lastUpdateBlockNumber orderDirection: desc) { validatorCount lastUpdateBlockNumber id }}"}'Output:
{
"data": {
"clusters": [
{
"validatorCount": "4",
"lastUpdateBlockNumber": "239598",
"id": "0xd5822eeeb87c2dcd41b307a741ce993d62baf21b-5-6-7-8"
}
]
}
}