⚛️
Leap Cosmos
  • Introduction
  • for dapps: Connect to Leap
    • Introduction
    • Optimizing Wallet Connectivity for Cosmos Dapps
    • Add Leap to existing Keplr integration
    • Add Leap to a new dapp
    • Suggest chain : Add Leap to a non-native chain
    • Add Leap to a Secret dapp
    • Wallet Connect
    • Wallet Adapters
      • Cosmos Kit
      • Shuttle
    • API Reference
  • for chains: integrate into Leap
    • Introduction
  • for SEI dapps: Connect to Compass
    • Connect to Compass
  • FOR SEI EVM DAPPS: CONNECT TO COMPASS
    • Connect to Compass
    • Supported RPC methods
  • Leap Metamask Snap
    • Introduction
    • Integrating Snaps
      • Metamask Cosmos Snap
      • Cosmos Snap Provider
      • Cosmos Kit
  • Embedded Wallet SDK
    • Embedded Wallet SDK React
    • Embedded Wallet Provider
    • Migration
    • Usage without UI
  • Elements
    • Introduction
    • Get Started
    • Integrate via CDN / Script Tag
    • Integrate as an Embed
    • Components
      • Aggregated Swaps
      • IBC Only Swaps
      • Fiat On-ramp
      • IBC Transfer
      • Multi View
    • Theming
      • Using CSS Variables
      • Advanced Customisations
    • Use Elements Without the UI
    • Tab Config
    • Using Skip API Key
  • Cosmos Nodes
    • Fallback Falooda : Node Fallback System
    • (Coming Soon) Blockchain Node Setup Guide
    • (Coming Soon) Monitoring Blockchain Node Performance
  • RESOURCES
    • Leap Assets
Powered by GitBook
On this page
  • Enable connection:
  • Get Key:
  • Sign Amino:
  • Sign Direct / Protobuf:
  • Request Signature for Arbitrary Message:
  • Delegate Transaction broadcasting:
  • CosmJS example
  • Method to add a CW20 token
  • Method to check wallet connection
  • Disconnect from Dapp
  • Get Supported Chains
  1. for dapps: Connect to Leap

API Reference

A list of Leap Connect Wallet methods

Enable connection:

The window.leap.enable(chainIds) method redirects to the extension login page if it is locked. If the user hasn't permitted the webpage, it will ask the user to enable the webpage to access Leap.

window.leap.enable(chainId: string | Array<string>)
// you can pass a list of chainIds to get approval for multiple chains in one request
window.leap.enable(['chainId1', 'chainId2'])

Note: In a case where multiple wallets are imported, users can select the wallet/wallets that are supposed to be enabled.

Get Key:

If the webpage has permission and Leap wallet is unlocked, this function will return the address and public key in the following format:

interface Key {
  name: string;
  algo: string;
  pubKey: Uint8Array;
  address: Uint8Array;
  bech32Address: string;
  isNanoLedger: boolean;
}

window.leap.getKey(chainId: string): Promise<Key>

Sign Amino:

Like signAmino method of CosmJS OfflineDirectSigner, however, Leap's signAmino function takes the chain-id as a required parameter. Signs Amino-encoded StdSignDoc.

interface SignOptions {
 // If set to true the wallet will not override fees specified in the signDoc.
  preferNoSetFee: boolean
}  

signAmino(chainId: string, signer: string, signDoc: StdSignDoc, signOptions?: SignOptions): Promise<AminoSignResponse>

Sign Direct / Protobuf:

Like signDirect method of CosmJS OfflineDirectSigner, however, Leap's signDirect function takes the chain-id as a required parameter. Signs Proto-encoded StdSignDoc.

interface SignDoc {
  bodyBytes?: Uint8Array | null;
  authInfoBytes?: Uint8Array | null;
  chainId?: string | null;
  accountNumber?: Long | null;
}

interface SignOptions {
 // If set to true the wallet will not override fees specified in the signDoc.
  preferNoSetFee: boolean
}  

signDirect(chainId:string, signer:string, signDoc: SignDoc, signOptions?: SignOptions): Promise<DirectSignResponse>

Request Signature for Arbitrary Message:

signArbitrary(
    chainId: string,
    signerAddress: string,
    data: string | Uint8Array
): Promise<StdSignature>;

await window.leap.signArbitrary(chainId, signerAddress, 'hello')

Delegate Transaction broadcasting:

Webpages can use this function to delegate the broadcasting of the transaction to LCD endpoints configured in the leap wallet. If the broadcast is successful, this method will return the transaction hash. Otherwise, it will throw an error.

sendTx(
    chainId: string,
    tx: Uint8Array,
    mode: BroadcastMode
): Promise<Uint8Array>;

CosmJS example

Leap’s API is similar to Keplr's to keep the integration of leap for the dApp as easy as possible.


import { GasPrice, SigningStargateClient } from '@cosmjs/stargate'

await window.leap.enable(chainId);

const signOptions = {
  // set this to true to prevent leap from overriding the fees.
  preferNoFeeSet: false
}

const offlineSigner = window.leap.getOfflineSigner(chainId, signOptions);
const accounts = await offlineSigner.getAccounts();
const rpcUrl = "" // Replace with a RPC URL for the given chainId
const signingStargateClient = await SigningStargateClient.connectWithSigner(
  rptycUrl,
  offlineSigner,
  {
    gasPrice: GasPrice.fromString("0.0025ujuno"),
  }
)

Method to add a CW20 token

await window.leap.suggestCW20Token(chainId, contractAddress) 

Method to check wallet connection

await window.leap.isConnected(chainId) // returns boolean 

Disconnect from Dapp

await window.leap.disconnect(chainId) // returns boolean 

Get Supported Chains

const supportedChains = await window.leap.getSupportedChains()
PreviousShuttleNextIntroduction

Last updated 1 year ago