EAS.getAttestation

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

주어진 UID에 대한 전체 Attestation 구조체를 반환합니다. UID가 알려지지 않은 값이면 uid == 0x00..인 Attestation이 반환됩니다. EAS 컨트랙트 preinstall의 정식 read 메서드이며, 다른 모든 surface(@ethereum-attestation-service/eas-sdk, Indexer, PCL EAS_POLICY 평가자)도 결국 이 함수를 호출합니다. dApp 코드는 attestation을 유효한 것으로 취급하기 전에 revocationTime == 0과 (expirationTime == 0 || expirationTime > now) 조건을 함께 검증해야 합니다.

파라미터

이름 타입 필수 설명
uid bytes32 Attestation의 32바이트 고유 식별자입니다.

반환값

타입: Attestation

구조체 필드입니다. uid(bytes32), schema(bytes32), time(uint64, attestation 타임스탬프), expirationTime(uint64, 0이면 만료 없음), revocationTime(uint64, 0이면 미폐기), refUID(bytes32, 다른 attestation에 대한 선택적 참조), recipient(address), attester(address), revocable(bool), data(bytes, 스키마 인코딩 페이로드).

예제

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
검색어를 입력하세요