Create Attestation

Creates a new attestation under a specific credential and schema

Create Attestation

Creates a new attestation under a specific credential and schema. This instruction allows authorized signers to create attestations that contain verified data and have a defined expiration time.

Parameters

ParameterTypeDescription
payerSignerThe account that will pay for the transaction
authoritySignerThe authorized signer of the credential
credentialPublicKey | PdaThe credential account associated with the schema
schemaPublicKey | PdaThe schema account that defines the attestation structure
attestationPublicKey | PdaThe attestation account to create
systemProgramPublicKey | PdaThe System Program account (defaults to '11111111111111111111111111111111')
nonceAddressA unique identifier for the attestation
dataReadonlyUint8ArrayThe attestation data that must conform to the schema
expirynumber | bigintThe expiration timestamp for the attestation

Returns

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

Example

import { getCreateAttestationInstruction } from "sas-lib";

const transaction = getCreateAttestationInstruction({
    payer: payerSigner,
    authority: authoritySigner,
    credential: credentialPublicKey,
    schema: schemaPublicKey,
    attestation: attestationPublicKey,
    systemProgram: systemProgramPublicKey,
    nonce: noncePublicKey,
    data: attestationData,
    expiry: expiryTimestamp
});

// Send the transaction
await transaction.sendAndConfirm();

Important Notes

  • Only authorized signers of the credential can create attestations
  • The authority must be a signer of the transaction
  • The payer must be a signer of the transaction
  • The attestation account must be writable
  • The credential and schema accounts must be readable
  • This operation requires the System Program for rent exemption calculations
  • The schema must not be paused
  • The data must conform to the schema's structure and validation rules
  • The nonce must be unique for each attestation
  • The expiry timestamp must be in the future
  • The attestation will be invalid after the expiry timestamp
  • The credential must be associated with the schema