aneopsy / VaultX-SDK

Web3 Provider for the Shipl API.

Home Page:https://shipl.co

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shipl JS SDK

Browser and NodeJS web3 provider for the Shipl API

Integrate Shipl in your Dapp

The Shipl SDK provides convenient access to the Shipl API into your javascript dApp. Shipl enable developers to create ethereum dApp without the usual UX complexity by abstracting the gas and making feesless transactions for the end user.

Documentation

See the API documentation

Installation

You can install the library via npm:

> npm i shipl

Usage

In order to use it, just import the library and pass the previous params in the constructor. By default the library is loaded with the following value, so you just have to pass a private key and then you can start to use Fuel.

The package need to be configured with an ethereum private key or a web3 wallet instance (eg. Metamask)

import Shipl from 'shipl';

const shipl = new Shipl({
    privateKey: "YOUR_PRIVATE_KEY", // You can provide a private key to shipl
    web3Provider: window.web3, // Or a web3 compatilbe wallet like Metamask
    network: 'rinkeby' // Can be rinkeby, ropsten or kovan (mainnet not available yet)
})

Then login into shipl. You have to pass an input callback to make the shipl SDK capable to ask for the phone number and then for the code verifcation send by SMS. For example on node you can use readline-sync.

const { identity, deviceKey } = await shipl.login(readline.question)

Then pass you can pass the shipl sdk into any web3 compatible library. Don't forget to execute the start function to launch the web3 provider.

const web3 = new Web3(shipl.start());

Then you can call a contract in the regular web3 way

const targetContract = new web3.eth.Contract(abi, contractAddress);

targetContract.methods
  .register('0x' + config.address, 1)
  .send({
    from: '0x' + config.address
  })
  .on('error', error => {
    console.log(error);
  })
  .on('transactionHash', transactionHash => {
    console.log('This the transactionHash', transactionHash);
  });

Finnaly you can get the internal transaction data by passing the txHash and contract abi to the method below.

const internalTxDatas = await shipl.getInternalTransactionsData(abi, txHash)

Browser Window Quick Start

For use directly in the browser you can reference the shipl distribution files from a number of places. They can be found in our npm package in the 'dist' folder or you can build them locally from this repo.

For a quick setup you may also request a remote copy from unpkg CDN as follows:

<!-- The most recent version  -->
<script src="https://unpkg.com/shipl/dist/shipl.js"></script>
<!-- The most recent minified version  -->
<script src="https://unpkg.com/shipl/dist/shipl.min.js"></script>
<!-- You can also fetch specific versions by specifying the version, files names may differ for past versions -->
<script src="https://unpkg.com/shipl@<version>/dist/shipl.js"></script>

To see all available dist files on unpkg, vist unpkg.com/shipl/dist

Then to instantiate the shipl object from the browser window object:

const Shipl = window.shipl
const shipl = new Shipl({ privateKey, network })

Examples

For a more in depth guide, check out our documentation site or clone this repository and check out the sample apps in the /examples folder.

About

Web3 Provider for the Shipl API.

https://shipl.co


Languages

Language:JavaScript 100.0%