Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

https-outcalls

БесплатноБез исполняемых скриптовНе проверен

Make HTTPS requests from canisters to external web APIs. Covers replicated, non-replicated and flexible outcalls, transform functions for consensus, both…

jiayaoqijiaот jiayaoqijia★ 81 звезда на GitHub

Об этом скилле

HTTPS Outcalls

What This Is

HTTPS outcalls allow canisters to make HTTP requests to external web services directly from on-chain code. In the default replicated mode, every node on the subnet makes the same request and all of them must agree on the response. A transform function strips non-deterministic fields (timestamps, request IDs, ordering) so that every replica sees an identical response and can reach consensus.

Two other modes avoid that agreement step: non-replicated (is_replicated = false, one node makes the request) and flexible (flexible_http_request, a committee of nodes return their individual responses). See Outcall modes.

Support matrix

Rust Motoko
Package ic-cdk 0.20.3+ with ic-cdk-management-canister 0.2+ ic 6.x (mops), which requires core 2.5.0+ and moc 2.1.0+
Entry point HttpRequest::new(url) builder, .send() Call.httpRequest(url) builder, .send()
Pricing version 1 (legacy) only by pinning ic-cdk-management-canister 0.1, or calling aaaaa-aa directly with ic_cdk::api::cost_http_request only by pinning ic 4.x or 5.x, or calling aaaaa-aa directly with Prim.costHttpRequest
Pricing version 2 (pay-as-you-go) yes, the builder always selects it yes, the builder always selects it
flexible_http_request yes, FlexibleHttpRequest::new(url) yes, Call.flexibleHttpRequest(url)
subnet_self_node_count ic_cdk::api::subnet_self_node_count() Prim.subnetSelfNodeCount() (via import Prim "mo:⛔")

Read this before writing code; what is available depends on the language and the dependency versions in the project. Both languages reach the same outcall surface, through a builder that selects version 2 and computes the cycles to attach, but only on recent dependencies. On ic 4.x or 5.x Motoko is still version 1: 4.x HttpRequestArgs has no pricing_version field at all, Candid omits the absent optional, and the replica reads it as version 1, which is exactly what that Call.httpRequest funds. The builder and flexible_http_request arrive in 6.0.0, which requires moc 2.1.0 for the costHttpRequestV2 primitive it calls.

For Rust the right code depends on which of three worlds the project is in. ic-cdk 0.19 has ic_cdk::management_canister::http_request(&args) (version 1; the module was removed in 0.20). ic-cdk 0.20 with ic-cdk-management-canister 0.1 has ic_cdk_management_canister::http_request(&args) (version 1). ic-cdk 0.20.3+ with ic-cdk-management-canister 0.2 has the builders, and is version 2 only: 0.2.0 removed the free http_request and the builder hard-codes pricing_version: Some(2) with no opt-out, so upgrading the crate is the migration. Rust also needs serde_json for JSON parsing.

Which version to write. Version 1 is deprecated and version 2 is the direction, so new Rust code should use the 0.2 builders. But do not bump a project's pinned versions in order to migrate it as a side effect of an unrelated task: 0.2 is a breaking change (it deletes the free http_request and HttpRequestArgs gains a required field), so the upgrade is the caller's decision. Write correct code for the line the project is actually on, and tell them the upgrade exists.

Canister IDs

HTTPS outcalls use the IC management canister:

Name Canister ID Used For
Management canister aaaaa-aa The http_request and flexible_http_request management call targets

You do not deploy anything extra. The management canister is built into every subnet.

Mistakes That Break Your Build

  1. Forgetting the transform function. In replicated mode, without a transform the raw HTTP response often differs between replicas (different headers, different ordering in JSON fields, timestamps). Consensus fails and the call is rejected. ALWAYS provide one there. In non-replicated and flexible mode it is optional for consensus, because each node's own response is delivered. Whether to set one there is a tradeoff. No transform reserves nothing for it (the instruction term defaults to 0, not to the query limit), which is the cheapest configuration available. Adding one defaults that term to the full query limit, so you must also declare with_expected_transform_instructions. What it buys back is the delivery fee, charged per byte on the transformed size: every byte stripped lowers the bill, so what decides it is how much there is worth stripping (bulky headers yes, a response that is already mostly payload no). The reservation floors that term at about 1 KB, so get_cost() understates the saving on a small response. Two non-cycle reasons can decide it anyway: in flexible mode the combined 2 MiB budget is measured after the transform, so smaller responses mean fewer get dropped, and reconciling is impossible if p
Полный SKILL.md на GitHub

Установить https-outcalls в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

LICENSESOURCE.mdTRUST.auto.yamlreferences/flexible-outcalls.mdreferences/json-responses.mdreferences/pricing-version-2.md

FAQ

Что делает скилл https-outcalls?

Make HTTPS requests from canisters to external web APIs. Covers replicated, non-replicated and flexible outcalls, transform functions for consensus, both cycle pricing versions (legacy and pay-as-you-go via ic0.cost_http_request_v2), response size limits, and idempotency patterns. Use when a canister needs to call an external API, fetch data from the web, make HTTP requests, choose a pricing_version, or use flexible_http_request. Do NOT use for EVM/Ethereum calls — use evm-rpc instead.

Как установить скилл https-outcalls?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл https-outcalls запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить https-outcalls с