Skip to main content

Logic Context - JS/TS

A logic context object would be passed to LOC logic during execution, which contains the following important data:

  • Task and execution metadata
  • Trigger payload
Logic TypeAvailable
Generic logic✅
Aggregator logic✅

Import and Usage​

The run and handleError function in a logic, which will be invoked by LOC runtime during execution, should receive a ctx argument:

/** @param {import('@fstnetwork/loc-logic-sdk').GenericContext} ctx */
export async function run(ctx) {
// ctx is the data context
}

/**
* @param {import('@fstnetwork/loc-logic-sdk').GenericContext} ctx
* @param {import('@fstnetwork/loc-logic-sdk').RailwayError} error
*/
export async function handleError(ctx, error) {
// ctx is the data context
}

For the error argument, see Logic Error for details.

Class Reference​

Type​

Logic TypeContext Type
GenericGenericContext
AggregatorAggregatorContext

Both importable from @fstnetwork/loc-logic-sdk

Properties​

PropertyTypeDescription
taskTaskReturn the Task object (lazy loaded)

Refer to: Task

Method: Load Payload​

async payload(): Promise<Payload>

Return the trigger payload (lazy loaded).

Refer to: Payload

Examples​

// get task and execution metadata
const task = ctx.task;

// get payload
const payload = await ctx.payload();