Action lifecycle

This section explains how SDK actions are structured, executed, and managed throughout their lifecycle.


Overview

Actions are the core building blocks of the SDK. Each action represents a multi-step blockchain operation with:

  • Predictable state machine

  • Event-driven progress updates

  • Built-in error handling

  • Retry support without state reset


Action Pattern

All actions follow the same pattern:

  1. Create — Initialize with configuration

  2. Prepare — Validate parameters and check requirements

  3. Authorize — Sign any required messages or transactions

  4. Execute — Perform the main operation

import { createLombardSDK, Chain, AssetId } from '@lombard.finance/sdk';
import { config } from './lib/lombard';

const sdk = createLombardSDK(config);

// 1. Create
const stake = sdk.chain.btc.stake({
  destChain: Chain.ETHEREUM,
  assetOut: AssetId.LBTC,
});

// 2. Prepare
await stake.prepare({
  amount: '0.1',
  recipient: '0x1234567890abcdef1234567890abcdef12345678',
});

// 3. Authorize
await stake.authorize();

// 4. Execute
const result = await stake.generateDepositAddress();
// result: 'bc1q...'

Status States

Actions have a status property that indicates their current state.

BTC Action Status

EVM Operation Status


Orthogonal Properties

Actions have three independent properties:

Property
Type
Description

status

string

Current step in the flow

isLoading

boolean

Whether an async operation is in progress

error

Error

null

These are independent. An action can be in any status with or without an error.


Error Recovery

When an error occurs, the status stays at the step where it happened. This enables retry without resetting state.


Checking Status


Last updated