The iExec SDK is a CLI and a JS library that allows developers to interact with iExec decentralized marketplace in order to run off-chain computations.
- The iExec Dapp Store: https://dapps.iex.ec
- The iExec Marketplace: https://market.iex.ec
- The iExec Explorer: https://explorer.iex.ec
- The iExec Pools registry: https://pools.iex.ec
- The RLC faucet: https://faucet.iex.ec
- iExec main documentation: https://docs.iex.ec
- The iExec JS smart contracts client lib to interact with iExec smart contracts (without the SDK)
- The iExec JS client lib to interact with iExec server (without the SDK)
- iExec dapps registry, to apply for Dapp Store listing
All three major OS are supported (linux, OSX, windows).
Requirements: and Git.
npm -g install iexec # install the cli
iexec --version
iexec --help
Requirements: Docker.
# For Linux users
echo 'alias iexec='"'"'docker run -e DEBUG=$DEBUG --interactive --tty --rm -v /tmp:/tmp -v $(pwd):/iexec-project -w /iexec-project iexechub/iexec-sdk'"'"'' >> ~/.bashrc && source ~/.bashrc
# For Mac OSX users
echo 'alias iexec='"'"'docker run -e DEBUG=$DEBUG --interactive --tty --rm -v /tmp:/tmp -v $(pwd):/iexec-project -w /iexec-project iexechub/iexec-sdk'"'"'' >> ~/.bash_profile && source ~/.bash_profile
Now run iexec --version
to check all is working.
- Nodejs: run
npm -g install iexec
- Docker: run
docker pull iexechub/iexec-sdk
- SDK Video series link: https://goo.gl/1AfnSH
- Init project video: https://www.youtube.com/watch?v=afBIv-84C9U
- Deploy app video: https://www.youtube.com/watch?v=EltDUaYU8lQ
- Buy market order and trigger a work video: https://www.youtube.com/watch?v=x7Sy8PcGcMg
Katacoda is an in-browser terminal that allows you to remotely follow tutorials without the need to install the SDK on your machine: https://www.katacoda.com/sulliwane/scenarios/sdk-v2-tutorial
required steps before following any other workflow.
iexec init # create all required files
iexec wallet getETH # ask faucet for ETH
iexec wallet getRLC # ask iExec faucet for RLC
iexec account deposit 200 # deposit nRLC on your iExec account, so you can buy orders
iexec wallet show
iexec account show
iexec app count # check if you have already deployed apps
iexec app init # reset app fields in iexec.json
iexec app deploy # deploy app on Ethereum
iexec app show # show details of deployed app
iexec order init --buy # init work order fields in iexec.json
vi iexec.json # edit iexec.json and customize the buy order fields. Particularly work params field.
iexec orderbook show --category 5 # show orderbook and choose an order ID
iexec order fill <orderID> # fill order using its ID
iexec work show --watch --download # watch progress of the submitted work, and download its result when completed
iexec --version
iexec --help
iexec app --help
iexec orderbook --help
iexec info --chain kovan
iexec init # create all files necessary to get started
# OPTIONS
# --chain <chainName>
# --to <address>
# --force
# --hub <address>
# --password <password>
iexec wallet create
iexec wallet getETH
iexec wallet getRLC
iexec wallet show [address] # optional address to show other people's wallet
iexec wallet sendETH <amount> --to <eth_address>
iexec wallet sendRLC <amount> --to <eth_address>
iexec wallet sweep --to <eth_address> # drain all ETH and RLC, sending them back to iExec faucet by default
iexec wallet encrypt --password <password> # save encrypted-wallet.json from wallet.json
iexec wallet decrypt --password <password> # save wallet.json from encrypted-wallet.json
# OPTIONS
# --chain <chainName>
# --force
# --hub <address>
iexec account login
iexec account show [address] # optional address to show other people's account
iexec account deposit <amount>
iexec account withdraw <amount>
# OPTIONS
# --chain <chainName>
# --hub <address>
# --user <address>
iexec app init # init new app
iexec app deploy # deploy new app
iexec app show [address|index] # show app details
iexec app count --user <userAddress> # count user total number of app
# OPTIONS
# --chain <chainName>
# --hub <address>
# --user <address>
iexec dataset init # init new app
iexec dataset deploy # deploy new dataset
iexec dataset show [address|index] # show dataset details
iexec dataset count --user <userAddress> # count user total number of dataset
# OPTIONS
# --chain <chainName>
# --hub <address>
# --user <address>
iexec workerpool init # init new workerpool
iexec workerpool deploy # deploy new workerpool
iexec workerpool show [address|index] # show workerpool details
iexec workerpool count --user <userAddress> # count user total number of workerpool
# OPTIONS
# --chain <chainName>
# --category [ID]
# --pool [address]
iexec orderbook show --category 5 # show orderbook for category 5
# OPTIONS
# --chain <chainName>
# --hub <address>
# --sell
# --buy
# --force
iexec order init --buy # init new buy order
iexec order init --sell # init new sell order
iexec order place # place an order at limit price
iexec order show <orderID> # show an order
iexec order fill <orderID> # fill an order at market price and start work execution
iexec order cancel <orderID> # cancel an order
iexec order count # count marketplace total number of order
# OPTIONS
# --chain <chainName>
# --watch
# --download [fileName]
iexec work show [address] --watch --download # show a work, watch its status changes and download it when completed
# OPTIONS
# --chain <chainName>
# --application <appName | app0xAddress>
# --keysFolderPath <path>
# --inputsFolderPath <path>
# --encryptedOutputsFolder <path>
# --outputsFolderPath <path>
# --secretManagementService <hostname/IP>
# --remoteFileSystem <serviceName>
iexec tee init # init the TEE folders tree structure
iexec tee encryptedpush --application iexechub/sgx-scone:blender # encrypt work input data + upload it to file hosting service
iexec tee decrypt # decrypt work result
# OPTIONS
# --chain <chainName>
# --hub <address>
iexec category init # init new category
iexec category create # create new category
iexec category show <index> # show category details by index
iexec category count # count hub total number of category
iexec registry validate app # validate an object description [app, dataset, workerpool]
iexec scheduler show # show scheduler details
iexec scheduler api # direct call of scheduler API methods
The iexec.json
file, located in every iExec project, describes the parameters used when creating a [app|datasetcategory|workerPool], or when submitting a work.
{
"app": {
"name": "next-dapp1",
"price": 1,
"params": {
"type": "DOCKER",
"envvars": "XWDOCKERIMAGE=ericro/face-recognition"
}
},
"dataset": {
"name": "next-dataset",
"price": 2,
"params": {
"uri": "https://data.provider.com"
}
},
"category": {
"name": "CAT1",
"description": "my category N°1",
"workClockTimeRef": 100
},
"workerPool": {
"description": "Qarnot WorkerPool ",
"subscriptionLockStakePolicy": 100,
"subscriptionMinimumStakePolicy": 100,
"subscriptionMinimumScorePolicy": 100
}
}
The chains.json
file, located in every iExec project, describes the parameters used when communicating with ethereum nodes and iExec schedulers. They are ordered by chain name, accessible by using the --chain <chainName>
option for each command of the SDK.
{
"default": "kovan",
"chains": {
"development": {
"host": "localhost",
"id": "*",
"server": "https://localhost:443"
},
"ropsten": {
"host": "https://ropsten.infura.io/berv5GTB5cSdOJPPnqOq",
"id": "3",
"server": "https://testxw.iex.ec:443"
},
"rinkeby": {
"host": "https://rinkeby.infura.io/berv5GTB5cSdOJPPnqOq",
"id": "4",
"server": "https://testxw.iex.ec:443"
},
"kovan": {
"host": "https://kovan.infura.io/berv5GTB5cSdOJPPnqOq",
"id": "42",
"server": "https://testxw.iex.ec:443"
},
"mainnet": {
"host": "https://mainnet.infura.io/berv5GTB5cSdOJPPnqOq ",
"id": "1",
"server": "https://mainxw.iex.ec:443"
}
}
}
[Work In Progress] Although we'll try to avoid any API change, the Lib API may still evolve a little bit based on beta-tester feedbacks.
iExec SDK can be imported in your code as a library/module, and it's compatible with old JS engines:
- >= Node v6.4
- >= Firefox v22
- >= Chrome v28
- >= IE 9
- iexec.wallet.checkBalances
- iexec.wallet.getETH
- iexec.wallet.getRLC
- iexec.wallet.sendETH
- iexec.wallet.sendRLC
- iexec.account.auth
- iexec.account.deposit
- iexec.account.withdraw
- iexec.hub.createObj
- iexec.hub.showObj
- iexec.hub.countObj
Parameters
contracts
Object an iexec contracts objectaddress
String the address to check balances onoptions
Object [optional] optionsoptions.hub
String custom hub address
Return (Promise)
balances
Objectbalances.wei
BN ether balance in weibalances.nRLC
BN RLC balance in nano RLC
Example
// wallet.checkBalances
Parameters
chainName
String name of the chain (ropsten|rinkeby|kovan)address
String the address to ask ETH for
Return (Promise)
responses
Array of String String response from each faucet api
Example
// wallet.getETH
Parameters
chainName
String name of the chain (ropsten|rinkeby|kovan)address
String the address to ask ETH for
Return (Promise)
responses
Array of String String response from each faucet api
Example
// wallet.getRLC
Parameters
contracts
Object an iexec contracts objectamount
String the amount of ETH to send tofrom
String the address the is sending ETHto
String the address that is receiving the amount of ETH
Return (Promise)
txReceipt
Object the ethereum transaction receipt
Example
// wallet.sendETH
Parameters
contracts
Object an iexec contracts objectamount
String the amount of nano RLC to send toto
String the address that will receive the amount of nRLCoptions
Object [optional] optionsoptions.hub
String custom hub address
Return (Promise)
txReceipt
Object the ethereum transaction receipt
Example
// wallet.sendRLC
Parameters
amount
String the amount of nano RLC to send toscheduler
Object an iexec scheduler objectethjs
Object Ethjs client
Return (Promise)
jwtoken
String the iExec jwt token
Example
// account.auth
Parameters
contracts
Object an iexec contracts objectamount
String the amount of nano RLC to deposit in iExec accountoptions
Object [optional] optionsoptions.hub
String custom hub address
Return (Promise)
txReceipt
Object the ethereum transaction receipt
Example
// account.deposit
Parameters
contracts
Object an iexec contracts objectamount
String the amount of nano RLC to deposit in iExec accountoptions
Object [optional] optionsoptions.hub
String custom hub address
Return (Promise)
txReceipt
Object the ethereum transaction receipt
Example
// wallet.withdraw
Parameters
objName
String the object type name (app|workerPool|dataset)
Return Below Function:
Parameters
contracts
Object an iexec contracts objectobj
Object the object to createoptions
Object [optional] optionsoptions.hub
String custom hub address
Return (Promise)
events
Object the decoded logs from the transaction receipt
Example
// hub.createObj
Parameters
objName
String the object type name (app|workerPool|dataset)
Return Below Function:
Parameters
contracts
Object an iexec contracts objectobjAdressOrIndex
String the object address or indexuserAddress
String the user address to query foroptions
Object [optional] optionsoptions.hub
String custom hub address
Return (Promise)
obj
Object All the properties of the object
Example
// hub.showObj
Parameters
objName
String the object type name (app|workerPool|dataset)
Return Below Function:
Parameters
contracts
Object an iexec contracts objectuserAddress
String the user address to query foroptions
Object [optional] optionsoptions.hub
String custom hub address
Return (Promise)
objCount
BN The total count of object
Example
// hub.countObj
If your program is not written in javascript, your last option to use the SDK would be to spawn it as a seperate process (sometimes called FORK operation). After each SDK run you should check the exit code returned by the SDK to know if the operation was sucessfull or not echo $?
:
- 0 = successful
- 1 = error
Finally, you could choose to parse the SDK stdout/stderr to access more information. ex:
iexec orderbook show &> out.txt
iexec orderbook show |& grep .
Warning:
- The stdout/stderr is subject to changes (this is what makes this solution brittle)
- The node and docker version have some slight differences in their stdout/stderr