QuickStart
Create your own JavaScript application on Golem
In this article, we'll show you how to launch your first JavaScript app on Golem Network from scratch in 15 minutes. The result of the application will be to run the JS file using Node JS on the provider's machine and return the result. We have divided the entire article into 5 sections:
The first two sections are duplicated with the more elaborate ones described elsewhere in the handbook. However, the purpose of this article is not to get into the details, but to show you how to start working with Golem step by step in minutes.
If you have a development environment already configured, you can go ahead and skip the first section and move on to the next one.
If you have already installed the yaggna daemon and configured the requestor correctly, go straight to the third section.
Prerequisites
- OS X 10.14+, Ubuntu 18.04 or 20.04 or Windows
- Familiarity with the command line
In this section we will introduce how to run a Simple Node Application on Golem Network. The created project will be using a build setup based on pre-built Golem Image and allow us to run Node.js script on Provider.
Make sure you have a 16.19.x version of Node.js installed:
node --version
To start working with Golem network we need to install
yagna
daemon locally. In the simplest terms, the daemon allows you to communicate with Golem Network and perform operations on it.Easy installation
Windows Manual installation
Unix Manual installation
Easy installation
You can install it using our helper script like this:
curl -sSf https://join.golem.network/as-requestor | bash -
You might be asked to modify your PATH afterwards.
On Windows, only the manual installation is supported.
Manual installation on Windows
Alternatively, if you can't install in easy way, you will do it manually in the following way:
- 1.Download the requestor package - prefixed
golem-requestor
- appropriate for your platform from: https://github.com/golemfactory/yagna/releases/tag/v0.12.0 - 2.Unzip the archive to extract the two files:
yagna.exe
andgftp.exe
. - 3.Copy those files to
C:\Windows\System32
Manual installation on Unix
Alternatively, if you can't install in easy way, you will do it manually in the following way:
- 1.Download the requestor package - prefixed
golem-requestor
- appropriate for your platform from: https://github.com/golemfactory/yagna/releases/tag/v0.12.0 - 2.Unpack
yagna
andgftp
binaries and put within somewhere in your PATH (e.g. copy them to /usr/local/bin on Unix-like systems) or add the directory you placed the binaries in to your PATH
Verify if
yagna
available in command line:yagna --version
It should output:
yagna 0.12.0 (37060503 2022-12-02 build #251)
Verify if
gftp
available in command line:gftp --version
It should output:
gftp 0.12.0 (37060503 2022-12-02 build #251)
If the above commands executed correctly, congratulations you have just installed the
yagna
daemon in your environment.If you have encountered problems, or would you like to learn more details about the requestor and
yagna
installation, please take a look in here: How to install requestor tutorialTo start using Golem Network you need a key, which will be also be the address of your wallet. For the purposes of this tutorial we are using testnet. To generate a key and fund your wallet follow these steps:
To perform any operations on the Golem Network the
yagna
daemon must be running. To do this, open a command line window and type:yagna service run
Important: After you launch the daemon, leave it running in the background while you proceed with the tutorial.
To use the network you must have your own unique key(wallet) for which is used for billing. To generate the key, make sure you have running
yagna
daemon from the previous step, leave it running in the background and in a separate command line window type in:yagna app-key create requestor
Please, note the key down
In order to be able to request tasks on Golem Network, you'll need some GLM tokens. To get some funds on testnet, type in:
yagna payment fund
Once you run the command, give some time to transfer funds to your wallet. You can verify whether you already got the funds with:
yagna payment status
If you have encountered problems, or would you like to learn more details about the funding process, please take a look in here: How to get some GLM tokens
Congratulations you are now ready to start building your first JavaScript app on the Golem Network.
Create a new node project by typing in the command line:
mkdir golem-tutorial-js
cd golem-tutorial-js
npm init
Add
yajsapi
to your project:npm install yajsapi
Let's create a simple code that will run a command displaying the node JS version on the provider. For this purpose we would like to call the command
node -v
. Let's create index.mjs
file that looks like the following:index.mjs
1
import { TaskExecutor } from "yajsapi";
2