Integrate MTO Custom driver into mobile applications

Integrating the mto-custom-driver is very simple.

You will need at least node version 14 installed in your system.

Installation

To obtain the latest version, simply require the project using npm or yarn:

npm i mto-custom-driver

or

yarn add mto-custom-driver

Use SDK with react native

To use the SDK with React native a special package should be imported:

import "@ethersproject/shims";

How to use custom SDK in nodejs based app (goerli testnet)

import { MTOCustomDriver } from 'mto-custom-driver'; // TODO check import types issue

const MTO_BLOCKCHAIN = 'goerli-testnet';
const scDriver = new MTOCustomDriver({
        blockchain: MTO_BLOCKCHAIN,
        privateKey: privateKey,
 });
await scDriver.init();
const result = await driver.purchase(
        PRODUCT_ID,
        MERCHANT_ADDRESS,
        amount,
        DISPUTABLE_TIME,
        WITHDRAW_TIME,
        { gasLimit: 800000 }
      );

Parameters:

NameIs RequiredDescription
PRODUCT_IDYesid of the product generated from the backend.
MERCHANT_ADDRESSYesMerchant wallet address
amountYesPrice of the product in wei value in MTO token
DISPUTABLE_TIMEYesA customer can dispute after this time passed.
WITHDRAW_TIMEYesAfter this time a customer can not submit dispute. It is assumed that the product has been delivered properly.