diff --git a/src/content/cre/guides/workflow/using-confidential-http-client/making-requests-go.mdx b/src/content/cre/guides/workflow/using-confidential-http-client/making-requests-go.mdx index 6aa8634bc0b..e72fbccb64e 100644 --- a/src/content/cre/guides/workflow/using-confidential-http-client/making-requests-go.mdx +++ b/src/content/cre/guides/workflow/using-confidential-http-client/making-requests-go.mdx @@ -139,6 +139,11 @@ func makeConfidentialRequest(config Config, runtime cre.Runtime) (Result, error) } ``` + + ### Step 5: Wire it into your workflow Call the request function from your trigger handler: diff --git a/src/content/cre/guides/workflow/using-confidential-http-client/making-requests-ts.mdx b/src/content/cre/guides/workflow/using-confidential-http-client/making-requests-ts.mdx index 342279fa336..8326dee76a8 100644 --- a/src/content/cre/guides/workflow/using-confidential-http-client/making-requests-ts.mdx +++ b/src/content/cre/guides/workflow/using-confidential-http-client/making-requests-ts.mdx @@ -117,6 +117,35 @@ const onCronTrigger = (runtime: Runtime): TransactionResult => { } // 3. Parse and return the result + return json(response) as TransactionResult +} +``` + + + +In your trigger handler, call `confHTTPClient.sendRequest()` with your fetch function and a consensus method: + +```typescript +import { + CronCapability, + ConfidentialHTTPClient, + handler, + consensusIdenticalAggregation, + type Runtime, + Runner, +} from "@chainlink/cre-sdk" + +const onCronTrigger = (runtime: Runtime): string => { + const confHTTPClient = new ConfidentialHTTPClient() + + const result = confHTTPClient + .sendRequest(runtime, fetchTransaction, consensusIdenticalAggregation())(runtime.config) + .result() + +======= const result = json(response) as TransactionResult runtime.log(`Transaction result: ${result.transactionId} — ${result.status}`) return result diff --git a/src/content/cre/llms-full-go.txt b/src/content/cre/llms-full-go.txt index 51ac49b58aa..3f93427b279 100644 --- a/src/content/cre/llms-full-go.txt +++ b/src/content/cre/llms-full-go.txt @@ -11383,6 +11383,10 @@ func makeConfidentialRequest(config Config, runtime cre.Runtime) (Result, error) } ``` + + ### Step 5: Wire it into your workflow Call the request function from your trigger handler: diff --git a/src/content/cre/llms-full-ts.txt b/src/content/cre/llms-full-ts.txt index 360ca6d5fbe..0185b315b05 100644 --- a/src/content/cre/llms-full-ts.txt +++ b/src/content/cre/llms-full-ts.txt @@ -10413,6 +10413,41 @@ type TransactionResult = { } ``` +Create the function that will be passed to `sendRequest()`. This function receives a `ConfidentialHTTPSendRequester` and your config as parameters: + +```typescript +import { type ConfidentialHTTPSendRequester, ok, json } from "@chainlink/cre-sdk" + +const fetchTransaction = (sendRequester: ConfidentialHTTPSendRequester, config: Config): TransactionResult => { + // 1. Send the confidential request + const response = sendRequester + .sendRequest({ + request: { + url: config.url, + method: "GET", + multiHeaders: { + Authorization: { values: ["Basic {{.myApiKey}}"] }, + }, + }, + vaultDonSecrets: [{ key: "myApiKey", owner: config.owner }], + }) + .result() + + // 2. Check the response status + if (!ok(response)) { + throw new Error(`HTTP request failed with status: ${response.statusCode}`) + } + + // 3. Parse and return the result + return json(response) as TransactionResult +} +``` + + + + ### Step 4: Implement the request and wire it into your workflow Unlike the regular HTTP client, the Confidential HTTP client takes a `Runtime` directly and does not require `runInNodeMode` wrapping: