Indexer.getReceivedAttestationUIDs

getReceivedAttestationUIDs(
  address recipient,
  bytes32 schemaUid,
  uint256 start,
  uint256 length,
  bool reverseOrder
) external view returns (bytes32[] memory)

페이지네이션 역방향 조회입니다. schemaUid로 recipient에게 발급된 attestation UID를 최대 length개 반환합니다. reverseOrder = true를 지정하면 가장 최근 항목부터 조회합니다. 반환된 각 UID를 EAS.getAttestation(uid)에 전달하여 실제 구조체를 가져오고 폐기/만료 여부를 확인합니다.

파라미터

이름 타입 필수 설명
recipient address ✓ 수신자(subject) 주소입니다.
schemaUid bytes32 ✓ 필터링할 스키마 UID입니다.
start uint256 ✓ indexer 목록의 0 기반 오프셋입니다. 첫 페이지를 가져올 때는 0을 전달합니다.
length uint256 ✓ 반환할 최대 UID 개수입니다. Indexer가 매우 큰 요청을 내부적으로 제한하므로 실용상 호출당 50~100개가 적절합니다.
reverseOrder bool ✓ true로 설정하면 가장 최근 attestation부터 가장 오래된 순으로 순회합니다. 대부분의 UI 사용 사례에서 권장되는 방향입니다.

반환값

타입: bytes32[]

Attestation UID 배열입니다. 일치하는 attestation이 없으면 빈 배열이 반환됩니다.

예제

viem — 가장 최근 5개 attestation

이 예시는 최근 다섯 개 중 유효한 attestation을 아무거나 찾습니다. PCL의 EAS_POLICY는 더 엄격해서 가장 최근에 인덱싱된 하나만 읽으므로, 그것이 폐기되었거나 만료되었다면 더 오래된 유효한 attestation이 있어도 정책을 통과하지 못합니다.

import { parseAbi } from "viem";

const easAbi = parseAbi([
  "struct Attestation { bytes32 uid; bytes32 schema; uint64 time; uint64 expirationTime; uint64 revocationTime; bytes32 refUID; address recipient; address attester; bool revocable; bytes data; }",
  "function getAttestation(bytes32 uid) view returns (Attestation)",
]);
const indexerAbi = parseAbi([
  "function getReceivedAttestationUIDCount(address recipient, bytes32 schemaUID) view returns (uint256)",
  "function getReceivedAttestationUIDs(address recipient, bytes32 schemaUID, uint256 start, uint256 length, bool reverseOrder) view returns (bytes32[])",
]);

const INDEXER = "0x1000000000000000000000000000000000000008";

const uids = await publicClient.readContract({
  address: INDEXER,
  abi: indexerAbi,
  functionName: "getReceivedAttestationUIDs",
  args: [recipient, schemaUid, 0n, 5n, true],
});

// Then look up each one to validate
const attestations = await Promise.all(
  uids.map((uid) =>
    publicClient.readContract({
      address: EAS,
      abi: easAbi,
      functionName: "getAttestation",
      args: [uid],
    })
  )
);
const valid = attestations.find(
  (a) => a.revocationTime === 0n && (a.expirationTime === 0n || a.expirationTime > now)
);
ESC
검색어를 입력하세요