증명서

증명서는 Solana 증명 시스템에서 검증된 주장 또는 진술을 나타냅니다. 증명서는 자격 증명 하에 승인된 서명자에 의해 생성되며 특정 스키마를 따릅니다. 각 증명서에는 주장의 실제 데이터와 생성 및 유효성에 대한 메타데이터가 포함됩니다.

구조

Attestation 구조체는 Solana 증명 시스템의 증명서를 나타냅니다. 각 증명서는 자격 증명, 스키마와 연결되며 증명된 데이터와 생성 및 유효 기간에 대한 메타데이터를 포함합니다.

타입 정의

Attestation

export type Attestation = {
discriminator: number; // Internal discriminator
nonce: Address; // Unique identifier for the attestation
credential: Address; // Associated credential address
schema: Address; // Associated schema address
data: ReadonlyUint8Array; // Attestation data
signer: Address; // Address of the signer who created the attestation
expiry: bigint; // Expiration timestamp
tokenAccount: Address; // Associated token account
};

AttestationArgs

export type AttestationArgs = {
discriminator: number;
nonce: Address;
credential: Address;
schema: Address;
data: ReadonlyUint8Array;
signer: Address;
expiry: number | bigint; // Can be either number or bigint
tokenAccount: Address;
};

메서드

증명서 가져오기

메서드설명매개변수반환값
fetchAttestation주소로 단일 증명서를 가져옵니다rpc: RPC 컨텍스트, address: 증명서 주소, config?: 가져오기 설정Promise<Account<Attestation>>
fetchMaybeAttestation안전하게 증명서를 가져오며, 찾을 수 없는 경우 null을 반환합니다rpc: RPC 컨텍스트, address: 증명서 주소, config?: 가져오기 설정Promise<MaybeAccount<Attestation>>
fetchAllAttestation주소로 여러 증명서를 가져옵니다rpc: RPC 컨텍스트, addresses: 증명서 주소 배열, config?: 가져오기 설정Promise<Account<Attestation>[]>
fetchAllMaybeAttestation안전하게 여러 증명서를 가져오며, 찾을 수 없는 항목은 건너뜁니다rpc: RPC 컨텍스트, addresses: 증명서 주소 배열, config?: 가져오기 설정Promise<MaybeAccount<Attestation>[]>

직렬화

메서드설명매개변수반환값
getAttestationEncoder증명서 데이터의 인코더를 가져옵니다없음Encoder<AttestationArgs>
getAttestationDecoder증명서 데이터의 디코더를 가져옵니다없음Decoder<Attestation>
getAttestationCodec증명서 데이터의 코덱을 가져옵니다없음Codec<AttestationArgs, Attestation>

사용 예제

단일 증명 가져오기

const attestation = await fetchAttestation(rpc, attestationAddress);
console.log("Attestation nonce:", attestation.nonce);

여러 증명 가져오기

const attestations = await fetchAllAttestation(rpc, [
attestation1Address,
attestation2Address
]);
attestations.forEach((attestation) =>
console.log("Attestation:", attestation.nonce)
);

안전한 가져오기

const attestation = await fetchMaybeAttestation(rpc, attestationAddress);
if (attestation) {
console.log("Attestation found:", attestation.nonce);
} else {
console.log("Attestation not found");
}

중요 참고사항

  • discriminator 필드는 내부적으로 사용되며 수정해서는 안 됩니다
  • nonce는 각 증명에 대한 고유 식별자를 제공합니다
  • credentialschema 필드는 증명을 관련 자격 증명 및 스키마에 연결합니다
  • data 필드는 실제 증명 데이터를 포함하며 스키마에 따라 적절히 인코딩/디코딩되어야 합니다
  • signer는 관련 자격 증명의 승인된 서명자 중 하나여야 합니다
  • expiry는 증명이 무효화되는 시점을 결정합니다
  • tokenAccount는 증명을 특정 token account에 연결합니다
  • 증명은 관련 자격 증명의 승인된 서명자만 생성할 수 있습니다
  • 증명 데이터는 관련 스키마에서 정의한 구조를 준수해야 합니다

Is this page helpful?

목차

페이지 편집