증명서는 Solana 증명 시스템에서 검증된 주장 또는 진술을 나타냅니다. 증명서는 자격 증명 하에 승인된 서명자에 의해 생성되며 특정 스키마를 따릅니다. 각 증명서에는 주장의 실제 데이터와 생성 및 유효성에 대한 메타데이터가 포함됩니다.
구조
Attestation 구조체는 Solana 증명 시스템의 증명서를 나타냅니다. 각 증명서는 자격 증명, 스키마와 연결되며 증명된 데이터와 생성 및 유효 기간에 대한 메타데이터를 포함합니다.
타입 정의
Attestation
export type Attestation = {discriminator: number; // Internal discriminatornonce: Address; // Unique identifier for the attestationcredential: Address; // Associated credential addressschema: Address; // Associated schema addressdata: ReadonlyUint8Array; // Attestation datasigner: Address; // Address of the signer who created the attestationexpiry: bigint; // Expiration timestamptokenAccount: 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 biginttokenAccount: 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는 각 증명에 대한 고유 식별자를 제공합니다credential및schema필드는 증명을 관련 자격 증명 및 스키마에 연결합니다data필드는 실제 증명 데이터를 포함하며 스키마에 따라 적절히 인코딩/디코딩되어야 합니다signer는 관련 자격 증명의 승인된 서명자 중 하나여야 합니다expiry는 증명이 무효화되는 시점을 결정합니다tokenAccount는 증명을 특정 token account에 연결합니다- 증명은 관련 자격 증명의 승인된 서명자만 생성할 수 있습니다
- 증명 데이터는 관련 스키마에서 정의한 구조를 준수해야 합니다
Is this page helpful?