Integrating Leap Wallet

This documentation provides a guide on integrating Leap Wallet into your Solana application. By following these steps, you can seamlessly detect, connect, and interact with Leap.

Detecting Leap Wallet

To seamlessly integrate Leap Wallet into your Solana application, use the @wallet-standard/core 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 @wallet-standard/core

# Using Yarn
yarn add @wallet-standard/core

Implementing Wallet Detection

After installing the package, use the following code snippet to detect Solana-compatible wallets, including Leap:

import { getWallets } from '@wallet-standard/core'

const { get } = getWallets()

const allWallets = get()

Next, filter out any wallets that are not compatible with the solana standard.

import { isWalletAdapterCompatibleStandardWallet }from '@solana/wallet-adapter-base'

const solanaWallets = allWallets.filter(isWalletAdapterCompatibleStandardWallet)

Once you've identified the Leap wallet within the solanaWallets 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 In

Authenticate with a dApp using Sign In with Solana.

Sign Message

Sign an arbitrary message.

Sign Transaction

Sign a transaction without broadcasting it.

Sign and Send Transaction

Sign and broadcast a transaction to the network.

Change Network

Switch between different Solana networks.

Example Usage with Web3.js

Events

The wallet provider emits events that you can listen to:

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