Attestaties

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 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;
};

Methoden

Attestaties Ophalen

MethodeBeschrijvingParametersRetourneert
fetchAttestationHaalt een enkele attestatie op via zijn adresrpc: RPC-context, address: Adres van attestatie, config?: OphalingsconfiguratiePromise<Account<Attestation>>
fetchMaybeAttestationHaalt veilig een attestatie op, retourneert null indien niet gevondenrpc: RPC-context, address: Adres van attestatie, config?: OphalingsconfiguratiePromise<MaybeAccount<Attestation>>
fetchAllAttestationHaalt meerdere attestaties op via hun adressenrpc: RPC-context, addresses: Array van attestatieadressen, config?: OphalingsconfiguratiePromise<Account<Attestation>[]>
fetchAllMaybeAttestationHaalt veilig meerdere attestaties op, slaat niet-gevonden overrpc: RPC-context, addresses: Array van attestatieadressen, config?: OphalingsconfiguratiePromise<MaybeAccount<Attestation>[]>

Serialisatie

MethodeBeschrijvingParametersRetourneert
getAttestationEncoderKrijgt de encoder voor attestatiedataGeenEncoder<AttestationArgs>
getAttestationDecoderKrijgt de decoder voor attestatiedataGeenDecoder<Attestation>
getAttestationCodecKrijgt de codec voor attestatiedataGeenCodec<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 discriminator wordt intern gebruikt en mag niet worden gewijzigd
  • Het veld nonce biedt een unieke identificatie voor elke attestatie
  • De velden credential en schema koppelen de attestatie aan de bijbehorende credential en het schema
  • Het veld data bevat de daadwerkelijke attestatiegegevens en moet correct worden gecodeerd/gedecodeerd volgens het schema
  • signer moet een van de geautoriseerde ondertekenaars zijn van de bijbehorende credential
  • expiry bepaalt wanneer de attestatie ongeldig wordt
  • tokenAccount koppelt 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?

Inhoudsopgave

Pagina Bewerken
© 2026 Solana Foundation. Alle rechten voorbehouden.