Skip to main content
The ActionCode class represents an action code in the Action Codes Protocol. It encapsulates all the data and logic for a single action code, including its status, metadata, transaction details, and utility methods for validation and display.

Type Definitions

ActionCodeStatus

Represents the status of an action code.

ActionCodeMetadata

Metadata for the action code, including an optional description and parameters.

ActionCodeTransaction

Represents transaction or message data attached to an action code.

ActionCodeFields

All fields required to construct an ActionCode instance.

ActionCode Class

Constructor

Creates a new ActionCode instance from the provided fields.

Static Methods

fromPayload

Creates an ActionCode from a plain object. Throws if required fields are missing.

fromEncoded

Creates an ActionCode from a base64-encoded string.

Instance Properties & Methods

encoded

Returns a base64-encoded string of the action code fields.

isValid

Checks if the action code is valid for the given protocol (signature, code format, not expired).

updateStatus

Updates the status of the action code.

json

Returns the raw fields as a plain object.

remainingTime

Milliseconds remaining until expiration (0 if expired).

expired

Returns true if the code is expired.

chain

Returns the chain identifier (e.g., ‘solana’).

status

Returns the current status of the action code.

code

Returns the 8-character action code string.

prefix

Returns the normalized prefix for the code.

pubkey

Returns the user’s public key.

transaction

Returns the transaction data, if any.

metadata

Returns the metadata object, if any.

description

Returns the human-readable description from metadata.

params

Returns the parameters from metadata.

timestamp

Returns the timestamp when the code was generated.

signature

Returns the user’s signature string.

displayString

Returns a formatted string for display (e.g., “PREFIX-XXXXXX (solana, pending)“).

remainingTimeString

Returns a human-readable string for remaining time (e.g., “1m 30s remaining” or “Expired”).

codeHash

Returns the code hash (used as code ID in protocol meta).

intentType

Returns the intent type for the action code.

Example