SDK Integration
To use the InstaFi with your Angular, React or Vue application, you will need to use @instafi/instafi-sdk (InstaFi’s JavaScript SDK).
Add the InstaFi SDK as a dependency using yarn
or npm
:
# Using yarn
$ yarn add @instafi/instafi-sdk
# Using npm
$ npm install @instafi/instafi-sdk
Connecting the SDK to InstaFi
import { InstafiSDK } from 'instafi-sdk';
const launcher = new InstafiSDK({
width: '[WIDTH]', //Width of widget
height: '[HEIGHT]', //Height of weidget
environment: '[ENVIRONMENT]', //STAGING or PRODUCTION
tokens: [ //List of tokens to purchase
{token:'[TOKEN_ID]' //Token name like "WETH" or token contract address
share: '[TOKEN_SHARE]' //Percentage of start amount used to purchase this token - 0.1 is 10% and 1 is 100%
]
//Payment method customization options
restrictedCountries: ['[COUNTRY_CODE]'], //Hide widget in certain countires
restrictedFiatCountries: ['[COUNTRY_CODE]'], //Hide fiat options in certain countries
disableFiat: '[DISABLE_FIAT]', //TRUE or FALSE to hide fiat option
disableCrossChain: '[DISABLE_X-CHAIN]'m //TRUE or FALSE to hide swap option
//DEX/bridge customization options
preferredBridge: '[BRIDGE_NAME]', //Bridge that x-chain transactions get directed to
preferredDEX: '[DEX_NAME]', //DEX that swaps get directed to
//The following parameters only apply if your dApp's smart contracts have been integrated
depositToContract: '[CONTRACT_INTEGRATED]' //TRUE or FALSE depending on whether dApp contract was integrated
protocol: '[PROTOCOL_NAME], //pre-determined name to identify your dApp
destinationContract: '[CONTRACT_ADDRESS]' //destination asset smart contract address
});
launcher.launch()
Last updated