Works with the AI tools you already use
Chainlink Functions
by Echo Rose
Chainlink Functions - A Premium AI Agent Skill
$7.99
· or 40 creditsSecure checkout via Stripe
About this skill
Chainlink Functions
# Chainlink Functions Builder
Smart contracts are inherently isolated from the outside world. They cannot natively access APIs, execute HTTP requests, or perform complex offchain computation. Traditional oracle solutions require running your own node infrastructure or relying on centralized API proxies that introduce trust assumptions. Chainlink Functions solves this by giving your smart contract a direct, trust-minimized pipeline to any external API or custom computation. Instead of managing oracle infrastructure, you write JavaScript source code that runs on a Decentralized Oracle Network (DON) — every node independently executes your code, and the DON aggregates results via consensus before returning them onchain. The challenge: Functions has complex setup (subscriptions, DON IDs, gas limits, source code restrictions, secrets management), sunset on June 30 2026 with migration to CRE, and developers need tooling to scaffold, test, deploy, and manage the lifecycle efficiently. This skill provides that tooling.
What It Does
- Scaffolds a complete Chainlink Functions consumer contract with all required imports and boilerplate
- Generates JavaScript source code templates for API GET/POST, computation, multi-source aggregation, and ABI decoding
- Manages Functions subscriptions: create, fund, add consumers, check balance, cancel
- Simulates source code execution locally before onchain deployment
- Handles DON-hosted and user-hosted (gist) secrets with encrypted threshold signing
- Generates migration-ready code for Chainlink Runtime Environment (CRE)
Frameworks / Standards Covered
| Framework / Standard | Description | |---|---| | Chainlink Functions v1.0.0 | Original Functions protocol (sunset June 30 2026) | | Chainlink Runtime Environment (CRE) | Successor to Functions, enhanced capabilities | | ERC-677 | LINK token transfer standard | | Decentralized Oracle Network (DON) | Multi-node consensus architecture | | Threshold Secret Management (TSM) | Encrypted secrets with multi-party decryption | | CLF-to-CRE Migration Guide | Full concept mapping and code migration | | Solidity ^0.8.19 | Functions consumer contract requirements | | FunctionsRequest library | Request encoding/decoding utilities |
Feature Breakdown
### 1. Smart Contract Scaffolding Generates a complete Functions consumer contract with: - FunctionsClient inheritance with correct constructor pattern - FunctionsRequest library integration with `using` declarations - Request encoding: setRequest, setSource, setSecrets, setArgs, setCallbackGasLimit - Response handling: fulfillRequest callback with request ID validation - Error handling: custom UnexpectedRequestID error, Response event logging - Owner-based access control via ConfirmedOwner base contract (OpenZeppelin compatible) ### 2. JavaScript Source Code Templates Pre-built JavaScript templates for the DON execution environment: - API GET request — fetches data with `Functions.makeHttpRequest()`, handles errors, returns typed responses - API POST request — sends authenticated POST with body payloads - Pure computation — on-chain math, aggregation, filtering without API dependencies - Multi-source aggregation — calls 3+ APIs and combines results (median, average, min/max) - ABI encoding/decoding — encodes multiple return values for onchain deserialization - String/number/bytes encoding — uses `Functions.encodeString()`, `Functions.encodeUint256()`, `Functions.encodeBytes()` ### 3. Subscription Manager Full lifecycle management: - Create subscription with configurable initial LINK funding - Add/remove consumer contract addresses - Check subscription balance and utilization - Cancel subscription with LINK withdrawal - Estimate request costs based on source code size, gas limits, and secrets usage - List all subscriptions for a router contract ### 4. Secrets Management Two supported approaches: - DON-hosted secrets (recommended): Encrypt secrets with DON public key, include in request. All nodes decrypt via threshold signing before execution. - User-hosted (gist) secrets: Store encrypted secrets as a GitHub gist, reference by URL. Useful for development but less secure than DON-hosted. Template includes both approaches with encryption helpers. ### 5. Local Simulation Offchain simulation workflow: - Run source code in the Functions Playground before onchain deployment - CLI tool validates JavaScript syntax and checks for disallowed patterns - Dry-run mode submits source code to DON without committing to chain - Gas estimation based on source code complexity and callback gas limit ### 6. CRE Migration Generator Critical sunset migration tooling: - Maps Functions concepts to CRE equivalents (Subscription -> Domain, DON ID -> Workflow ID) - Generates CRE-compatible Solidity contracts using the FunctionsConsumer pattern - Converts JavaScript source code to CRE TypeScript format - Provides step-by-step migration checklist with deadlines - Tests migrated contracts against CRE testnet before mainnet cutover
Usage
### Quick Start ```bash # 1. Scaffold a new Functions project python3 scripts/functions_cli.py scaffold --name MyConsumer --network sepolia # 2. Create a subscription python3 scripts/functions_cli.py sub create --amount 5 --link-token 0x779877A7b0D9E8603169DDbD7836e478b4624789 # 3. Deploy consumer contract python3 scripts/functions_cli.py deploy --contract MyConsumer.sol --sub-id 123 # 4. Send a Functions request python3 scripts/functions_cli.py request --sub-id 123 --contract 0x... --source templates/api-get.js --args '[42]' # 5. Simulate source code locally python3 scripts/functions_cli.py simulate --source templates/api-get.js --args '[1]' # 6. Check subscription balance python3 scripts/functions_cli.py sub status --sub-id 123 # 7. Generate CRE migration python3 scripts/functions_cli.py migrate --sub-id 123 --contract 0x... ``` ### Configuration Create `config/functions-config.yaml`: ```yaml network: sepolia router_address: "0xb83E47C2bC239B3bf370bc41e1459A34b41238D0" don_id: "0x66756e2d657468657265756d2d7365706f6c69612d3100000000000000000000" link_token: "0x779877A7b0D9E8603169DDbD7836e478b4624789" subscription: gas_limit: 300000 gas_price: "auto" secrets: mode: don_hosted # don_hosted | user_hosted_gist encryption_key: "" # path to DON public key migration: target_cre_domain: "my-domain" cre_endpoint: "https://cre.chain.link" ```
Output Format
### Functions Request Receipt ``` === FUNCTIONS REQUEST [request-id] === Subscription: 123 Consumer: 0xabc...def Source Code: 847 bytes Secrets: DON-hosted (2 entries) Args: [42] Callback Gas: 300000 Status: PENDING (tx: 0x123...) --- Response: 0x000000000000000000000000000000000000000000000000000000000000002a Decoded: 42 Explorer: https://sepolia.etherscan.io/tx/0x123... ``` ### Subscription Status ``` === SUBSCRIPTION 123 === Admin: 0xabc...def Balance: 4.25 LINK Consumers: 2 - 0xabc...def (active) - 0xdef...abc (active) Total Requests: 147 Last Fulfilled: 2026-06-01 14:32 UTC Status: ACTIVE --- CRE Migration: PENDING (deadline: June 30 2026) ```
Why This Beats Prompting It Yourself
Prompting ChatGPT/Claude Using This Skill --- --- --- Router addresses Must look up every time Pre-configured for all 15 networks Source code restrictions May suggest disallowed patterns Validates against DON constraints Secret encryption No tooling for threshold encryption Built-in DON-hosted secret manager Migration urgency May not mention sunset deadline Active CRE migration tracking Subscription management No lifecycle understanding Full CRUD with cost estimator Network-specific booleans Easy to get wrong Correct by default per network Error recovery Generic suggestions Specific Functions error codes Multiple return values Likely to miss ABI encoding Pre-built ABI encode/decode templatesUse Cases
- Parametric Insurance — Fetch weather API data as trigger conditions for automatic payout smart contracts. JavaScript computes threshold logic offchain, returns boolean payout signal.
- Dynamic NFTs — Update NFT metadata based on real-world sports scores or gaming stats. Functions fetches API data, transforms it, and returns the URI or trait data.
- DeFi Price Oracles — Aggregate prices from multiple CEX APIs (Binance, Coinbase, Kraken) with median calculation in the DON. No reliance on a single price source.
- Automated KYC/Compliance — Check offchain identity APIs inside a Functions request before allowing token transfers or contract interactions. Secrets manage API keys securely.
- Prediction Markets — Fetch event outcome data from trusted APIs and settle bets automatically. Functions validates and returns the resolved outcome onchain.
Details
How to install
Drop the file into your AI Agent. Works with Claude, Cursor, ChatGPT, and 20+ more.
Reviews
No reviews yet - be the first to share your experience.
Only users who have downloaded or purchased this skill can leave a review.
Be the first to review this skill.
Only users who have downloaded or purchased this skill can leave a review.
Security Scanned
Passed automated security review
Permissions
Allowed Hosts
File Scopes
Creator
Frequently Asked Questions
Browse More Skills
api-designer
Professional API design and review skill for REST, GraphQL, and event-driven architectures.
code-reviewer
Reviews your code for bugs, security vulnerabilities, logic errors, performance issues, and style violations. Organizes findings by severity and suggests fixes with code examples.

prompt-engineer
Professional prompt engineering patterns for building robust, secure, and production-ready LLM applications.

frontend-motion-wizard
Advanced responsive layout and interactive micro-interaction engine for React, Tailwind CSS, and Framer Motion. Automatically injects fluid element states, mobile-first touch behaviors, adaptive viewports, and non-destructive layout transitions into static codebases