Skip to content

Chain format

Every chain is JSON. That’s exactly the JSON you get when you Export, and it’s how the templates are stored in the repository. The format is described as a JSON schema (draft 2020-12): download chain-1.json.

The RSI alert from First alert in three minutes:

rsi-below-30.json
{
"$schema": "https://bellchain.app/schema/chain-1.json",
"name": "BTC RSI below 30",
"version": 1,
"nodes": [
{ "id": "c1", "type": "core.candle", "position": { "x": 40, "y": 40 }, "settings": { "pair": "BTC/USDT", "timeframe": "1h" } },
{ "id": "r1", "type": "core.rsi", "position": { "x": 260, "y": 40 }, "settings": { "length": 14 } },
{ "id": "k1", "type": "core.compare", "position": { "x": 480, "y": 40 }, "settings": { "operator": "below", "value": 30 } },
{ "id": "t1", "type": "core.telegram", "position": { "x": 700, "y": 40 }, "settings": {} }
],
"edges": [
{ "from": "c1.close", "to": "r1.in" },
{ "from": "r1.out", "to": "k1.in" },
{ "from": "k1.out", "to": "t1.in" }
]
}
Field Required Content
$schema reference to the schema, for editors with autocompletion
name yes name of the chain, 1 to 120 characters; appears in messages as {{chain}}
version yes version of the chain format, currently always 1
description free text, up to 2,000 characters
meta details for the template gallery: title and description per language (de, en), tags, author, source
nodes yes the nodes, at most 200
edges yes the connections, at most 1,000

An entry in nodes:

Field Content
id unique within the chain, starts with a letter, no dot, up to 32 characters, such as c1
type node type with namespace, such as core.rsi; the types are listed in the node reference under “Technical details”
position x and y on the board
settings settings as number, text or boolean; Bellchain fills in missing ones with the default

A connection in edges leads from an output to an input, both as node.pin: "from": "c1.close", "to": "r1.in". Growing inputs such as on AND are called in0, in1 and so on.

core.rsi always takes the latest version of a node. If a chain should never change unnoticed, pin the version: core.rsi@1 takes the latest 1.x, core.rsi@1.0.0 exactly this one. If a node’s result changes, its major version goes up.

When loading, importing and testing, Bellchain checks in this order:

  1. structure against the JSON schema
  2. unique ids and known nodes
  3. settings against each node’s description; missing ones are filled in
  4. connections: node and pin exist, types match, every input has at most one connection, no node connected to itself
  5. no loops, the same timeframe for all candles
  6. open required inputs and empty required fields

Point 6 is a note in a draft and an error when you activate. Every message names the location in the JSON, such as /nodes/2/settings/length, in German and English.

Code Means
schema structure doesn’t match the schema
duplicate-node two nodes with the same id
unknown-type unknown node or version not available
unknown-setting, invalid-setting setting doesn’t exist or value is invalid
required-setting required field empty, such as a webhook’s URL
unknown-node, unknown-pin connection points nowhere
type-mismatch pin types don’t match
input-taken input already has a connection
self-loop, cycle node connected to itself, or a loop
required-input, too-few-inputs required input open or too few growing inputs connected
timeframe-mismatch candles with different timeframes