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 discriminatorauthority: Address; // Authority public keyname: ReadonlyUint8Array; // Credential nameauthorizedSigners: Array<Address>; // List of authorized signers};
Methods
Fetching Credentials
| Method | Description | Parameters | Returns |
|---|---|---|---|
fetchCredential | Fetches a single credential by its address | rpc: RPC context, address: Credential's address, config?: Fetch config | Promise<Account<Credential>> |
fetchMaybeCredential | Safely fetches a credential, returns null if not found | rpc: RPC context, address: Credential's address, config?: Fetch config | Promise<MaybeAccount<Credential>> |
fetchAllCredential | Fetches multiple credentials by their addresses | rpc: RPC context, addresses: Array of credential addresses, config?: Fetch config | Promise<Account<Credential>[]> |
fetchAllMaybeCredential | Safely fetches multiple credentials, skips not found | rpc: RPC context, addresses: Array of credential addresses, config?: Fetch config | Promise<MaybeAccount<Credential>[]> |
Serialization
| Method | Description | Parameters | Returns |
|---|---|---|---|
getCredentialEncoder | Gets the encoder for credential data | None | Encoder<CredentialArgs> |
getCredentialDecoder | Gets the decoder for credential data | None | Decoder<Credential> |
getCredentialCodec | Gets the codec for credential data | None | Codec<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
discriminatorfield is used internally and should not be modified - The
authorityfield determines who has control over the credential authorizedSignersis an array of addresses that are allowed to create attestations under this credential- The
namefield 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
Is this page helpful?