Subgraph
The Graph is a protocol for indexing networks like Ethereum and IPFS. Site owners publish subgraphs that expose site data for anyone to query. UniRep's subgraph allows you to retrieve data from the Unirep.sol
smart contract.
info
The Graph protocol uses the GraphQL query language. For examples, see the GraphQL API documentation.
Deployment
UniRep subgraph version 2.0.0 is deployed on the following networks:
Network | API |
---|---|
Sepolia | https://api.studio.thegraph.com/query/48080/sepolia/v2.0.0 |
Arbitrum Sepolia | NOT SUPPORTED YET |
Avalanche Fuji | https://api.studio.thegraph.com/query/48080/fuji/v2.0.0 |
Query Examples
- Query the first 100 attesters (by default, sorted by
id
).
info
id
is computed by
event.transaction.hash.concatI32(event.logIndex.toI32())
query MyQuery {
attesters {
attesterId
blockNumber
epochLength
startTimestamp
transactionHash
}
}
- Query the first 100 users from a certain attester ID (by default, sorted by
id
).
query MyQuery {
users(
where: {
attesterId: "812064237485286466066480536294992408637941768146"
}
) {
commitment
}
}
- Query the first 100 state tree leaves, sorted by
index
.
query MyQuery {
stateTreeLeaves(
orderBy: index
where: {
attesterId: "812064237485286466066480536294992408637941768146"
epoch: "1"
}
) {
leaf
}
}
- Query the first 1000 state tree leaves, sorted by
index
.
query MyQuery {
stateTreeLeaves(
first: 1000
orderBy: index
where: {
attesterId: "812064237485286466066480536294992408637941768146"
epoch: "1"
}
) {
leaf
}
}
- Query the next 1000 state tree leaves, sorted by
index
.
query MyQuery {
stateTreeLeaves(
skip: 1000
first: 1000
orderBy: index
where: {
attesterId: "812064237485286466066480536294992408637941768146"
epoch: "1"
}
) {
leaf
}
}
Schema
Attestation
id
: An id to avoid data collisionepoch
: The epoch in which an attestation occurredepochKey
: The receiver's epoch keyattesterId
: The attester addressfieldIndex
: The index of the data field that was changedchange
: The change number of the datablockNumber
: The block number in which the attestation transaction occurredblockTimestamp
: The timestamp of the block in which the attestation transaction occurredtransactionHash
: The attestation transaction hash
StateTreeLeaf
id
: An id to avoid data collisionepoch
: The epoch in which the state tree leaf was emittedleaf
: The emitted state tree leafindex
: The index of the state tree leaf in the epochattesterId
: The attester addressblockNumber
: The block number in which the transaction occurredblockTimestamp
: The timestamp of the block in which the transaction occurredtransactionHash
: The transaction hash
EpochTreeLeaf
id
: An id to avoid data collisionepoch
: The epoch in which the epoch tree leaf was emittedleaf
: The emitted epoch tree leafindex
: The index of the epoch tree leaf in the epochattesterId
: The attester addressblockNumber
: The block number in which the transaction occurredblockTimestamp
: The timestamp of the block in which the transaction occurredtransactionHash
: The transaction hash
HistoryTreeLeaf
id
: An id to avoid data collisionleaf
: The emitted history tree leafattesterId
: The attester addressblockNumber
: The block number in which the transaction occurredblockTimestamp
: The timestamp of the block in which the transaction occurredtransactionHash
: The transaction hash
Epoch
id
: An id to avoid data collisionnumber
: The number of the ended epochattesterId
: The attester addressblockNumber
: The block number in which the transaction occurredblockTimestamp
: The timestamp of the block in which the transaction occurredtransactionHash
: The transaction hash
Nullifier
id
: An id to avoid data collisionepoch
: The epoch in which the nullifier was emittedattesterId
: The attester addressnullifier
: The nullifier that was used to prevent a double user state transitionblockNumber
: The block number in which the transaction occurredblockTimestamp
: The timestamp of the block in which the transaction occurredtransactionHash
: The transaction hash
User
id
: An id to avoid data collisioncommitment
: The Semaphore identity commitmentepoch
: The epoch in which the user signed upattesterId
: The address of the attester the user signed up toleafIndex
: The state tree leaf of the signup eventblockNumber
: The block number in which the transaction occurredblockTimestamp
: The timestamp of the block in which the transaction occurredtransactionHash
: The transaction hash
Attester
id
: An id to avoid data collisionattesterId
: The attester addressstartTimestamp
: The start time of the attester's first epochepochLength
: The length of the attester's epochsblockNumber
: The block number in which the transaction occurredblockTimestamp
: The timestamp of the block in which the transaction occurredtransactionHash
: The transaction hash