Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 0 additions & 127 deletions reports/llms-report.json

This file was deleted.

9 changes: 6 additions & 3 deletions src/content/chainlink-local/llms-full.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8573,7 +8573,10 @@ does not persist the files that you open from an external source. To save files,
/// @notice Constructor initializes the contract with the router address.
/// @param _router The address of the router contract.
/// @param _link The address of the link contract.
constructor(address _router, address _link) {
constructor(
address _router,
address _link
) {
s_router = IRouterClient(_router);
s_linkToken = LinkTokenInterface(_link);
}
Expand Down Expand Up @@ -8603,8 +8606,8 @@ does not persist the files that you open from an external source. To save files,
Client.GenericExtraArgsV2({
gasLimit: 200_000, // Gas limit for the callback on the destination chain
allowOutOfOrderExecution: true // Allows the message to be executed out of order relative to other messages
// from
// the same sender
// from
// the same sender
})
),
// Set the feeToken address, indicating LINK will be used for fees
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
cre.handler(
handler(
cronTrigger.trigger({ schedule: "0 */10 * * * *" }), // trigger fires every 10 minutes
onCronTrigger // your callback function
)

function onCronTrigger(runtime: Runtime<Config>): Record<string, never> {

Check warning on line 6 in src/content/cre/code-snippets/index-trigger-callback-example.ts

View workflow job for this annotation

GitHub Actions / eslint

'runtime' is defined but never used

Check warning on line 6 in src/content/cre/code-snippets/index-trigger-callback-example.ts

View workflow job for this annotation

GitHub Actions / eslint

'runtime' is defined but never used
// Create SDK clients and call capabilities
return {}
}
16 changes: 8 additions & 8 deletions src/content/cre/concepts/non-determinism-ts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ date: Last Modified
metadata:
description: "Learn how to avoid non-deterministic behaviors in CRE TypeScript workflows that prevent nodes from reaching consensus."
datePublished: "2025-11-04"
lastModified: "2025-11-04"
lastModified: "2026-01-20"
---

import { Aside } from "@components"
Expand Down Expand Up @@ -45,7 +45,7 @@ const obj = { b: 2, a: 1 }

// Order may vary across runtimes or serialization
for (const key in obj) {
console.log(key) // Could be "b", "a" or "a", "b"
// key could be "b", "a" or "a", "b" — non-deterministic!
}
```

Expand All @@ -56,7 +56,7 @@ const obj = { b: 2, a: 1 }

// Preserves insertion order
for (const key of Object.keys(obj)) {
console.log(key, obj[key]) // "b", "a" (insertion order)
// key order: "b", "a" (insertion order)
}
```

Expand All @@ -67,7 +67,7 @@ const obj = { b: 2, a: 1 }

// Guaranteed alphabetical order
for (const key of Object.keys(obj).sort()) {
console.log(key, obj[key]) // "a", "b" (alphabetically sorted)
// key order: "a", "b" (alphabetically sorted)
}
```

Expand All @@ -83,7 +83,7 @@ map.set("b", 2)
map.set("a", 1)

for (const [key, value] of map) {
console.log(key, value) // Always "b", then "a"
// Order: ["b", 2], then ["a", 1] — guaranteed
}
```

Expand All @@ -93,7 +93,7 @@ for (const [key, value] of map) {
const set = new Set(["b", "a"])

for (const value of set) {
console.log(value) // Always "b", then "a"
// Order: "b", then "a" — guaranteed
}
```

Expand Down Expand Up @@ -125,11 +125,11 @@ const firstSuccess = await Promise.any([fetchFromAPI1(), fetchFromAPI2()])
**Good: Deterministic order with `.result()`**

```typescript
import { cre, type Runtime, type NodeRuntime, consensusMedianAggregation } from "@chainlink/cre-sdk"
import { HTTPClient, type Runtime, type NodeRuntime, consensusMedianAggregation } from "@chainlink/cre-sdk"

// Fetch from API 1, then API 2, in a fixed order
const fetchPrice = (nodeRuntime: NodeRuntime<Config>): bigint => {
const httpClient = new cre.capabilities.HTTPClient()
const httpClient = new HTTPClient()

// Try first API
const response1 = httpClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pageId: "getting-started-part-1"
metadata:
description: "Getting started Part 1 (TypeScript): set up your first CRE project, explore the structure, and run a successful workflow simulation."
datePublished: "2025-11-04"
lastModified: "2026-01-14"
lastModified: "2026-01-20"
---

import { Aside, CopyText, CodeHighlightBlock } from "@components"
Expand Down Expand Up @@ -160,6 +160,12 @@ Open `onchain-calculator/my-calculator-workflow/main.ts` to see its contents:
- **`initWorkflow`**: Creates the workflow by registering handlers (trigger-callback pairs). This is where you define what events your workflow responds to.
- **`main`**: The entry point that creates a `Runner`, passes your config type, and runs the workflow.

<Aside type="note" title="Automatic execution">
You don't need to call `main()` at the end of your file—the SDK automatically executes it during compilation. The SDK
also handles error reporting automatically, so you don't need to add `.catch()` unless you need custom error handling.
See the [Core SDK Reference](/cre/reference/sdk/core-ts#main) for details.
</Aside>

## Step 4: Configure your workflow

Now that you've explored the generated files, let's configure your workflow for simulation. You'll need to adjust a few configuration files.
Expand Down
6 changes: 3 additions & 3 deletions src/content/cre/getting-started/snippets/part-1-main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cre, Runner, type Runtime } from "@chainlink/cre-sdk"
import { CronCapability, handler, Runner, type Runtime } from "@chainlink/cre-sdk"

type Config = {
schedule: string
Expand All @@ -10,9 +10,9 @@ const onCronTrigger = (runtime: Runtime<Config>): string => {
}

const initWorkflow = (config: Config) => {
const cron = new cre.capabilities.CronCapability()
const cron = new CronCapability()

return [cre.handler(cron.trigger({ schedule: config.schedule }), onCronTrigger)]
return [handler(cron.trigger({ schedule: config.schedule }), onCronTrigger)]
}

export async function main() {
Expand Down
16 changes: 12 additions & 4 deletions src/content/cre/getting-started/snippets/part-2-main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import { cre, consensusMedianAggregation, Runner, type NodeRuntime, type Runtime } from "@chainlink/cre-sdk"
import {
CronCapability,
HTTPClient,
handler,
consensusMedianAggregation,
Runner,
type NodeRuntime,
type Runtime,
} from "@chainlink/cre-sdk"

type Config = {
schedule: string
Expand All @@ -10,15 +18,15 @@ type MyResult = {
}

const initWorkflow = (config: Config) => {
const cron = new cre.capabilities.CronCapability()
const cron = new CronCapability()

return [cre.handler(cron.trigger({ schedule: config.schedule }), onCronTrigger)]
return [handler(cron.trigger({ schedule: config.schedule }), onCronTrigger)]
}

// fetchMathResult is the function passed to the runInNodeMode helper.
// It contains the logic for making the request and parsing the response.
const fetchMathResult = (nodeRuntime: NodeRuntime<Config>): bigint => {
const httpClient = new cre.capabilities.HTTPClient()
const httpClient = new HTTPClient()

const req = {
url: nodeRuntime.config.apiUrl,
Expand Down
13 changes: 8 additions & 5 deletions src/content/cre/getting-started/snippets/part-3-main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {
cre,
CronCapability,
HTTPClient,
EVMClient,
handler,
consensusMedianAggregation,
Runner,
type NodeRuntime,
Expand Down Expand Up @@ -31,14 +34,14 @@ type MyResult = {
}

const initWorkflow = (config: Config) => {
const cron = new cre.capabilities.CronCapability()
const cron = new CronCapability()

return [cre.handler(cron.trigger({ schedule: config.schedule }), onCronTrigger)]
return [handler(cron.trigger({ schedule: config.schedule }), onCronTrigger)]
}

// fetchMathResult is the function passed to the runInNodeMode helper.
const fetchMathResult = (nodeRuntime: NodeRuntime<Config>): bigint => {
const httpClient = new cre.capabilities.HTTPClient()
const httpClient = new HTTPClient()

const req = {
url: nodeRuntime.config.apiUrl,
Expand Down Expand Up @@ -73,7 +76,7 @@ const onCronTrigger = (runtime: Runtime<Config>): MyResult => {
throw new Error(`Unknown chain name: ${evmConfig.chainName}`)
}

const evmClient = new cre.capabilities.EVMClient(network.chainSelector.selector)
const evmClient = new EVMClient(network.chainSelector.selector)

// Encode the function call using the Storage ABI
const callData = encodeFunctionData({
Expand Down
15 changes: 9 additions & 6 deletions src/content/cre/getting-started/snippets/part-4-main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {
cre,
CronCapability,
HTTPClient,
EVMClient,
handler,
consensusMedianAggregation,
Runner,
type NodeRuntime,
Expand Down Expand Up @@ -37,9 +40,9 @@ type MyResult = {
// highlight-end

const initWorkflow = (config: Config) => {
const cron = new cre.capabilities.CronCapability()
const cron = new CronCapability()

return [cre.handler(cron.trigger({ schedule: config.schedule }), onCronTrigger)]
return [handler(cron.trigger({ schedule: config.schedule }), onCronTrigger)]
}

const onCronTrigger = (runtime: Runtime<Config>): MyResult => {
Expand All @@ -61,7 +64,7 @@ const onCronTrigger = (runtime: Runtime<Config>): MyResult => {
runtime.log(`Successfully fetched offchain value: ${offchainValue}`)

// Step 2: Read onchain data using the EVM client
const evmClient = new cre.capabilities.EVMClient(network.chainSelector.selector)
const evmClient = new EVMClient(network.chainSelector.selector)

const callData = encodeFunctionData({
abi: Storage,
Expand Down Expand Up @@ -120,7 +123,7 @@ const onCronTrigger = (runtime: Runtime<Config>): MyResult => {
// highlight-end

const fetchMathResult = (nodeRuntime: NodeRuntime<Config>): bigint => {
const httpClient = new cre.capabilities.HTTPClient()
const httpClient = new HTTPClient()

const req = {
url: nodeRuntime.config.apiUrl,
Expand All @@ -146,7 +149,7 @@ function updateCalculatorResult(
): string {
runtime.log(`Updating calculator result for consumer: ${evmConfig.calculatorConsumerAddress}`)

const evmClient = new cre.capabilities.EVMClient(chainSelector)
const evmClient = new EVMClient(chainSelector)

// Encode the CalculatorResult struct according to the contract's ABI
const reportData = encodeAbiParameters(
Expand Down
Loading
Loading