npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

iexec-server-js-client

v2.0.3

Published

JS client to interact with iExec REST API

Downloads

6

Readme

iexec-server-js-client

Build Status npm version license

JS client lib to interact with iExec server REST API

Ressources

  • The iExec server API doc: https://serverapi.iex.ec
  • The iExec SDK
  • The iExec main documentation: https://docs.iex.ec

Examples

Below are examples showcasing the use of the library in the most common worklow:

1. Create iExec client

iExec server URL:

  • tesnet (ropsten / rinkeby / kovan): https://testxw.iex.ec:443
  • mainnet: https://mainxw.iex.ec:443
const createIEXECClient = require('iexec-server-js-client');
const iexec = createIEXECClient({ server: 'https://testxw.iex.ec:443' });

2. Auth

Authenticate before hitting iExec API:

iexec.auth(web3.currentProvider, accountAddress).then(({ jwtoken, cookie }) => {
  console.log(jwtoken); // this is given by auth.iex.ec server
  console.log(cookie); // this is given by iExec server
  // hit iExec server API
  iexec.getAppByName(deployTxHash).then(console.log); // print app description from deploy txHash
  iexec.getWorkByExternalID(submitTxHash).then(console.log); // print work description from submit txHash
});

If you already have your JWT token, no need to do full auth (avoid wallet signing):

iexec.getCookieByJWT('my_jwt_token').then(cookie => {
  // hit iExec server API
  iexec.getByUID(workUID).then(console.log); // print work description
});

3. Submit a work

Call the dapp smart contract "iexecSubmit" method to submit a work (for reference only, not part of this repo library):

const oracleJSON = require('iexec-oracle-contract/build/contracts/IexecOracle.json');
const work = '{"cmdline":"10"}'

const oracleContract = web3.eth
  .contract(oracleJSON.abi)
  .at(oracleJSON.networks[chainID].address);
const callbackPrice = await oracleContract.callbackPrice();

const dappContract = web3.eth
  .contract(dappSubmitABI)
  .at(dappAddress);

// this is the work submit
const txHash = await dappContract.iexecSubmit(work, {
  value: callbackPrice[0].toNumber(),
});

4. Wait for work result

After submitting a work through Ethereum, use the transaction hash (txHash) to wait for the work result:

iexec
  .waitForWorkResult(oracleContract.getWork, txHash)
  .then(workResultURI => iexec.createDownloadURI(workResultURI))
  .then(console.log); // let user open this URL in the browser to download the work result