{"id":20974229,"url":"https://github.com/thirdweb-example/thirdweb-chainlink-functions","last_synced_at":"2025-05-14T12:31:10.761Z","repository":{"id":107808552,"uuid":"608381940","full_name":"thirdweb-example/thirdweb-chainlink-functions","owner":"thirdweb-example","description":"Off-chain Data \u0026 Computation with Chainlink Functions","archived":false,"fork":false,"pushed_at":"2024-04-12T00:26:28.000Z","size":337,"stargazers_count":2,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-02T18:22:40.498Z","etag":null,"topics":["chainlink","chainlink-functions","dashboard","deploy","template"],"latest_commit_sha":null,"homepage":"","language":"Solidity","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thirdweb-example.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-01T22:40:33.000Z","updated_at":"2023-11-29T20:51:42.000Z","dependencies_parsed_at":"2024-11-19T04:42:02.358Z","dependency_job_id":null,"html_url":"https://github.com/thirdweb-example/thirdweb-chainlink-functions","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fthirdweb-chainlink-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fthirdweb-chainlink-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fthirdweb-chainlink-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thirdweb-example%2Fthirdweb-chainlink-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thirdweb-example","download_url":"https://codeload.github.com/thirdweb-example/thirdweb-chainlink-functions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254142251,"owners_count":22021489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chainlink","chainlink-functions","dashboard","deploy","template"],"created_at":"2024-11-19T04:27:19.793Z","updated_at":"2025-05-14T12:31:10.221Z","avatar_url":"https://github.com/thirdweb-example.png","language":"Solidity","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [!Important]  \n\u003e This repository is referencing the `mumbai` chain.\n\u003e \n\u003e `Mumbai` [is deprecated since 08/04/2024](https://blog.thirdweb.com/deprecation-of-mumbai-testnet/), meaning the code in this repository will no longer work out of the box.\n\u003e\n\u003e You can still use this repository, however you will have to switch any references to `mumbai` to another chain.\n\n# Chainlink Functions using thirdweb\nAn example use case for Chainlink Functions - call a Chess API to retrieve the ratings of two chess players \u0026 calculate the new ELO rating based on who wins the subsequent match.\n\nThis repository is a simplified and modified version of the official [Chainlink Functions Starter Kit](https://github.com/smartcontractkit/functions-hardhat-starter-kit).\n\n## Using this repo\nPrerequisites:\n- Git\n- Hardhat\n- Cast\n\nTo create a copy of this template, run the command from your terminal:\n\n```Bash\nnpx thirdweb create --template thirdweb-chainlink-functions\n```\n\n## Deploying the Consumer contract\n\n- Run the command:\n\n```Bash\nnpx thirdweb deploy\n```\n- Select the `FunctionsConsumer` contract\n- Copy and paste as the contract parameter the oracle address corresponding to the network you are deploying to\n- Click __Deploy Now__ and verify the transaction\n\n## Create \u0026 Fund a Subscription\nChainlink Functions uses the subscription method to manage and fund consumer contracts to enable them to make requests to the Chainlink Decentralized Oracle Network (DON)\n\nTo create a subscription, import the `FunctionsBillingRegistry` contract, corresponding to the network you are working on, to your Dashboard using the search bar. \n\nCall the __write__ function `createSubscription` and copy the subscription Id from the event in the events tab\n\nAdd your consumer contract as a consumer by calling the function `addConsumer` on the Billing Registry by filling in your consumer contract address and subscription Id. \n\n## Funding your Subscription\n\nImport the `LinkToken` contract to your Dashboard and select the `transferAndCall` function. For the `data` parameter, you will need to ABI encode your subscription Id. To do this run the following command in your terminal:\n\n```Bash\ncast abi-encode \"f(uint256)\" \"\u003cyour-subscription-id\u003e\"\n```\n\nCopy the result and use as the `data` parameter. Paste the Billing Registry address as the `address` parameter. The `amount` parameter is measured in JUELS so 5 LINK will have an input of 5000000000000000000.\n\n## Making a Request\n\nSelect the function `executeRequest` and use the following values as parameters:\n\n- Source: copy the code from inside `scripts/functions.js`\n- Secrets: We are not using secrets (where you could use secrets e.g. encrypted API Keys) - `0x`\n- Location: `0` denotes Inline, `1` denotes Remote. Use a value of `0`\n- Args: `[\"0\", \"1\"]` - the first param (either `0` or `1`) specified whether to calculate player 1 or 2's rating, the second param specifies whether they won or lost the subsequent match `0` = lose, `1` = win.\n\nExecute the transaction, making sure to set a manual gas limit in your browser wallet (a value of 500000 should do it!)\n\n## Reading the results\n\nCall the __read__ function `latestResponse` to read the updated ELO rating.\n\nThis value can now be used in, for example, updating dynamic NFT metadata to have the NFT represent the player's current rating. By combining with Chainlink Automation, this process becomes seamless and automatic when a player completes a match. \n\n## Useful Addresses\n\n  mainnet:\n    linkToken: \"0x514910771af9ca656af840dff83e8264ecf986ca\",\n\n  polygon:\n    linkToken: \"0xb0897686c545045afc77cf20ec7a532e3120e0f1\",\n\n  mumbai:\n    linkToken: \"0x326C977E6efc84E512bB9C30f76E30c160eD06FB\"\n    linkEthPriceFeed: \"0x12162c3E810393dEC01362aBf156D7ecf6159528\"\n    functionsOracleProxy: \"0xeA6721aC65BCeD841B8ec3fc5fEdeA6141a0aDE4\"\n    functionsBillingRegistryProxy: \"0xEe9Bf52E5Ea228404bB54BCFbbDa8c21131b9039\"\n    functionsPublicKey:\n      \"a30264e813edc9927f73e036b7885ee25445b836979cb00ef112bc644bd16de2db866fa74648438b34f52bb196ffa386992e94e0a3dc6913cee52e2e98f1619c\"\n\n  sepolia: \n    linkToken: \"0x779877A7B0D9E8603169DdbD7836e478b4624789\"\n    linkEthPriceFeed: \"0x42585eD362B3f1BCa95c640FdFf35Ef899212734\"\n    functionsOracleProxy: \"0x649a2C205BE7A3d5e99206CEEFF30c794f0E31EC\"\n    functionsBillingRegistryProxy: \"0x3c79f56407DCB9dc9b852D139a317246f43750Cc\"\n    functionsPublicKey:\n      \"a30264e813edc9927f73e036b7885ee25445b836979cb00ef112bc644bd16de2db866fa74648438b34f52bb196ffa386992e94e0a3dc6913cee52e2e98f1619c\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthirdweb-example%2Fthirdweb-chainlink-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthirdweb-example%2Fthirdweb-chainlink-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthirdweb-example%2Fthirdweb-chainlink-functions/lists"}