EAS.getAttestation

getAttestation(bytes32 uid) external view returns (Attestation memory)

Returns the full Attestation struct for a given UID, or an Attestation with uid == 0x00.. if the UID is unknown. This is the canonical read on the EAS contract preinstall — every other surface (@ethereum-attestation-service/eas-sdk, the Indexer, PCL's EAS_POLICY evaluator) ultimately calls this. dApp code should validate revocationTime == 0 and (expirationTime == 0 || expirationTime > now) before treating an attestation as valid.

Parameters

Name Type Required Description
uid bytes32 The 32-byte unique identifier of the attestation.

Returns

Type: Attestation

Struct fields: uid (bytes32), schema (bytes32), time (uint64, attestation timestamp), expirationTime (uint64, 0 = never), revocationTime (uint64, 0 = not revoked), refUID (bytes32, optional reference to another attestation), recipient (address), attester (address), revocable (bool), data (bytes, schema-encoded payload).

Examples

viem readContract

import { createPublicClient, http } from "viem";
// EAS contract address — resolve via the EAS precompile's getParams()
// or hard-code the canonical preinstall: 0x1000000000000000000000000000000000000007
const EAS = "0x1000000000000000000000000000000000000007";

const attestation = await publicClient.readContract({
  address: EAS,
  abi: easAbi,
  functionName: "getAttestation",
  args: [uid],
});

const now = BigInt(Math.floor(Date.now() / 1000));
const valid =
  attestation.uid !== "0x0000000000000000000000000000000000000000000000000000000000000000" &&
  attestation.revocationTime === 0n &&
  (attestation.expirationTime === 0n || attestation.expirationTime > now);

Foundry cast

cast call $EAS "getAttestation(bytes32)" $UID --rpc-url $MAROO_RPC
ESC
Type to search