Integrating Leap Wallet
This documentation provides a guide on integrating Leap Wallet into your Sui application. By following these steps, you can seamlessly detect, connect, and interact with Leap
Detecting Leap Wallet
To seamlessly integrate Leap Wallet into your SUI application, use the @mysten/wallet-standard package. This standardized approach ensures consistent wallet detection and interaction across different providers.
Prerequisites
Before you begin, install the required package using your preferred package manager:
# Using NPM
npm i @mysten/wallet-standard
# Using Yarn
yarn add @mysten/wallet-standardImplementing Wallet Detection
After installing the package, use the following code snippet to detect SUI-compatible wallets, including Leap:
import { getWallets } from '@mysten/wallet-standard'
const { get } = getWallets()
const allWallets = get()Next, filter out any wallets that are not compatible with the SUI standard.
import { isWalletWithRequiredFeatureSet } from '@mysten/wallet-standard'
const suiWallets = allWallets.filter(isWalletWithRequiredFeatureSet)
Once you've identified the Leap wallet within the suiWallets array, you'll gain access to various functions like connect, which we’ll cover in the next section.
Alternative Detection Method
You can also access the Leap wallet directly through the window object:
This method provides direct access to the Leap wallet interface when available in the browser environment.
Note: Make sure to implement proper error handling and wallet availability checks in your application to ensure a smooth user experience.
Enable Connection
The wallet connection can be established using the connect method. If the wallet is locked, it will redirect to the extension login page. If the user hasn't permitted the webpage, it will ask for permission.
Disconnect
Disconnect the wallet from the dApp.
Sign Personal Message
Sign an arbitrary personal message.
Sign Transaction
Sign a transaction without executing it.
Sign and Execute Transaction
Sign and execute a transaction in one step.
Legacy Support (Transaction Blocks)
For backward compatibility, the wallet also supports transaction block operations:
Sign Transaction Block
Sign and Execute Transaction Block
Events
The wallet provider emits events that you can listen to:
Example Usage with Sui SDK
Supported Chains
The wallet supports the following Sui chains:
sui:mainnetsui:testnet
Note: All methods may throw errors if the wallet is locked, user rejects the request, or if there are network issues. Make sure to implement proper error handling in your dApp.
Last updated