JavaScript

Note: The package has not been published, please contact us or fill out this form for access

Our foundational package, crafted to interface directly with your backend, retrieves essential insurance information tailored for your project. Flexible in its application, it's designed to function smoothly whether integrated into your project's frontend or backend, ensuring a seamless connection to Web3Shield's insurance services.

Installation

npm install @web3shield/insurance-core

Implementation

In your main.js setup the following

import { W3SInsurance } from "@web3shield/insurance-core";

// Initialize W3SInsurance with your API key
const apiKey = "your-api-key";
const web3shield = new W3SInsurance(apiKey);

async example = () => {
    const user = '0xuserAddress';
    const amount = 100;
    const source = 'source_chain_id';
    const destination = 'destination_chain_id';
    const sourceToken = '0xsourceTokenAddress';
    const destinationToken = '0xdestinationTokenAddress';

    const result = await web3shield.getInsurance(
      user,
      amount,
      source,
      destination,
      sourceToken,
      destinationToken
    );
}

Types

W3SInsurance

Constructor

Parameter
Type
Description

apiKey

string

Web3Shield Project API Key

logs

boolean

Enable or disable logs, false by default

environment

mainnet | testnet | local

Select which Web3Shield environment to operate in, local by default

getInsurance()

Parameter
Type
Description

user

string

Address of the user opting in for insurance

amount

string | number | BigNumber

Amount of sourceToken being bridged

source

string

Chain ID of the source chain

destination

string

Chain ID of the destination chain

sourceToken

string

Address of the source token

destinationToken

string

Address of the destination token

Return Value
Type
Description

message

string

Relevant success/error message

premium

float

Premium amount to be paid to cover amount of sourceToken

minimumPremium

float

Minimum premium amount to be paid (in USD)

validTill

number

Epoch until which the policy is valid

Last updated