InsurAce Protocol
  • Welcome to InsurAce.io
  • V2 Updates
  • About InsurAce.io
    • Overview
      • Why InsurAce.io
      • What is InsurAce.io
      • Use Cases
      • Architecture
    • Cover Products
      • Product List
      • Smart Contract Vulnerability Cover
      • Stablecoin De-Peg Cover
      • Ethereum Slashing Cover
      • Bridge Cover
        • LI.FI Bridge Cover
      • Custodian Risk Cover
      • Post-Audit Cover
      • Risk Transfer Cover
      • Bundled Cover [Not Avaliable]
    • Protocol
      • Pricing Models
      • Capital Management
      • Risk Assessment
        • Security Rating Methodology
      • Governance
        • Data Publications
      • Investment
      • Mining
        • Staking Mechanisms
        • Staking Risks
    • Tokenomics
      • Token Buyback
    • Security
    • Roadmap
    • Coverage Request
      • Apply to be Listed
    • Refer & Earn Program
      • Direct Sharing
      • Customize Referral Link
    • FAQs
    • Disclaimers
    • Contact Us
      • Twitter
  • Documentation
    • User Guide
      • Buy Cover Guides
        • General Guide
        • Ethereum Slashing Cover Guide
      • Claim Guides
        • General Guide
        • Ethereum Slashing Cover Guide
        • Evidence Checklist
      • Cancel cover
      • Launch DAPP & Connect Wallet
        • MetaMask Installation & Configuration
      • Claim Assessors
      • Advisory Board
      • Underwriting Mining (Stake & Unstake)
      • Liquidity Mining
        • UniSwap
      • Harvest Rewards
      • Token Bridge
        • Step 1: MetaMask installation & Configuration
        • Step 2: Bridge
        • Step 3: View Bridging Status
        • Step 4: Check Proof of Assets
      • Governance
        • Get veINSUR and veNFT
        • Unlock and Harvest
        • Submit Proposal
        • Cancel Proposal
        • Vote Proposal
        • Harvest Voting Rewards
        • Mining Pool Gauge
        • Cover Capacity Gauge
        • Committee Member Nomination
        • Committee Member Removal
    • Claim Records
    • Whitepaper
  • Developer Reference
    • Service Integration
      • APIs for service integration
      • Smart Contract ABI
      • UI integration
      • InsurAce.io APIs Docs
    • Smart Contract Addresses
  • PR & Marketing
    • Branding & Media Kit
  • External Links
    • Website
Powered by GitBook
On this page
  • Access Key
  • Get $INSUR token information
  • Retrieve product information
  • Buy cover
  • Step 1: Configuration
  • Step 2: Call function
  • Cancel Cover
  • Step 1: Configuration
  • Step 2: Call function

Was this helpful?

  1. Developer Reference
  2. Service Integration

APIs for service integration

How to request for the services provided by InsurAce.io

PreviousService IntegrationNextUI integration

Last updated 4 months ago

Was this helpful?

InsurAce.io APIs currently supports the following services:

  • Get $INSUR token information

  • Retrieve product information

  • Buy cover

  • Cancel cover

More APIs will be added soon.

The APIs are documented using Swagger. For details, please check:

Access Key

Some APIs may require a key to access, here is a public shared key:

dRsOlTd0UDcMkcCtunc7exPLz3eVnwikjNV4sebGalfq1qWpEzECQg==

  • If you find any problems using the key, please contact the technical team via , or email to operations@insurace.io .

  • Project teams or institutional users who need larger traffic, kindly reach out to our marketing/BD team via , to request for an exclusive key for Partners.

Get $INSUR token information

To get the total and circulating supply of $INSUR, you can call these APIs:

getCirculation : get the sum of $INSUR in circulation on different networks

getTotalAmount : get the sum of all $INSUR on different networks

Retrieve product information

To retrieve product information such as product price, capacity, protocol name and etc. (Access Key required)

getProductList : Return a list of all products covered with details such as product id, name, capacity, product price, etc.

getCurrencyList : Return a list of tokens that can be used to purchase the cover with details such as token name, contract address, etc.

getCoverPremiumV2 : Return the price for a cover.

Buy cover

The full sample code for buying cover using JS code can be found here

You can follow the instruction there to run the test code.

Below is a step-by-step illustration of the JS code:

Step 1: Configuration

Prior to calling the APIs, you need to configure the following parameters first, here is a sample code:

//---------------------------------------
// Configuration
//---------------------------------------

// The JSON RPC URL that connects to an Ethereum node.
const jsonRpcUrl = '';

// The private key of a wallet that is used to purchase this cover.
const privateKey = '';

// The address of InsurAce Cover contract. Please contact InsurAce team to get the contract address.
// Different chains have different addresses.
const contractAddress = '';

// The URL of InsurAce API.
const httpApiUrl = 'https://api.insurace.io/ops/v1';

// The API key that allows consumers to access InsurAce API.
const httpApiCode = '';

// The blockchain that the cover purchase transaction is sent to. Valid values are ETH, BSC,
// POLYGON, AVALANCHE.
const chain = 'ETH';

// The address of the token used to specify the cover amount. Please check
// https://api.insurace.io/docs for a list of tokens that can be used to purchase covers.
const coverCurrency = '';

// The address of the token used to purchase this cover. Must be the same as coverCurrency.
const premiumCurrency = '';

// The product IDs for this cover purchase. Can be more than 1 product IDs. Please check
// https://docs.insurace.io/landing-page/documentation/protocol-design/product-design/product-list
// for a complete list of products.
const productIds = [1, 2];

