Querying EAS Data
How to read attestations from Maroo's EAS — via Solidity contract calls (the canonical surface), via the EAS Indexer for reverse lookups, and via the JS/TS SDKs.
Prerequisites
- Maroo testnet RPC URL
- EAS / EAS Indexer addresses (preinstalls or resolved via the EAS precompile's
getParams())
Resolve EAS / Indexer addresses
Two options. Hard-code the canonical preinstall addresses (
EAS = 0x1000…0007, Indexer = 0x1000…0008) — fine for known networks. Or call the EAS precompile's getParams() so the same code works against any Maroo network without modification.import { createPublicClient, http } from "viem";
const EAS_PRECOMPILE = "0x1000000000000000000000000000000000000009";
const { eas: EAS, indexer: INDEXER } = await publicClient.readContract({
address: EAS_PRECOMPILE,
abi: easPrecompileAbi,
functionName: "getParams",
}); Method 1 — Direct contract call (viem / ethers)
The default path for frontend dApps and most backend code. Use
getAttestation(uid) against the EAS contract; it returns the full Attestation struct (schema, recipient, attester, time, expirationTime, revocationTime, refUID, data).import { createPublicClient, http } from "viem";
const publicClient = createPublicClient({ transport: http(MAROO_RPC) });
const attestation = await publicClient.readContract({
address: EAS,
abi: easAbi,
functionName: "getAttestation",
args: [uid],
});
// attestation.recipient, attestation.revocationTime, attestation.expirationTime, ... Method 2 — Reverse lookups via the Indexer
"Has user X been attested under schema Y?" — that's the Indexer. Two methods you'll use:
Then feed each UID into Method 1 to fetch the actual attestation.
getReceivedAttestationUIDCount(recipient, schemaUid)→ cheap existence checkgetReceivedAttestationUIDs(recipient, schemaUid, start, length, reverseOrder)→ paginated list
Then feed each UID into Method 1 to fetch the actual attestation.
// 1) count check
const count = await publicClient.readContract({
address: INDEXER,
abi: indexerAbi,
functionName: "getReceivedAttestationUIDCount",
args: [recipient, schemaUid],
});
// 2) most recent 5
const uids = await publicClient.readContract({
address: INDEXER,
abi: indexerAbi,
functionName: "getReceivedAttestationUIDs",
args: [recipient, schemaUid, 0n, 5n, true /* reverseOrder */],
}); Note: Filter out revoked/expired attestations after fetching — the Indexer only tracks issuance, not validity. PCL's `EAS_POLICY` does the same revocation/expiration checks against `getAttestation`.
Method 3 — eas-sdk (JS)
If you already use the official
@ethereum-attestation-service/eas-sdk in your stack, point it at the Maroo EAS address and use it normally. The SDK wraps getAttestation and the schema registry calls.const { EAS } = require("@ethereum-attestation-service/eas-sdk");
const eas = new EAS(EAS); // canonical Maroo EAS address
await eas.connect(provider);
const attestation = await eas.getAttestation(uid); Note: The eas-sdk doesn't ship Indexer bindings — for reverse lookups you'll still call the Indexer directly via viem/ethers as in Method 2.
Method 4 — `cast` for ad-hoc terminal queries
When you just want to confirm a value from the shell.
# fetch one attestation
cast call $EAS "getAttestation(bytes32)" $UID --rpc-url $MAROO_RPC
# count attestations a user has under a schema
cast call $INDEXER \
"getReceivedAttestationUIDCount(address,bytes32)(uint256)" \
$RECIPIENT $SCHEMA_UID --rpc-url $MAROO_RPC