📂
Bridge Mutual
Bridge Mutual WebsiteTelegram GroupTwitter
  • Etherscan interaction guides
    • BMI tokens
      • Old (v1) BMI staking
    • USDT tokens
  • Bridge Mutual: Overview
    • Understanding the Dashboard
  • Glossary
  • Staking
    • Native BMI staking
    • Native BMI staking update
  • Policies
  • Buying coverage
    • Buying Coverage Policies
  • Types of coverage
    • 📄Smart Contract
    • 📌De-pegging
    • 🎩Custodian
  • Making a claim
  • Claim voting process
    • How to Vote
  • Reputation and reward system
    • How to receive rewards
  • Coverage
    • Coverage pools
      • Making a Coverage Pool
    • Providing coverage
      • Providing Coverage Liquidity
    • Withdrawing coverage
    • Rewards for coverage providers
    • SushiSwap Liquidity & Staking
  • V2
    • Overview
    • Leveraged Portfolios
      • Providing Leveraged Coverage
    • Capital & Reinsurance Pools
    • Shield Mining
      • Participating in Shield Mining
    • Bridge Mutual Widget
      • Widget integration
        • SDK integration
        • Solidity contract integration
        • Javascript integration
    • Migration to V2 Notes
    • BMI Bridge
      • How to use the Bridge
  • Other
    • Media Kit
    • Links
    • FAQ
    • Governance
    • Roadmap
    • Allowance
  • Legacy events and info
    • Claiming rewards and the inflation mitigation mechanism
    • Coverage Mining Event: 09.07.2021 - 23.07.2021
Powered by GitBook
On this page

Was this helpful?

  1. V2
  2. Bridge Mutual Widget
  3. Widget integration

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()
PreviousWidget integrationNextSolidity contract integration

Last updated 2 years ago

Was this helpful?