Solaris AISolaris AI FlowDocs
Node ReferenceUtility

Code

Run custom JavaScript against upstream workflow data.

View as Markdown

The Code node runs small JavaScript transformations in a sandbox and passes the returned value downstream. Use it when the Transform node's visual pipeline is not expressive enough for custom math, grouping, reducing arrays, or normalizing inconsistent nested data.

Code nodes are synchronous. They can read upstream data through $input and must return a JSON-serializable value.

Configuration

FieldTypeRequiredDescription
JavaScriptstringYesCode to run. Use $input to read upstream node outputs and return the downstream value
Timeout (ms)numberNoExecution deadline. Values are clamped between 100 and 10000 ms
Output VariablestringNoName used by downstream nodes. Defaults to codeResponse
Node LabelstringNoDisplay name shown on the canvas

How it works

  1. Upstream node outputs are collected into $input
  2. Your JavaScript runs in a sandboxed QuickJS runtime
  3. The returned value is saved as this node's output
  4. Downstream nodes reference it through the configured output variable

The sandbox does not provide host APIs such as fetch, process, filesystem access, npm imports, or timers. Use integration nodes for network calls and the Code node for data shaping.

Working with $input

The node settings Input pane shows the upstream sample passed to $input. Click a value in the Input pane while the JavaScript editor is focused to insert the matching $input access at the cursor.

Examples:

$input.pumpfunResponse.data[0].symbol
$input["price-feed"].data.value

The Input pane also includes JSON, Schema, and Table views when you need exact inspection instead of the default Variables browser.

Example: rank Pump.fun top tokens

Workflow:

Manual Trigger → Pump.fun getTopRunners → Code → Telegram

Set the Pump.fun node output variable to pumpfunResponse. Then add this Code node:

const tokens = Array.isArray($input.pumpfunResponse?.data)
  ? $input.pumpfunResponse.data
  : [];

const ranked = tokens
  .filter((token) => {
    return (
      token.mint &&
      token.name &&
      token.symbol &&
      token.priceSol != null &&
      token.bondingProgressPct != null
    );
  })
  .map((token) => ({
    mint: token.mint,
    name: token.name,
    symbol: token.symbol,
    priceSol: token.priceSol,
    bondingProgressPct: token.bondingProgressPct,
    score:
      Number(token.bondingProgressPct) * 2 + Number(token.priceSol) * 100000,
  }))
  .sort((a, b) => b.score - a.score)
  .slice(0, 5);

return {
  count: ranked.length,
  tokens: ranked,
};

If the Code node output variable is rankedTokens, a downstream Telegram or Discord node can use:

Top Pump.fun runner: {rankedTokens.data.tokens[0].symbol}
Mint: {rankedTokens.data.tokens[0].mint}
Progress: {rankedTokens.data.tokens[0].bondingProgressPct}%

Output

A successful Code node returns:

{
  "success": true,
  "data": {
    "count": 5,
    "tokens": []
  }
}

Downstream nodes reference the returned value under .data:

{codeResponse.data}
{codeResponse.data.tokens[0].symbol}

If you set Output Variable to rankedTokens, use:

{rankedTokens.data.tokens[0].symbol}

Previewing

Code settings use the shared node-settings layout:

  • Input shows upstream sample data available as $input.
  • Parameters contains the JavaScript editor, timeout, output variable, and node label.
  • Output shows a Live preview for the current draft and a Last tab for the most recent persisted run output.

The Live preview runs your draft code in the same QuickJS sandbox used by workflow execution, using the current upstream sample. It is for inspection while editing; execute the node or workflow to persist a last-run output.

If the Code node has no input sample, use the Input pane button to execute previous nodes. This runs previous nodes and uses their latest outputs as preview data. Preview runs count as monthly runs and are hidden from normal execution history. If upstream nodes can send messages, transfer funds, trade, or broadcast transactions, the editor asks for confirmation before firing them.

Limits

LimitValue
Timeout100-10000 ms
Memory16 MB
Stack1 MB
Output size5 MB

The returned value must be JSON-serializable. Returning functions, symbols, circular objects, or unsupported values causes the node to fail.

When to use Code vs Transform

Use Transform when your data change fits the visual pipeline:

  • Filter, sort, and slice arrays
  • Keep, drop, or rename fields
  • Add fixed fields
  • Add template-derived fields
  • Compute age from timestamps

Use Code when you need arbitrary JavaScript logic:

  • Custom scoring or math
  • Grouping or reducing arrays
  • Normalizing inconsistent API shapes
  • Handling branching data structures that do not fit the visual steps
  • Building a custom object for alerts or downstream trades

Next steps

On this page