Credentials

Attestation authorities in the Solana Attestation System

Credentials

A credential represents an attestation authority in the Solana Attestation System. Credentials define who can issue attestations and what types of attestations they can issue. Each credential has a set of authorized signers who can create attestations under its authority.

Structure

The Credential struct represents a credential in the Solana Attestation System. Each credential defines an authority that can issue attestations and the signers authorized to do so.

Type Definitions

Credential

export type Credential = {
    discriminator: number;           // Internal discriminator
    authority: Address;              // Authority public key
    name: ReadonlyUint8Array;       // Credential name
    authorizedSigners: Array<Address>; // List of authorized signers
};

Methods

Fetching Credentials

MethodDescriptionParametersReturns
fetchCredentialFetches a single credential by its addressrpc: RPC context, address: Credential's address, config?: Fetch configPromise<Account<Credential>>
fetchMaybeCredentialSafely fetches a credential, returns null if not foundrpc: RPC context, address: Credential's address, config?: Fetch configPromise<MaybeAccount<Credential>>
fetchAllCredentialFetches multiple credentials by their addressesrpc: RPC context, addresses: Array of credential addresses, config?: Fetch configPromise<Account<Credential>[]>
fetchAllMaybeCredentialSafely fetches multiple credentials, skips not foundrpc: RPC context, addresses: Array of credential addresses, config?: Fetch configPromise<MaybeAccount<Credential>[]>

Serialization

MethodDescriptionParametersReturns
getCredentialEncoderGets the encoder for credential dataNoneEncoder<CredentialArgs>
getCredentialDecoderGets the decoder for credential dataNoneDecoder<Credential>
getCredentialCodecGets the codec for credential dataNoneCodec<CredentialArgs, Credential>

Usage Examples

Fetching a Single Credential

const credential = await fetchCredential(rpc, credentialAddress);
console.log('Credential name:', credential.name);

Fetching Multiple Credentials

const credentials = await fetchAllCredential(rpc, [credential1Address, credential2Address]);
credentials.forEach(credential => console.log('Credential:', credential.name));

Safe Fetching

const credential = await fetchMaybeCredential(rpc, credentialAddress);
if (credential) {
    console.log('Credential found:', credential.name);
} else {
    console.log('Credential not found');
}

Important Notes

  • The discriminator field is used internally and should not be modified
  • The authority field determines who has control over the credential
  • authorizedSigners is an array of addresses that are allowed to create attestations under this credential
  • The name field is stored as a byte array and should be properly encoded/decoded according to your application's needs
  • Only authorized signers can create attestations under a credential
  • The authority can modify the list of authorized signers