Skip to content

Record

A record is an instance of a class. It is created under a class and contains the data for that record.

Structure

The Record struct represents a record in the Solana Record System. Each record contains metadata and data associated with a specific class.

Type Definitions

RecordAccountDataArgs

export type RecordAccountDataArgs = {
    class: PublicKey;         // Class public key
    owner: PublicKey;         // Owner public key
    isFrozen: boolean;        // Frozen status
    expiry: number | bigint;  // Expiry timestamp
    name: string;            // Record name
    data: string;            // Record data
};

Methods

Fetching Records

MethodDescriptionParametersReturns
fetchRecordFetches a single record by its public keycontext: RPC context, publicKey: Record's public key, options?: RPC optionsPromise<Record>
safeFetchRecordSafely fetches a record, returns null if not foundcontext: RPC context, publicKey: Record's public key, options?: RPC optionsPromise<Record | null>
fetchAllRecordFetches multiple records by their public keyscontext: RPC context, publicKeys: Array of record public keys, options?: RPC optionsPromise<Record[]>
safeFetchAllRecordSafely fetches multiple records, skips not foundcontext: RPC context, publicKeys: Array of record public keys, options?: RPC optionsPromise<Record[]>

Serialization

MethodDescriptionParametersReturns
getRecordAccountDataSerializerGets the serializer for record account dataNoneSerializer<RecordAccountDataArgs, RecordAccountData>
deserializeRecordDeserializes raw account data into a RecordrawAccount: Raw RPC account dataRecord

Program Interaction

MethodDescriptionParametersReturns
getRecordGpaBuilderGets a GPA builder for querying recordscontext: RPC and programs contextGpaBuilder<Record, {...}>

Usage Examples

Fetching a Single Record

const record = await fetchRecord(rpc, recordPublicKey);
console.log('Record data:', record.data);

Fetching Multiple Records

const records = await fetchAllRecord(rpc, [record1PublicKey, record2PublicKey]);
records.forEach(record => console.log('Record:', record.name));

Safe Fetching

const record = await safeFetchRecord(rpc, recordPublicKey);
if (record) {
    console.log('Record found:', record.name);
} else {
    console.log('Record not found');
}

Using GPA Builder

const gpaBuilder = getRecordGpaBuilder(context);
const records = await gpaBuilder
    .where('class', classPublicKey)
    .get();

Important Notes

  • All timestamps are stored as bigint values
  • The discriminator field is used internally and should not be modified
  • The ownerType field determines the type of entity that owns the record
  • Records can be frozen to prevent modifications
  • The data field contains serialized data that must be deserialized according to the class schema