アテステーションは、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は、関連するクレデンシャルの認可された署名者の1人である必要がありますexpiryは、アテステーションが無効になる時点を決定しますtokenAccountは、アテステーションを特定のトークンアカウントにリンクします- アテステーションは、関連するクレデンシャルの認可された署名者によってのみ作成できます
- アテステーションデータは、関連するスキーマで定義された構造に準拠する必要があります
Is this page helpful?