// The cover period (in days) for each product.
const coverDays = [30, 90];

// The cover amount for each product.
const coverAmounts = [utils.parseEther('1000').toString(), utils.parseEther('2000').toString()];

// The wallet addresses protected by the cover for each product. Each product must correspond to
// a wallet addresses (the same wallet address may be specified multiple times).
const coveredAddresses = [];

// The referral code used in this cover purchase, may be null.
const referralCode = null;
  • httpApiCode: API access key

  • coverCurrency: token address can be retrieved by calling getCurrencyList API

Step 2: Call function

To buy covers, you need to use the following functions:

  • getCoverPremium()

Get the price of the cover by calling getCoverPremium API with the parameters specified in Step 1 includes chain, productIds, coverDays, coverAmounts, coverCurrency, owner wallet address and referralCode.

async function getCoverPremium(option) {
  const body = {
    chain: option.chain,
    owner: option.owner,
    coverCurrency: option.coverCurrency,
    premiumCurrency: option.premiumCurrency,
    productIds: option.productIds,
    coverDays: option.coverDays,
    coverAmounts: option.coverAmounts,
    coveredAddresses: option.coveredAddresses,
    referralCode: option.referralCode,
  };

  const options = {
    params: {
      code: httpApiCode,
    },
  };

  const { data } = await axios.post(httpApiUrl + '/getCoverPremiumV2', body, options);

  return {
    premium: data.premiumAmount,
    params: data.params,
  };
}
  • confirmCoverPremium()

Confirm the price by calling confirmCoverPremiumAPI using the results getting from the above function as the parameter.

async function confirmCoverPremium(option) {
  const body = {
    chain: option.chain,
    params: option.params,
  };

  const options = {
    params: {
      code: httpApiCode,
    },
  };

  const { data } = await axios.post(httpApiUrl + '/confirmCoverPremiumV2', body, options);

  return {
    params: data,
  };
}
  • buyCover()

Buy the cover with the confirmed information above.

async function buyCover(wallet, params) {
  const contractAbi = [
    'function buyCoverV3(uint16[] products, uint16[] durationInDays, uint256[] amounts, address[] addresses, uint256 premiumAmount, uint256 referralCode, uint256[] helperParameters, uint256[] securityParameters, string freeText, uint8[] v, bytes32[] r, bytes32[] s) payable',
  ];

  const contract = new Contract(contractAddress, contractAbi, wallet);

  const response = await contract.buyCoverV3(params[0], params[1], params[2], params[3], params[4], params[5], params[6], params[7], params[8], params[9], params[10], params[11]);

  const receipt = await response.wait();

  return receipt;
}

Once done, you can call those functions in sequence. Here is a sample code for you:

// -------------------------------------------------------------------
// Main
// -------------------------------------------------------------------

async function main() {
  const provider = new providers.JsonRpcProvider(jsonRpcUrl);
  const wallet = new Wallet(privateKey, provider);

  console.log('1. Get premium');

  const premiumInfo = await getCoverPremium({
    chain,
    owner: wallet.address,
    coverCurrency,
    premiumCurrency,
    productIds,
    coverDays,
    coverAmounts,
    coveredAddresses,
    referralCode,
  });

  console.log(`Premium = ${utils.formatEther(premiumInfo.premium)}`);

  console.log('2. Confirm premium');

  const confirmInfo = await confirmCoverPremium({
    chain,
    params: premiumInfo.params,
  });

  console.log('3. Purchase cover');

  const receipt = await buyCover(wallet, confirmInfo.params);

  console.log('Cover purchase successful.');
  console.log(`Transaction hash: ${receipt.transactionHash}`);
}

main();

Cancel Cover

The full sample code for buying cover using JS code can be found here

You can follow the instruction there to run the test code.

Below is a step-by-step illustration of the JS code:

Step 1: Configuration

Prior to calling the APIs, you need to configure the following parameters first, here is a sample code:

//---------------------------------------
// Configuration
//---------------------------------------

// The JSON RPC URL that connects to an Ethereum node.
const jsonRpcUrl = '';

// The private key of a wallet that is used to cancel the cover.
const privateKey = '';

// The address of InsurAce Cover contract, ask InsurAce team to get address
// different chain has different addresses.
const contractAddress = '';

// The ID of the cover pending to be cancelled.
const coverId = '';

Step 2: Call function

To cancel cover, you need to use the function below:

  • cancelCover()

Cancel the cover with the coverID set in step 1 above.

async function cancelCover(wallet, pendingCancelCoverId) {
  const contractAbi = [
    'function cancelCover(uint256 coverId)',
  ];

  const contract = new Contract(contractAddress, contractAbi, wallet);

  const response = await contract.cancelCover(pendingCancelCoverId);

  const receipt = await response.wait();

  return receipt;
}

You can call the function using the sample below:

// -------------------------------------------------------------------------------------------------
// Main
// -------------------------------------------------------------------------------------------------

async function main() {
  const provider = new providers.JsonRpcProvider(jsonRpcUrl);
  const wallet = new Wallet(privateKey, provider);

  console.log(`Cancel cover with ID ${coverId}`);

  const receipt = await cancelCover(wallet, coverId);

  console.log('Cover cancellation successful.');
  console.log(`Transaction hash: ${receipt.transactionHash}`);
}

main();ode

productIds: Can be more than 1 IDs, which can be retrieved from or by calling getProductList API

Telegram
Discord
Telegram
Discord
👉
Example - Buy Cover
Product List
👉
Example - Cancel Cover