-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathindex.ts
More file actions
35 lines (30 loc) · 909 Bytes
/
index.ts
File metadata and controls
35 lines (30 loc) · 909 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
* Example: Typed SDK usage
*
* For applications that want full type safety.
*
* Prerequisites:
* npm install @graphprotocol/client-cli @graphprotocol/client-x402
*
* Build the SDK first:
* export X402_PRIVATE_KEY=0x...
* export X402_CHAIN=base-sepolia
* npx graphclient build
*
* Then run this file:
* npx tsx index.ts
*/
import { execute, GetIndexersDocument } from './.graphclient'
async function main() {
// Execute with full type safety - result is typed based on your schema and query
const result = await execute(GetIndexersDocument, {})
if (result.errors) {
console.error('GraphQL errors:', result.errors)
return
}
// result.data is fully typed
for (const indexer of result.data?.indexers ?? []) {
console.log(`Indexer ${indexer.id}: ${indexer.stakedTokens} staked, ${indexer.allocations.length} allocations`)
}
}
main().catch(console.error)