Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
mode = ModeOptions.bridge
Bridge mode allows your users to transfer similar assets between any chain supported by Kima. I.e. USDC on Arbitrum to USDT on Avalance.
On testnet it should look something like this. The test tokens are called USDK and can be obtained from the Kima faucet.
Add the widget to your React project using npm
or your favorite javascript package manager.
You'll need to add the following:
The <KimaProvider>
component in App.tsx
The <KimaTransactionWidget>
which interacts with Kima
A link to the Kima Transaction Backend (or build your own)
A WalletConnect project id
For the purposes of this example, we'll just add the widget to App.tsx
, but it can go anywhere it makes sense for your project.
Open App.tsx
, wrap your existing componts with the <KimaProvider>
and add the <KimaTransactionWidget>
component.
If you don't have one already, you'll need to get a (free) WallectConnect project ID from Reown Cloud and add it to the <KimaProvider>
component.
In the following sections, we'll go through the framework specific configuration for Vinalla React and NextJS.
The Kima Transaction Widget is a ready made React component that allows users to transfer like assets between chains using the Kima protocol. Combined with the Kima Transaction Backend, it is the quickest way to integrate Kima into your dApp.
The Kima Transaction Widget supports 3 modes:
Payment
Bridge
Status
In Payment Mode, the user can send funds from any chain supprted by Kima to the specified payment address and chain. See the Payment Mode section for more information.
I.e. Pay 12.34 USDC from Polygon or Solana
In Bridge Mode, the user is able to send funds to and from any chain supported by Kima. See the Bridge Mode section for more information.
I.e. Send 12.34 USDT on BSC and receive USDC on Arbitrum
Status Mode displays the progress of an existing transaction. See the Status Mode section for more information.
mode = ModeOptions.payment
Payment mode allows your users to pay for a product or service using stablecoins from any chain supported by Kima.
The payment details are passed into the Widget via the transactionOption
prop (required)
The user can choose to pay from any chain and token supported by Kima. The funds will be transferred to the wallet and chain specified in the transactionOption
prop
The title and subtile can be customized using the titleOption
and paymentTitleOption
props
You should see a page that looks like this:
The payment (target) wallet and chain will show on the next step when the user approves the transfer amount.
The procedure for adding the Kima Transaction Widget to a NextJS app is very similar to the React tutorial but you should be aware that you will need to export the widget component as a dynamic component with {ssr: false}
so that the application runs the widget on the client side.
To create a new app, you can run npx create-next-app <your-app-name>
. Then install the Kima Widget and its peer dependencies.
You'll need to add the following:
The <KimaProvider>
component in App.tsx
The <KimaTransactionWidget>
which interacts with Kima
A link to the Kima Transaction Backend (or build your own)
A WalletConnect project id
If you don't have one already, you'll need to get a (free) WallectConnect project ID from Reown Cloud and add it to the <KimaProvider walletConnectProjectId='your-project-id' />
component.
Within your app
directory, create a components
directory and inside that create a file named widget.jsx
with the following code:
Copy
You can now use DynamicApp
on whatever page you like. In our example, we will create an index page index.jsx
in our pages
directory and copy the following code:
Copy
When you visit localhost:3000
you will see something like this:
See the Configuration options section for more details on setting up the widget.
Add the widget to your React project using npm
or your favorite javascript package manager.
You'll need to add the following:
The <KimaProvider>
component in App.tsx
The <KimaTransactionWidget>
which interacts with Kima
A link to the Kima Transaction Backend (or build your own)
A WalletConnect project id
For the purposes of this example, we'll just add the widget to App.tsx
, but it can go anywhere it makes sense for your project.
Open App.tsx
, wrap your existing componts with the <KimaProvider>
and add the <KimaTransactionWidget>
component.
If you don't have one already, you'll need to get a (free) WallectConnect project ID from and add it to the <KimaProvider>
component.
Note that if you are using a later version of webpack
(>= 5), you will need to polyfill node core modules using react-app-rewired
.
This can be resolved by adding a file at the root of your project named config-overrides.js
. Paste the following content into the file:
There are several configuration options, which will described in the section on setting up the widget.
The easiest way to see the widget working, including the polyfill workaround, is to check out .
mode = ModeOptions.status
Status mode displays the progress of a transaction that has already been submitted to Kima. This is useful if the normal flow was interrupted and the status needs to be displayed again. Usually the transaction status view will display automatically after the user approves and submits the transaction.
⚠️
txId
is the transaction id returned from the/submit
endpoint- not the transaction hash. I.e22843
You would see a page that looks like this:
The transaction status will be displayed on the next step when the user approves the transfer amount.
There are numerous ways to configure the Widget for your own preferences and the look and feel of your dApp, which you can do via the following props:
The Theme prop controls whether the Widget is in light or dark mode and their background colours:
Required
Type: ThemeOptions
colorMode (required): ColorModeOptions.light | ColorModeOptions.dark
backgroundColorLight (optional): string
backgroundColorDark (optional): string
The Title prop enables you to give the widget whatever title you want and can be configured for each step of the widget.
Optional
Type: TitleOption:
initialTitle (optional): string
confirmTitle (optional): string
The PaymentTitle prop allows you to optionally set the title that appears on the payment screen if you are using the Payment component.
Optional
Type: PaymentTitleOption
title (optional): string
style (optional): object
This is a string, which should be to your own help documentation or FAQ. If unset, the link will default to Kima's help documentation.
Optional
Type: string
Required: true
Type: ModeOptions
payment: Payment scenario
bridge: Bridge scenario
status: mode for tracking the status of a specific Kima transaction
Used to specify the transaction flow scenario of the Widget. See the individual scenarios for more information.
Sets the default chain, wallet, and amount in the Widget. Required for the Payment mode, optional for the Bridge mode.
Payment mode: Required, Bridge mode: Optional
Type: TransactionOption
targetChain (optional): SupportNetworks
targetAddress (optional): string
amount (optional): number
currency (optional): string
This is one of the few props that is mandatory to set, because there are several enpoints which the Widget expects to exist on the Backend. The examples assume the backend server is running locally at localhost:3001
. Replace this with the URL of your backend.
Required: true
Type: string
For more information see the Kima Transaction Backend section.
Optional
Type: string
Default: explorer.kima.network
This is used to specify the URL of Kima's block explorer in the environment you are using. The widget needs this to provide updates to the status screen, as well as allowing users to link to their transactions to view progress.
Kima Mainnet Explorer: https://explorer.kima.network
Sardis (Testnet) Explorer: https://explorer.sardis.kima.network
Optional
Type: string[]
Default: []
Chain names to exlude from the widget. Users will not be able to select these chains in the widget. Useful for compliance reasons or to exclude chains not supported by your app.
There is currently no opton to do the opposite- i.e. explicity specify which chains to include.
Excluded target networks will have no effect in payment mode as the target chain, address, and amount are already explicity set.
Optional
Type: function
Called when an error occurs. Useful for debugging and logging.
Optional
Type: function
Called when the widget is closed.
Optional
Type: function
Called when the transaction is successful.
Used in Status mode to specify the transaction to track progress for. Only used in status mode, ignored otherwise.
Status mode: Required, ignored otherwise
Type: boolean
Default: -1
Used to provide the widget with wallet connection and chain switching functionality.
walletConnectProjectId
Used to specify the WalletConnect project id. Visit Reown Cloud and sign up for a free account (WalletConnect is now called Reown) to obtain a project id.
Required: true
Type: string
networkOption
Used to specify the network type.
Required: false
Type: NetworkOptions
Default: NetworkOptions.testnet
extneralProvider
If there is already a wallet connection logic elsewhere in your app, an external provider can be passed in. Otherwise, the widget will handle the connection logic on its own.
Required: false
Type: ExternalProvider
compliantOption
Required: false
Type: boolean
Default: false
If your app requires compliance checks, please contact us for more information. When false
(the default), compliance checks are disabled.