Chainlink Functions Playground

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

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

Chainlink Functions Playground

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.

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

Luke Skywalker

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?

Last updated