Skip to main content
A comprehensive overview of the methods available in the Action Codes SDK for interacting with the Action Codes Protocol.

Table of Contents


Overview

The Action Codes SDK provides a set of methods to interact with the Action Codes Protocol, enabling you to register, resolve, attach, and finalize action codes on Solana.

Method Reference

resolve

Resolves an action code and returns its details. Parameters:
  • code (string): The code to resolve.
Returns: Promise<ActionCode> (see ActionCode)

getStatus

Fetches the status of an action code. Parameters:
  • code (string): The code to check.
Returns: Promise<ActionCodeStatusResponse> (see ActionCodeStatusResponse)

observeStatus

Observes the status of an action code over time. Parameters:
  • code (string): The code to observe.
  • options (object): { interval?: number, timeout?: number } (see ObserveStatusOptions)
Returns: AsyncGenerator<ActionCodeStatusResponse> (see ActionCodeStatusResponse)

register

Registers a new action code. Parameters:
  • pubkey (PublicKey): User’s public key.
  • sign (function): Function to sign a message.
  • metadata (object, optional): Additional metadata (see ActionCodeMeta).
Returns: Promise<ActionCode> (see ActionCode)

attachTransaction

Attaches a transaction to an action code. Parameters:
  • code (string): The code to attach to.
  • transaction (string): The transaction data.
  • meta (object, optional): Additional metadata (see ActionCodeMeta).
Returns: Promise<AttachCodeResponse> (see AttachCodeResponse)

attachMessage

Attaches a message to an action code. Parameters:
  • code (string): The code to attach to.
  • message (string): The message to attach.
  • meta (object, optional): Additional metadata (see ActionCodeMeta).
Returns: Promise<AttachCodeResponse> (see AttachCodeResponse)

finalizeTransaction

Finalizes an action code with a transaction signature. Parameters:
  • code (string): The code to finalize.
  • signature (string): The transaction signature.
Returns: Promise<FinalizeCodeResponse> (see FinalizeCodeResponse)

finalizeMessage

Finalizes an action code with a signed message. Parameters:
  • code (string): The code to finalize.
  • signedMessage (string): The signed message.
Returns: Promise<FinalizeCodeResponse> (see FinalizeCodeResponse)

Error Handling

The SDK throws custom errors for various failure scenarios:
  • CodeNotFoundError: The code does not exist.
  • UnauthorizedError: The request is unauthorized.
  • ExpiredCodeError: The code has expired.
  • ActionCodesBaseError: Base error for ActionCodes.
  • InvalidCodeFormatError: The code format is invalid.

Examples

Register and Attach a Transaction

Observe Status

Finalize a Transaction