zenith-docs/docs/api/lockdrop-watcher.md
2025-11-28 15:34:21 -05:00

116 lines
2.5 KiB
Markdown

# Lockdrop Watcher API
The Lockdrop Watcher monitors the Zenith lockdrop contract on Ethereum, tracking participant deposits and lock commitments during Stage 0.
**GraphQL Endpoint**: `https://lockdrop-watcher.zenith-test.tlon.systems/graphql`
## Query Deposit Information
```graphql
query GetDeposit($address: String!) {
deposit(address: $address) {
address
points
lockDuration
timestamp
blockNumber
transactionHash
}
}
```
## Query All Deposits
```graphql
query GetAllDeposits {
deposits(orderBy: timestamp, orderDirection: desc) {
address
points
lockDuration
timestamp
}
}
```
## Query Locked Points
```graphql
query GetLockedPoints($pointId: Int!) {
lockedPoint(id: $pointId) {
pointId
owner
lockDuration
lockedAt
unlocksAt
withdrawn
}
}
```
## Using the GraphQL API
### With curl
```bash
# Query Lockdrop Watcher
curl -X POST https://lockdrop-watcher.zenith-test.tlon.systems/graphql \
-H "Content-Type: application/json" \
-d '{
"query": "query { deposits { address points lockDuration } }"
}'
```
### With JavaScript/TypeScript
```javascript
const query = `
query GetDeposit($address: String!) {
deposit(address: $address) {
points
lockDuration
timestamp
}
}
`;
const variables = { address: "0x..." };
const response = await fetch('https://lockdrop-watcher.zenith-test.tlon.systems/graphql', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query, variables })
});
const data = await response.json();
```
### With GraphQL Client Libraries
```javascript
import { GraphQLClient } from 'graphql-request';
const client = new GraphQLClient(
'https://lockdrop-watcher.zenith-test.tlon.systems/graphql'
);
const query = `
query GetDeposit($address: String!) {
deposit(address: $address) {
points lockDuration timestamp
}
}
`;
const data = await client.request(query, { address: '0x...' });
```
## Rate Limiting and Best Practices
- **Rate Limits**: Public watcher endpoints have rate limiting in place. For production applications, consider running your own watcher instances.
- **Pagination**: Use pagination parameters for queries that return large result sets.
- **Caching**: Cache frequently accessed data to reduce API load.
- **Error Handling**: Implement proper error handling and retry logic for network failures.
!!! note "Watcher Documentation"
For more information about the watcher architecture and deployment, see the [Watchers documentation](../documentation/watchers.md).