Een attestatie vertegenwoordigt een geverifieerde claim of verklaring in het Solana Attestation System. Attestaties worden aangemaakt door geautoriseerde ondertekenaars onder een credential en volgen een specifiek schema. Elke attestatie bevat de daadwerkelijke data van de claim en metadata over de aanmaak en geldigheid.
Structuur
De Attestation struct vertegenwoordigt een attestatie in het Solana Attestation System. Elke attestatie verwijst naar een credential, schema en bevat de geattesteerde data samen met metadata over de aanmaak en geldigheidsperiode.
Typedefinities
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;};
Methoden
Attestaties Ophalen
| Methode | Beschrijving | Parameters | Retourneert |
|---|---|---|---|
fetchAttestation | Haalt een enkele attestatie op via zijn adres | rpc: RPC-context, address: Adres van attestatie, config?: Ophalingsconfiguratie | Promise<Account<Attestation>> |
fetchMaybeAttestation | Haalt veilig een attestatie op, retourneert null indien niet gevonden | rpc: RPC-context, address: Adres van attestatie, config?: Ophalingsconfiguratie | Promise<MaybeAccount<Attestation>> |
fetchAllAttestation | Haalt meerdere attestaties op via hun adressen | rpc: RPC-context, addresses: Array van attestatieadressen, config?: Ophalingsconfiguratie | Promise<Account<Attestation>[]> |
fetchAllMaybeAttestation | Haalt veilig meerdere attestaties op, slaat niet-gevonden over | rpc: RPC-context, addresses: Array van attestatieadressen, config?: Ophalingsconfiguratie | Promise<MaybeAccount<Attestation>[]> |
Serialisatie
| Methode | Beschrijving | Parameters | Retourneert |
|---|---|---|---|
getAttestationEncoder | Krijgt de encoder voor attestatiedata | Geen | Encoder<AttestationArgs> |
getAttestationDecoder | Krijgt de decoder voor attestatiedata | Geen | Decoder<Attestation> |
getAttestationCodec | Krijgt de codec voor attestatiedata | Geen | Codec<AttestationArgs, Attestation> |
Gebruiksvoorbeelden
Eén attestatie ophalen
const attestation = await fetchAttestation(rpc, attestationAddress);console.log("Attestation nonce:", attestation.nonce);
Meerdere attestaties ophalen
const attestations = await fetchAllAttestation(rpc, [attestation1Address,attestation2Address]);attestations.forEach((attestation) =>console.log("Attestation:", attestation.nonce));
Veilig ophalen
const attestation = await fetchMaybeAttestation(rpc, attestationAddress);if (attestation) {console.log("Attestation found:", attestation.nonce);} else {console.log("Attestation not found");}
Belangrijke opmerkingen
- Het veld
discriminatorwordt intern gebruikt en mag niet worden gewijzigd - Het veld
noncebiedt een unieke identificatie voor elke attestatie - De velden
credentialenschemakoppelen de attestatie aan de bijbehorende credential en het schema - Het veld
databevat de daadwerkelijke attestatiegegevens en moet correct worden gecodeerd/gedecodeerd volgens het schema signermoet een van de geautoriseerde ondertekenaars zijn van de bijbehorende credentialexpirybepaalt wanneer de attestatie ongeldig wordttokenAccountkoppelt de attestatie aan een specifiek token account- Attestaties kunnen alleen worden aangemaakt door geautoriseerde ondertekenaars van de bijbehorende credential
- De attestatiegegevens moeten voldoen aan de structuur die is gedefinieerd door het bijbehorende schema
Is this page helpful?