Skip to content

Update Record

Updates the data of an existing record while preserving its ownership and other properties.

Parameters

ParameterTypeDescription
authoritySignerThe record owner or class authority (for permissioned classes)
recordPublicKey | PdaThe record account to be updated
systemProgram?PublicKey | PdaOptional System Program account
class?PublicKey | PdaOptional class account of the record
datastringNew serialized data for the record

Returns

Returns a TransactionBuilder that can be used to build and send the transaction.

Example

import { updateRecord } from "srs-lib";
 
const transaction = updateRecord(context, {
    authority: authority,
    record: recordPublicKey,
    systemProgram: systemProgramPublicKey,
    class: classPublicKey, // Optional, but recommended for permissioned classes
    data: JSON.stringify({
        title: "Updated Record Title",
        description: "Updated record description",
        // Additional data fields conforming to the class schema
    })
});
 
// Send the transaction
await transaction.sendAndConfirm();

Important Notes

  • The authority must be either the record owner or the class authority (for permissioned classes)
  • The record must not be frozen
  • The new data must conform to the schema defined in the record's class
  • The data must be properly serialized
  • The record's ownership and expiration remain unchanged
  • For permissioned classes, providing the class account is recommended to ensure proper authority verification
  • This operation can be performed multiple times
  • The data update is permanent and cannot be undone

Related