How To Decentralize and Monetize Your Application With iExec

Blair Maclennan
iExec
Published in
6 min readDec 4, 2018

***2020 UPDATE***

Please follow the up-to-date official iExec technical documentation here:

➡️https://docs.iex.ec/for-developers/quick-start-for-developers ⬅️

Information given in this article may be dated, so please check out our ‘Quicks start guide for Developers, linked above.

******

💡 Want to learn more about iExec? Check out iExec Academy!

iExec Academy aggregates all content related to the project. You’ll find articles, tech documentation, videos, interactive demos, and much more! Whether you are a beginner or an expert, a developer or crypto-enthusiast, you’ll find what you are looking for on iExec Academy!

📚➡️ https://academy.iex.ec

iExec has developed a blockchain-based decentralized marketplace for cloud computing resources. The iExec Marketplace allows participants who need computing power to meet those who own computing power, turning cloud power into a commodity that can be traded by anyone.

The iExec SDK easily allows any application to be transformed into a decentralized one. This article will outline the simple process of setting up an application to be powered by a decentralized cloud network, and how developers can profit from the new business models iExec opens up.

Why iExec?

With iExec, developers can decentralize their existing applications. Decentralization is achieved when computing is done on separate nodes over the network with no node instructing another. Using iExec to power your application in a decentralized fashion provides numerous advantages, including monetizations opportunities through the iExec ‘pay-per-task’ system.

  • As a decentralized application (‘dapp’), applications become autonomous. The network for computing power is distributed, run on consensus and is not controlled by a single entity. This removes the vulnerability of a single-point-of-failure as well as being extremely difficult and expensive to attack.
  • Application developers do not need to write blockchain ‘smart contracts’. The iExec SDK removes the complexity of blockchain.
  • The smart contracts used for the iExec decentralized network have been publicly audited by ChainSecurity, ensuring functional correctness, compliance, and absence of security vulnerabilities.
  • iExec takes care of much of the lifecycle, deployment, operation, and monitoring of applications, allowing developers to focus on their core offering.
  • Monetization through the iExec ‘pay-per-task’ payment scheme allows developers to earn money every time their applications are used.

What Applications can be supported by iExec?

iExec supports the most compute-intensive decentralized applications in a variety of fields, ranging from AI and Big Data, to Fintech and 3D rendering. The iExec Dapp Store lists decentralized applications that are already powered by iExec workers. For deeper insight into what iExec can do, have a read of our ‘Dapp of the Week’ series. Some examples include:

4 Steps to Decentralize your application

With iExec, achieving decentralization is simple. The remainder of the article will walk you through the following steps:

  1. Create a Docker image
  2. Decentralize your application on the blockchain (and set a price for it)
  3. List your application on the iExec Dapp Store
  4. Monitor your application using the iExec explorer

1. Create a Docker image

There is no one specific method for creating a Docker image for iExec. To do so, you can follow the official Docker documentation. However, there are a few important points that should be considered during the process.

  • The Docker image file should not contain a directory named “/iexec”.
    A directory named “/iexec” is automatically created during run-time. This directory is where your application will retrieve input files, and also where the application stores results of computations.
  • To ensure the highest level of trusts, applications should be deterministic. This means that the task must give an identical result each time, given the same input files and parameters. This is required to benefit from the trust mechanism offered by the ‘PoCo’, the iExec consensus protocol which validated the correctness of the result. (you can read more about proof-of-contribution or ‘PoCo’ here). It is the responsibility of the application developer to ensure the deterministic behavior of their application, which is calculated using the result file. If the application is not deterministic, it may generate the file: “/iexec/consensus.iexec”, and PoCo mechanism will attempt to calculate consensus on this specific file instead of the result itself.

Note: If your application is not deterministic, PoCo still offers three security mechanisms: blockchain-level audibility, secure payment using RLC tokens and, potentially, certification that a computation was executed within ‎Intel® SGX hardware enclaves.

  • Another file name to avoid is: “/iexec/enclaveSig.iexec”. This file is automatically generated if your application is run in an SGX enclave [read more on our solution for SGX], overwriting any existing content.
  • Once the docker image is created, a test should be run locally using the following command:

docker run -v $(pwd):/iexec — rm — name ${CONTAINERNAME} \ ${IMAGENAME} ${ARGS} 2>&1

$(pwd) — is the current working directory (keep it like that; this is automatically calculated by your shell);
${CONTAINERNAME} — is the name of the container (free text);
${IMAGENAME} — is the Docker image name (free text);
${ARGS} is the application command line arguments (free text);

When ready, the image must be uploaded to a public hub at https://hub.docker.com

2. Decentralize your Application on the Blockchain

The iExec Software Development Kit (SDK) makes developers’ lives easier.

Please follow the full SDK tutorial on GitHub, it walks you through the following steps:

  • Install the SDK : “npm -g install iexec
  • Initialize a project: “iexec init”, (to automatically create all configuration files and a wallet in the current directory)
  • Edit the “iexec.json” file to set up the name, the price and the dockerhub link for your application
  • Deploy your application on the blockchain: “iexec app deploy”.

After this, you now have a blockchain address for your application, the entry point for running your app within SDK or Marketplace

Monetizing your application

To monetize an application and earn RLC tokens each time it is executed through iExec, developers have the option of setting a fee for each task execution. This step is shown in the iexec.json section in the SDK. When naming the .json file, the sum should be set (in nRLC) after “price”: (note: 1 nRLC is equivalent to 0.000000001 RLC)

🎉 Congratulations!

That’s it, your application is decentralized. It is also monetized, if you chose to set a price in the .json file, each time a task is launched through the iExec Dapp Store, the user will pay the set price for the execution and you will be rewarded with the fee in your iExec account. You may then withdraw your funds to your own wallet.

3. List your decentralized application on the iExec Dapp Store

This is an optional step. As your application is integrated with the iExec marketplace and native iExec payment token ‘RLC’, it can easily be monetized. The iExec Dapp Store is a listing of all decentralized applications that can be powered by iExec workers. To advertise your application here, you can open a pull request on our GitHub Dapp registry. Please note that anybody will soon be encouraged to deploy Dapp Stores. To encourage decentralization, iExec does not want to be the only operator and curator of decentralized applications.

4. Monitor your Decentralized Application

iExec is fully auditable. The iExec Explorer gives an overview of all transactions over the iExec network, allowing developers and users to follow the activity of their applications and the tasks executed and transactions on the marketplace.

So that’s it! By deploying on iExec, you have added a decentralized aspect to your application and can now benefit from the new monetization models enabled by blockchain. So have fun with the SDK tools and let us know how it goes!

Technical Support on Slack:

Along with a community of developers already using iExec with their applications, the tech team is accessible on #beta-testers channel on our Slack chat.

--

--