Getting started

The following document explains how to get started with the Teller Widget, as well as the available customization options.

We recommend using the following build configurations/environments for your react apps

  1. Vite

  2. next.js

  3. create-react-app (although this one is highly unrecommended)

There are additional steps required for the last 2 environments that are outlined at the bottom of this page.

Installing the widget

Required packages

 @tanstack/react-query
 alchemy-sdk
 graphql
 graphql-request
 react
 react-dom
 @teller-protocol/v2-contracts

Using either yarn or npm, to install the widget, run the following commands

Please note that your app must be running React 18.2.0 or higher, and must have the packages in Required packages and that subgraph studio api key is required for the widget to function properly.

Using the widget

To use the widget, import it from the package

The widget will work without any additional props or setup required. It will pickup the user's connected wallet and display all available loans for the user's wallet tokens.

To generate a subgraph api key from The Graph, used in prop subgraphApiKey, follow the steps here.

Customizing the widget

The following elements of the widget are customizable

  • buttonLabel: The label in the button to trigger the widget

  • whitelistedTokens: Additional tokens to always display

  • showOnlyWhiteListedTokens: Toggle to show only the tokens defined in whitelistedTokens

  • buttonColorPrimary: #hex background color styling to the main button

  • buttonTextColorPrimary: #hex text color styling to the main button

  • buttonClassName: a css class to add to the main button

  • isBareButton: a boolean that removes all the standard styling and keeps the button to bare minimum for much easier customization

  • referralFee: Loan fee %, to be sent to a referral address

  • referralAddress: The address to receive the referral fee

  • welcomeScreenLogo: Logo (as a URL) displayed on the widget's welcome screen

  • welcomeScreenTitle: Bold, header text on the widget's welcome screen

  • welcomeScreenParagraph: Body, paragraph text on the widget's welcome screen

buttonLabel

You can customize the label that appears in the button once you add it to the your app.

By default the label is Cash Advance, this can be changed to any string like so

whitelistedTokens

By default, the widget shows available offers for the tokens in the user's wallet.

By passing in an object organized by chain id, you can customize this list so the tokens in the list always show up in the available loan opportunities. If the token is not found in the user's wallet, the widget will default to a value of 1 for the respective token.

showOnlyWhiteListedTokens

If you want to only show the tokens in the above list, set this prop to true. Please note that for this prop to work, whitelistedTokens must be present as well.

buttonColorPrimary

For simple css styling, the primary button's background color can be changed by passing in this prop. The input must be in hex format, including the #, ie #FFFFFF

buttonTextColorPrimary

Also for simple css styling, the primary button's text color can be changed by passing in this prop. The input must be in hex format, including the #, ie #FFFFFF

buttonClassName

To facilitate styling of the button, and make it easier to match your app's styles, a buttonClassName prop is available to add a custom css class to the button.

isBareButton

By setting isBareButton to true, all the styling of the button is reset to the browser's default styling to make it easier to override the styling of the button.

whitelistedChains

An optional array to show desired chains. By default, the widget shows all chains. Available chains:

  • 1 (Ethereum),

  • 137 (Polygon)

  • 42161 (Arbitrum)

  • 8453 (Base)

referralFee

Referral fee %, in basis points. For example, 100 = 1%, max 500 = 5%. Note, referral fee on rollover loans is capped at 5% of the original loan repayment.

referralAddress

Recipient wallet address to receive referral fee.

Logo (as a URL) displayed on the widget's welcome screen. Image types .png, .jpg, .jpeg, .svg.

welcomeScreenTitle

Bold, header text on the widget's welcome screen.

welcomeScreenParagraph

Body, paragraph text on the widget's welcome screen.

Different environment configurations

next.js

please add the following to your next.config.js

create-react-app

For CRA based environments, multiple steps are required

  1. Install the following packages

  1. Modify the start scripts in package.json to use react-app-rewired instead of react-scripts

  1. Add a config-overrides.js file to the top of the project directory with the following

Please note that the following message may appear once the project has been built

This message can safely be ignored, as this only happens in dev environments. You can either close it by clicking on the x on the top right or by refreshing the page. This message won't appear in production environments

Last updated