SDK integration

SDK integration

SDK a basic understanding of Javascript/Typescript and installed Web3.

You can easily install the SDK using the command:

// with npm
npm install bridgemuual

// or with yarn
yarn add bridgemutual

Purchase policy

import {_getWhitelistedContracts, getCoverageApprove, provideCoverage} from 'bridgemutual';

//returnts list of whitelisted contracts
param {Object} web3 - instance of web3
param {Boolean} isTest - for use Rinkeby TestNet
_getWhitelistedContracts(web3, isTest).then(policies => {
    //policies <== list of policies
})

//returns approved contract
param {Number} id - Id of policy
param {Object} web3 - instance of web3
param {Number} weeks - period of policy
param {Number} amount - amount of policy
param {String} userAddress - user address (in ETH)

getApprove(id, web3, weeks, amount, userAddress).then(approvedContract => {
    //approvedContract  <== list of policies
})

//returns policy price
param {String} userAddress - user address (in ETH)
param {Number} id - Id of policy
param {Number} amount - amount of policy
param {Number} weeks - period of policy
param {Object} web3 - instance of web3

getPolicyPrice(userAddress, id, amount, weeks, web3).then(policyPrice => {
    //policyPrice  <== policy price in USDT
})

//returns current allowance
param {Object} web3 - instance of web3
param {String} userAddress - user address (in ETH)
param {Number} id - Id of policy
param {Boolean} isTest - for use Rinkeby TestNet

getAllowance (web3, userAddress, id, isTest).then(currentAllowance => {
    //currentAllowance  <== current allowance
})

//returns current allowance
param {Object} web3 - instance of web3
param {String} userAddress - user address (in ETH)
param {Number} id - Id of policy
param {Boolean} isTest - for use Rinkeby TestNet

resetAllowance(web3, userAddress, id, isTest).then(currentAllowance => {
    //currentAllowance  <== current allowance equal 0
})

//returns current allowance
param {Object} web3 - instance of web3
param {String} userAddress - user address (in ETH)
param {Number} id - Id of policy
param {Number} policyPrice - from getPolicyPrice method 
param {Boolean} isTest - for use Rinkeby TestNet

setAllowance (web3, userAddress, id, policyPrice, isTest).then(currentAllowance => {
    //currentAllowance  <== current allowance
})

//returns policy purchase result
param {Number} id - Id of policy
param {Object} web3 - instance of web3
param {String} userAddress - user address (in ETH)
param {Number} weeks - period of policy
param {Number} amount - amount of policy
param {String} referralAddress - user address (in ETH)

buyPolicy(id, web3, userAddress, weeks, amount, referralAddress).then()

Display purchased policies

import {_getWhitelistedContracts, getCoverageApprove, provideCoverage} from 'bridgemutual';

//returnts list of whitelisted contracts
param {Object} web3 - instance of web3
param {Boolean} isTest - for use Rinkeby TestNet
_getWhitelistedContracts(web3, isTest).then(policies => {
    //policies <== list of policies
})

//returns list of purchased policies
param {Object} web3 - instance of web3
param {String} userAddress - user address (in ETH)
param {Boolean} active - active/unactive policies
param {Number} offset - offset
param {Number} limit - limit
param {Boolean} isTest - for use Rinkeby TestNet

getPurchasedPolicies (web3, userAddress, active, offset, limit, isTest).then(listPurchasedPolicies => {
    //listPurchasedPolicies  <== list purchased policies
})

Earn Interest

import {_getWhitelistedContracts, getCoverageApprove, provideCoverage} from 'bridgemutual';

//returnts list of whitelisted contracts
param {Object} web3 - instance of web3
param {Boolean} isTest - for use Rinkeby TestNet
_getWhitelistedContracts(web3, isTest).then(policies => {
    //policies <== list of policies
})

//returns current allowance
param {Object} web3 - instance of web3
param {String} userAddress - user address (in ETH)
param {Number} id - Id of policy
param {Boolean} isTest - for use Rinkeby TestNet

getAllowance (web3, userAddress, id, isTest).then(currentAllowance => {
    //currentAllowance  <== current allowance
})

//returns current allowance
param {Object} web3 - instance of web3
param {String} userAddress - user address (in ETH)
param {Number} id - Id of policy
param {Boolean} isTest - for use Rinkeby TestNet

resetAllowance(web3, userAddress, id, isTest).then(currentAllowance => {
    //currentAllowance  <== current allowance equal 0
})

//returns current allowance
param {Object} web3 - instance of web3
param {String} userAddress - user address (in ETH)
param {Number} id - Id of policy
param {Number} amount - amount of coverage
param {Boolean} isTest - for use Rinkeby TestNet

setAllowance (web3, userAddress, id, amount, isTest).then(currentAllowance => {
    //currentAllowance  <== current allowance
})

//returns coverage provided result
param {Number} id - Id of policy
param {String} userAddress - user address (in ETH)
param {Number} amount - amount of coverage

provideCoverage(id, userAddress, amount).then()

Last updated