Action Codes SDK
The official JavaScript/TypeScript SDK for integrating Action Codes into any app — frontend, backend, or edge.
📦 Installation
npm install @actioncodes/sdk
⚡️ Quick Start
import { ActionCodesClient } from '@actioncodes/sdk';
const client = new ActionCodesClient();
const observeStatus = await client.submitAction('12345678',
action: {
label: 'Test Action',
logo: 'https://ota.codes/logo.png',
memo: 'gm!',
message: 'Transfer SOL',
transactionBase64: '...', // your transaction in base64 format
},
);
for await (const status of observeStatus) {
console.log('Status updated:', status);
}
📚 SDK Reference
Below are the core methods and types exposed by the ActionCodesClient
class.
Constructor
const client = new ActionCodesClient(baseUrl?: string);
Initializes a new ActionCodes client. The optional baseUrl
can be used to override the default API endpoint.
client.getAction(code)
Resolves and decrypts the action metadata for a given code.
Param | Type | Description |
---|---|---|
code | string | The 8-digit Action Code |
client.getActionStatus(code)
Fetches the latest status of a submitted action.
client.submitAction(code, fields)
Submits an action with partial metadata. Returns an async generator to track the status in real time.
Param | Type | Description |
---|---|---|
code | string | The Action Code |
fields | Partial<ActionPayload> | Action metadata (label, message, transactionBase64, etc) |
client.observeActionStatus(code)
Returns an async generator that emits status updates for the given code.
Types
ActionStatus
: 'pending' | 'ready' | 'failed' | 'cancelled'ActionFields
: Full metadata about the action (label, memo, logo, etc.)ActionPayload
: Submit-safe subset of fieldsSubmitResponse
: { success: boolean; status: ActionStatus; expiresAt: string }