♈
Bootcamp-2024
  • Intro
  • 1. Blockchain & Wallet Fundamentals
    • Blockchain Introduction
    • State Machines
    • Cryptography
    • Distributed Networks
    • Game Theory
    • What is Web3
    • MetaMask Wallet Installation
    • Transferring Tokens with MetaMask
  • 2. Smart Contract & Solidity Fundamentals
    • Using Remix
    • Create, compile and publish your first smart contract
    • Interact with already published smart contracts
    • Blockchain Explorer
    • Verify source code on Etherscan
  • 3. Oracles, ERC20 & Chainlink Data Feeds
    • Oracles
    • Create & Deploy ERC20
    • Data Feeds
  • 4. Cross-Chain Tokens With Chainlink CCIP
    • Setting up MetaMask
    • Getting USDC Testnet Tokens
    • Create Smart Contract In Remix
    • Compile and Deploy
    • Approve USDC
    • Send LINK to your Contract
    • Send USDC from Fuji to Sepolia
    • USDC on Sepolia
  • 5. Mentoring Session
  • 6. NFTs & Chainlink Automation
    • NFT Basics
    • Dynamic NFTs
    • Creating an NFT Smart Contract
    • Deploying Your Dynamic NFTs
  • 7. Chainlink CCIP & Cross-Chain NFT dApps
    • Create and deploy CCIP NFT Contracts
    • Mint on Source Chain
    • Fund Contract
    • Mint On Sepolia From Fuji
    • Mint from Destination 2 - Base Sepolia
  • 8. Random Numbers with Chainlink VRF
    • Introduction to Chainlink VRF
    • Hands On Game Using VRF
  • 9. Off-Chain Data with Chainlink Functions
    • Chainlink Functions Playground
    • Setting up MetaMask
    • Remix
    • Functions Subscription
    • Creating The Functions Consumer Contract
    • Sending a Request from Remix
    • City Weather and Examples
    • City Weather on Chainlink Functions
  • 10. Connecting the 🌏 with Chainlink
  • Glossary
Powered by GitBook
On this page
  • Inputs
  • Star Wars Example
  1. 9. Off-Chain Data with Chainlink Functions

Chainlink Functions Playground

A place to simulate, test and demo Chainlink Functions code in your browser

Previous9. Off-Chain Data with Chainlink FunctionsNextSetting up MetaMask

Last updated 1 year ago

Navigate to the and you will see this page with a simple example:

Inputs

  1. Your Source code

  2. Your Argument(s)

  3. Your Secret, if any

When you are ready to run your code:

  • click the “Run Code” button (#4) at the bottom left

  • your "Output" (#5) will appear on the right hand side. In this traditional example, you get the string back "Hello World!"


Star Wars Example

Back in the Chainlink Functions Playground, click the drop-down menu on the upper right called “Fill with example code” (#1) and click the “Star Wars characters” example (#2):

The JavaScript source code will be loaded for your project.

  1. This is the first argument, which is the characterId you want to retrieve information about. args gets injected into your source code at runtime. More on that later!

  2. Then, a HTTP request is made to the URL: https://swapi.info/api/people/${characterId} using the Functions library that is also injected into the source code at run time.

This has various information about the Star Wars character Luke Skywalker. You can change the argument 1 to 2 and so on for other Star Wars characters.

Hint:4 is Darth Vader!

Now back at the Playground, pass your arguments to the source code using the text input boxes. Put 1 as shown in the image (#1) and and click the “Run Code” (#2) blue button.

You will see the “Console log” and "Output" data on the right with all the information on Luke Skywalker:

By utilizing the Chainlink Functions Playground, you verify your code to make sure it works before you put that into your contracts. Pretty neat, huh?

Let's assume that your first argument (which gets assigned to characterId ) is 1. If you go to that link () a you will see the following information:

https://swapi.info/api/people/1/
Chainlink Functions Playground
Chainlink Functions Playground
Luke Skywalker