1. Overview

It is time to submit your task to the blockchain. Before you do so, we strongly recommend that you read and understand the guide found here.

What you will need to do

Install XELINE Wallet

In order to submit your task to the blockchain you will need to install XELINE Wallet. This tool comes in handy when you have finished implementing your ePL program (we wil talk about this next ) and you feel it is ready to be broadcasted to the XEL network.

Write your task in ePL

ePL is a programming language which was specifically designed for coding algorithms to be executed on the XEL computation node network. Its syntax is very similar to the C programming languages. However, since nodes on the XEL network download and execute code from potentially dangerous sources, a few adaptations were necessary to ensure that code written in ePL can cause no harm to the system it is executed on.

If you haven’t already, please head to the ePL documentation to get more information on how to write your task before continuing on the tutorial.

2. Installing XELINE Wallet

Xeline is a wallet software which lets you easily upload your ePL file to the XEL network by just drag-dropping it into the GUI. It takes only a few seconds to have the computation nodes on the XEL network start searching for solutions to your algorithm. Furthermore, this wallet is able to conveniently perform live monitoring of your open tasks and collect the results that other nodes have found and recorded on the Blockchain.

Windows

MacOS

Linux

Run XELINE Wallet from binaries

Make sure you have installed unzip

sudo apt-get install -y unzip

Now, directly download XEL Lite Wallet with xeline-linux-x64.zip

Launch

Unzip the folder, go inside the directory and launch the binary

unzip xeline-linux.zip

cd xeline-linux-x64

./xeline

Run XELINE Wallet from sources

Requirements

Make sure you have installed git and curl

sudo apt-get install -y curl git

Install a recent version of Nodejs, if you haven’t already.

curl -sL https://deb.nodesource.com/setup_9.x | sudo -E bash -

sudo apt-get install -y nodejs

Cloning and installing dependencies

Clone the repository and npm install all dependencies (only once)

git clone https://github.com/xel-software/xeline.git​

cd xeline

npm install

Launch

Finally, run the application

npm start

3. Preparing the task

Now that you have installed XELINE Wallet, it’s time to write your task in ePL and broadcast it to the XEL network. We'll utilise the same demonstration task we use on the ePL tutorial. Save it to a file called “my_own_prime_demo.epl”. While this demo is already integrated in the XELINE Wallet and can be run right away, we want to create this demo project from scratch here, for learning purposes.

Preparing your ePL file

At this moment, your ePL file contains just the program logic. However, to submit it to the blockchain you have to configure a few parameters which will be used in XELINE Wallet as metadata. Those parameters tell XELINE how much you are willing to spend for that job, how long it is meant to be running, how many solutions you are interested in, how many iterations your job is meant to run, and so on. We have not yet covered the iteration part, we save that for later. Metadata is added to your ePL file at the top. So go ahead, an add those lines to the top of your ePL program:

// metadata(title:My personal PRIME demo)

// metadata(pow_limit:1000)

// metadata(pow_price:0.02)

// metadata(bounty_limit:1)

// metadata(bounty_price:5)

// metadata(iterations:1)

// metadata(timeout:250)

// metadata(callback:my_own_prime_demo_callback.js)

Let’s break this up and take a deeper look at what these lines actually do:

// metadata(title:My personal PRIME demo)

This line gives your job a description. Try to keep it as short as possible. This title is just used to help you organise tasks inside the XELINE Wallet and it won’t be transmitted to the blockchain.

// metadata(pow_limit:1000)

// metadata(pow_price:0.0001)

These two lines describe how many proof-of-work rewards you want to give out before your job times out and closes automatically. Remember: these are continuous small rewards workers keep getting as a targeted frequency of 10 proof-of-work per second (for all the tasks in the network together). So in our case, we want to close our job if we have paid 1000 proof-of-work rewards (0.0001 XEL each) and the network has not yet found a solution to our problem.

// metadata(bounty_limit:1)

// metadata(bounty_price:5)

