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()

Last updated