Implements an on-chain GraphQL query precompile that enables any EVM contract to execute GraphQL queries against the G-Chain unified query layer. Contracts can read indexed blockchain state, cross-chain data, and oracle feeds without off-chain infrastructure. Includes a result cache, subscription registration, cache management, and index hinting.
0x0500000000000000000000000000000000000010 | GraphQL query execution |0x0500000000000000000000000000000000000011 | Subscription registration |0x0500000000000000000000000000000000000012 | Cache management |0x0500000000000000000000000000000000000013 | Index hints |Query (0x...0010):
Input: query_len(2) + query(UTF-8) + variables_len(2) + variables(JSON)
Output: result(JSON bytes)
Subscribe (0x...0011):
Input: subscription query + callback address + callback selector
Output: subscription_id(32)
Cache (0x...0012):
Input: op(1) + cache_key(32)
0x01: Get cached result
0x02: Invalidate cache entry
0x03: Set TTL
Gas costs scale with query complexity (estimated from the query AST):
1. Query complexity is bounded: maximum depth, field count, and result size are enforced to prevent denial-of-service.
2. Cross-chain queries return data at the latest finalized block height -- no unconfirmed data.
3. Cache entries have TTLs and can be invalidated. Stale data risk is managed by the contract.
4. The G-Chain client connection is local to the node. No external network calls during EVM execution.
github.com/luxfi/precompile/graph/Copyright (C) 2024-2026, Lux Partners Limited. All rights reserved.
Licensed under the MIT License.