These two lines describe how many solutions you want to your problem. In our case, we are looking for just one prime number so we set this value to 1. Also, we are willing to pay a “bounty price” of 5 XEL for the first submitted solution to our problem. If multiple solutions are submitted inside one block, only the one appearing first in the block transaction list will count. This can happen for the very simple reason that the work closing and timeout events are triggered after the block has been processed. So when your job receives a solution in block 1000, it will be closed in block 1001.

// metadata(iterations:1)

This line tells XELINE how many iterations you want your program to run. Leaving it at 1 means that your program ends immediately after #bounty_limit solutions have been found.

// metadata(timeout:250)

This line tells XELINE after how many blocks you want to end your task regardless of how many proof-of-work or bounty solutions have been found. This is useful when you, for example, create tasks with time critical results. In this example, we just set this value to a random 250 which means that the job will end after 250 blocks from the block it gets included into.

// metadata(callback:my_own_prime_demo_callback.js)

This line is probably the most important one since it will help you to automatically analyze and post process the results the worker nodes find. But specifying the callback in the metadata is not enough, we actually need to create that file in the correct location. The directory where callback scripts should be placed into varies by operating system:

Windows

C:\Users\YourUserName\AppData\Local\Xeline\callbacks

MacOS

~/Library/Application Support/Xeline/callbacks

If you are on a macOS system you have to create the following file for this demo to run:

~/Library/Application Support/Xeline/callbacks/my_own_prime_demo_callback.js

Linux

~/.config/Xeline/callbacks

Callbacks are written in NodeJS and are only executed on your local computer. They are meant to nicely post process your solution candidate for display. Practically, the XELINE Wallet will run this file once a solution has been submitted to the blockchain and display the console output in your task overview. Of course, your callback can do all sorts of other stuff like, for example, submit your result over the network or feed it into another application. For now, just put this line into the file:

console.log("Yeah. The blockchain just reported this prime: " + (bounties[0][0]>>>0));

Within your callback script, you can access a two-dimensional array called bounties[][]. The first dimension holds all solutions that were submitted, and the second dimension holds the 12 m[] values that led to this solution. Since we are only looking for one solution only, our bounty array will have just one entry containing twelve unsigned integers:

var bounties = [ [m[0],m[1],m[2],...m[11]] ];

Since our prime number candidate is just in m[0] (head to the last step for more information) it is enough for us to just print out bounties[0][0], i.e., the first m value in the first (and only) solution. There is a second, one-dimensional array that you can access, the storages[] array which contains the latest version of the storage integers. Since we have not yet used the concept of iterations and storages, this array will be empty and should not be accessed in this demo.

4. Submitting the task

Now, it’s time to submit your task to the blockchain.

Submitting your ePL file

Open the XELINE Wallet we installed in step 2. To submit your ePL file, click on “new task” in the lower part of the left hand side in order to go to the “New Task” screen.

Now, simply drag your “my_own_prime_demo.epl” file onto the drag-drop field.

You will see a confirmation screen where you can once again verify that all the metadata you have configured earlier has been picked up correctly. Also, this step will inform you in case you did not put your callback script in the proper location. By clicking the “Broadcast” button, you can actually submit your task to the Blockchain. You will see this confirmation message, showing the transaction ID and advise you to switch over to your task overview:

Click on “work list overview” or alternatively on “xx tasks” in the left sidebar in order to switch to the task overview.

It might happen, that your task does not appear immediately because it needs at least one confirmation on the blockchain. Just hang on for a minute, it should appear eventually. You will see your task which comes with some basic statistics such as the amount of proof-of-work submissions received so far, the number of bounties (or solutions) that have been found so far, the iteration this job is in and the remaining blocks until the job times out. Additionally, for open tasks, you see a “Cancel” button which allow you to stop that job at any time. Below the task statistics you see a message saying, that a callback will be executed the moment the job is finished: this is where the results of your task will appear.

5. Support

If you encounter any difficulty while submitting your task to the blockchain you can always read more information on the official XEL wiki or seek assistance from our community.

Code copied!