iExecBlockchainComputing / iexec-sdk
- воскресенье, 22 апреля 2018 г. в 00:17:48
JavaScript
iExec CLI client to develop, deploy and execute Dapps relying on iExec stack
iExec allows Ethereum developers to create applications that can be executed off-chain. This package brings all the tools to develop, deploy and execute Dapps on Ethereum and iExec. Using these tools, you will be able to deploy any legacy applications in the iExec infrastructure and execute them through calls to Ethereum smart contracts.
Requirements: and Git.
npm -g install iexec # install the cli
iexec --version
iexec --help
Windows users need to create an alias by running
for /f "delims=|" %i in ('where iexec') do doskey iex="%i" $*
to avoid a naming conflict. Then always useiex
instead ofiexec
when using the SDK.
Requirements: Docker.
# For Linux users
echo 'alias iexec='"'"'docker run --interactive --tty --rm -v $(pwd):/iexec-project -w /iexec-project iexechub/iexec-sdk'"'"'' >> ~/.bashrc && source ~/.bashrc
# For Mac OSX users
echo 'alias iexec='"'"'docker run --interactive --tty --rm -v $(pwd):/iexec-project -w /iexec-project iexechub/iexec-sdk'"'"'' >> ~/.bash_profile && source ~/.bash_profile
Now run iexec --version
to check all is working.
npm -g install iexec
docker pull iexechub/iexec-sdk
Before any use of the SDK, make sure you did run once the below steps:
iexec init # init a project
cd iexec-init # enter the project
iexec wallet create # create a wallet
iexec wallet getETH # get some ETH
iexec wallet getRLC # get some RLC
iexec wallet show # check you received the tokens
iexec account allow 5 # credit your account with RLC
iexec account show # check your iExec account balance
Go checkout the run a dapp tutorial, recap below:
After the init steps, go to iExec dapp store and find the dapp you'd like to use, say ffmpeg:
iexec.js
with the one of the dapp (you can find it on the github page of the dapp)And submit your work to the dapp address:
iexec submit --dapp <dapp_address>
Finally, copy the transaction hash given by the SDK and check the progress of your work:
iexec result <txHash> --dapp <dapp_address>
Note: The iExec explorer provides a more visual experience.
Go checkout the Hello World tutorial
Go checkout the Ffmpeg step by step tutorial
iexec --help
iexec --version
To interact with the iExec dapps registry
iexec init # pull a basic project
iexec init factorial # pull factorial branch from iExec dapp registry
iexec init <branch> --repo <my_github_repo> # pull from custom dapp registry
iexec compile # call truffle compile underhood
iexec migrate # call truffle migrate underhood
iexec truffle [...] # or just call any truffle command
iexec wallet create
iexec wallet getETH
iexec wallet getRLC
iexec wallet show
iexec wallet sendETH <amount> --to <eth_address> --chain ropsten
iexec wallet sendRLC <amount> --to <eth_address> --chain ropsten
iexec wallet sweep --to <eth_address> --chain ropsten # drain all ETH and RLC, sending them back to iExec faucet by default
iexec account login
iexec account show
iexec account allow 5
iexec deploy --chain ropsten # Deploys the smart contract on ethereum + deploy the app on iExec offchain platform
iexec submit --chain ropsten # submit work to your own dapp
iexec submit --dapp 0xE22F4... --chain ropsten # submit work to someone else dapp address
You need the txHash of a work submission in order to check its result:
iexec result <txHash> --chain ropsten # this will log the result data
iexec result <txHash> --save --chain ropsten # this will download the result locally
iexec upgrade # update iExec CLI tool and upgrade iExec project
iexec server version # get server version
iexec server deploy # deploy legacy app only to iExec server
iexec server uploadData <data_path> # direct data upload
iexec server submit --app <app_uid> # direct work submit
iexec server result <workUID> # direct result
iexec server api <fnName> [arg1] [arg2] ... # directly call api method
The iexec.js
file, located in every iExec project, describes the parameters used when deploying an app, and when submitting a work.
module.exports = {
name: 'Factorial',
// app tags used once when deploying app to iExec server
// iexec deploy
app: {
type: 'DOCKER',
envvars: 'XWDOCKERIMAGE=cogniteev/echo',
},
// work tags used for each work submit
// iexec submit
work: {
cmdline: 'iExec',
},
};
The truffle.js
file, located in every iExec project, describes the parameters used when communicating with ethereum and iexec nodes.
module.exports = {
networks: {
ropsten: {
// ETH node relay config
host: 'https://ropsten.infura.io/berv5GTB5cSdOJPPnqOq',
port: 8545,
network_id: '3',
constructorArgs: [ROPSTEN_ORACLE_ADDRESS],
// iExec server used to deploy legacy app
server: 'https://testxw.iex.ec:443',
// gasPriceMultiplier: 2, // use factor 2 of the network estimated gasPrice
// gasLimitMultiplier: 4, // use factor 4 of the network estimated gasLimit
// gasPrice: 21000000000 // manually set the gasPrice in gwei. Prefer 'gasPriceMultiplier'
// gas: 400000 // manually set the gas limit in gwei. Prefer 'gasLimitMultiplier'
},
};