Got a cool example to share? Get listed here! Submit it now.

useChainlinkFunctions()

Collection of community submitted examples for Chainlink Functions

Get inspired from quick examples

Chainlink Functions, a new self-service platform that allows anyone to write serverless code to fetch any data from any API and run custom compute on Chainlink's network. Learn from examples created by the community or contribute your own!
Learn more about Chainlink Functions

Fetch Solana token data from LYS Labs Aggregation API

Submitted by:
LysLabs
Fetch token metadata from the LYS Labs Solana Aggregation API by mint address. Requires 1 argument (mint) and 1 secret (LYS_API_KEY). Returns a JSON string containing mint/name/symbol/supply.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 /** * LYS Labs Solana Aggregation API example for Chainlink Functions * * Args: * - args[0]: Solana mint address (string) * * Secrets: * - secrets.LYS_API_KEY: API key created in the LysLabs developer portal * * Create an API key: https://dev.lyslabs.ai/ (sign up → dashboard → API Keys) * * API Docs: * - https://agg-api-solana-mainnet.lyslabs.ai/api-docs */ const mint = args[0] if (!mint || mint.length === 0) { throw Error("mint is required (args[0])") } if (!secrets.LYS_API_KEY) { throw Error("LYS_API_KEY secret is required") } const url = `https://agg-api-solana-mainnet.lyslabs.ai/v1/aggregated/${mint}` const resp = await Functions.makeHttpRequest({ url, method: "GET", headers: { "Content-Type": "application/json", "x-api-key": secrets.LYS_API_KEY, }, }) if (resp.error) { throw Error("request failed") } const data = resp.data || {} const name = data.name || (data.lifecycle && data.lifecycle.name) || "Unknown" const symbol = data.symbol || (data.lifecycle && data.lifecycle.symbol) || "TOK" const supply = Number(data.supply || (data.lifecycle && data.lifecycle.uiAmount) || 0) const out = { mint, name, symbol, supply } return Functions.encodeString(JSON.stringify(out))