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:
Name | Is Required | Description |
---|---|---|
PRODUCT_ID | Yes | id of the product generated from the backend. |
MERCHANT_ADDRESS | Yes | Merchant wallet address |
amount | Yes | Price of the product in wei value in MTO token |
DISPUTABLE_TIME | Yes | A customer can dispute after this time passed. |
WITHDRAW_TIME | Yes | After this time a customer can not submit dispute. It is assumed that the product has been delivered properly. |
Updated almost 2 years ago