The Bright Union SDK is a set of javascript utilities that enables an easy integration of the Bright Union's multi-chain protocol into any web project.
This SDK will give you access to the Bright Union aggregator contract that combines risk coverage services from:
A swagger API documentation can be found here.
- Node v14+
- Blockchain client node provider:
- infura, quicknode, anyblock etc...
Quotation support for Nexus provider is only allowed by white-listing your URL, please contact us for support and we will add your app to Nexus supported URL's. Not doing so, will cause Nexus quotations throwing 403 error. Other quotations from other providers will load.
npm install @brightunion/sdk
getCatalog()
getQuotes( <amount> , <currency> , <period> , <productId> )
getQuoteFrom( <distributorName>, <amount>, <currency>, <period>, <productId>)
buyQuote(<preExistingQuote>)
getCoversFrom(<DistributorName>)
getAllCovers()
const BrightClient = require('@Brightunion/SDK');
const brightClient= new BrightClient({ <web3_instance> });
// Initialize the client
await brightClient.initialize();
// Get catalog of all risk covers available
const catalog = brightClient.getCatalog();
// Get quotes for a catalog item from all risk providers available
const quotes = brightClient.getQuotes( <amount> , <currency>, <period>, <catalog_item> )
// Buy quoted cover
brightClient.buyQuote( <quote> ).then(data => {
// Transaction done
})
// Get purchased covers from all distributors
const coversAll = await brightClient.getAllCovers();
const BrightClient = require('@Brightunion/SDK');B
const brightClient= new BrightClient({ <web3_instance> });
// Initialize the client
await brightClient.initialize();
// Define a Catalog Item from a supported insurance distributor
// INSURACE catalog item example
const catalogItemInsurace = { productId: <Insurace_product_id> };
// BRIDGE catalog item example
const catalogItemBridge = { bridgeProductAddress: <Bridge_product_address> };
// NEXUS catalog item example
const catalogItemNexus = { nexusCoverable: <Nexus_product_address> };
// Get quote from specific distributor on a catalog item
const quote = await brightClient.getQuoteFrom( <distributorName>, <amount> , <currency>, <period>, <catalog_item>);
// Buy quoted cover
brightClient.buyQuote( <quote> ).then(data => {
// Transaction done
})
Quote and buy multiple covers in one transaction. Currently supported only for covers from Insurace.
const BrightClient = require('@Brightunion/SDK');B
const brightClient= new BrightClient({ <web3_instance> });
// Initialize the client
await brightClient.initialize();
// Get catalog of all risk covers available
const catalog = brightClient.getCatalog();
// Get multiple quotes
const quotesArray = await brightClient.getMultipleQuotes([catalog[0], catalog[1], catalog[3]]);
// Buy multiple quotes
await brightClient.buyQuotes(quotesArray).then(data => {
// Transaction done
});
When provider (Metamask, Trust, WalletConnect etc.) network is switched, new Bright Client should be initialized with the new instance of Web3.
const brightClient= new BrightClient({ <web3_instance> });
// Initialize the client
await brightClient.initialize();
Events are fired before the main function returns the final response
brightClient.events.on(<eventName> , ()=> {})
Events which are currently supported are for methods related to Quotation and Buy
- "quote"
- "buy"
brightClient.events.on("buy" , (data)=> {})
brightClient.events.on("quote" , (data)=> {})