Usage

How to use Shipl-Wallet in your dApp.

Preparation

Before attempting to integrate, you'll need to create an account in Shipl's console. Head on over to console.shipl.co to create it to start this process.

After a short time, you should receive an email into your account, click on the link, you will follow a tutorial to create your first app.

Dapp Quick Start

In this first example, we'll show the Shipl-Wallet SDK being used as a meta-transaction provider and cloud wallet for your customers. We'll require the customer to authenticate with their phone number. After sign-in, they will be able to connect to your dApp and process "etherless" transactions.

In this example you will replace "YOUR_SHIPL_APP_ID" with the appID from an app created in your Shipl account. The network used is the one defined by your appId on https://shipl.co/

import Shipl from 'shipl';
const shiplwallet = await Shiplwallet.create({ appId: "YOUR_SHIPL_APP_ID" })

Never instantiate with new keyword! Always use create method.

Your appId is available on https://console.shipl.co/

Shipl deploy an identity contract for every users, so the "identity" variable correspond to the user's identity contact for the selected network. The web3.eth.getAccounts method return the address controlling the identity contract (one or multiples of them can be stored in the Shipl's HSM)

Because the Shipl-Wallet SDK is a web3 provider, your next step is to pass the Shipl-Wallet SDK into any web3 compatible library.

const web3 = new Web3(shiplwallet.getWeb3Provider())

Example of how to get your identity address and your signer address

const identity = shiplwallet.shiplID.auth.identity
// console.log(identity) -> The address of your Identity contract
const account = (await web3.eth.getAccounts())[0]
// console.log(account) -> The address of your Shipl Wallet

Then you call your smart contract in the regular web3 way.

const contract = new web3.eth.Contract(abi, contractAddress);
contract.methods.register(identity, 1) // we use the identity to represent the user
.send({
from: account // we use the account to sign the transaction
})
.on('transactionHash', transactionHash => {
console.log('This the transactionHash', transactionHash);
});

Examples

We have developed a very cool dApp to show you how Shipl and Shipl-Wallet can make the UX of your dApp smooth and easy to use by a 5 years old baby. Play with it at: demo.shipl.co and see the code here.

Sign in & Sign up

You just have to put your phone number to sign in shipl-wallet. If your phone number is used for the first time, it will be automatically registered.

Shipl-Wallet's sign in and sign up are the same, the user don't have to care if he has already an account or not.

Your First Shipl dApp is now ready! 🎉

After putting the 4 code snippets above into your code, your app is now blockchain enabled!