⚛️
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
  • @leapwallet/cosmos-snap-provider
  • Installation
  • or
  • Methods
  • cosmjsOfflineSigner
  • getSnap
  • connectSnap
  • getKey
  • SuggestChain
  1. Leap Metamask Snap
  2. Integrating Snaps

Cosmos Snap Provider

PreviousMetamask Cosmos SnapNextCosmos Kit

Last updated 1 year ago

The cosmos-snap-provider is specifically designed for seamless integration of the Leap Cosmos Snap with the client.

Installation

npm install @leapwallet/cosmos-snap-provider

or

yarn add @leapwallet/cosmos-snap-provider

Methods

cosmjsOfflineSigner

If you're already employing cosmjs libraries for transaction signing, cosmjsOfflineSigner is recommended. It functions as an offline signer with existing cosmwasm clients. Before utilizing it as an offline signer, verify that the dapp is connected to the Snap.

Usage:


import { SigningStargateClient } from '@cosmjs/cosmwasm-stargate';
import { GasPrice } from '@cosmjs/stargate';
import { cosmjsOfflineSigner } from '@leapwallet/cosmos-snap-provider';

const offlineSigner = new cosmjsOfflineSigner(chainId);
const accounts = await offlineSigner.getAccounts();
const rpcUrl = ""; // Populate with an RPC URL corresponding to the given chainId

const stargateClient = await SigningStargateClient.connectWithSigner(
  rpcUrl,
  offlineSigner,
  {
    gasPrice: GasPrice.fromString("0.0025ujuno"),
  }
);

getSnap

This method is used to detect if the Leap Cosmos Snap is installed within the user's browser instance of Metamask.

Usage:

import { getSnap } from '@leapwallet/cosmos-snap-provider';

const snapInstalled = await getSnap(); // Returns true if the snap is already installed

connectSnap

connectSnap facilitates the connection to the Leap Cosmos Snap. If the Snap isn't installed, this function triggers its installation and establishes a connection.

Usage:

import { getSnap, connectSnap } from '@leapwallet/cosmos-snap-provider';

const snapInstalled = await getSnap();
if (!snapInstalled) {
  connectSnap(); // Initiates installation if not already present
}

getKey

getKey fetches the chain address corresponding to a specific chainId. Ensure the Snap is connected with the dapp before invoking this function.

const key = await getKey(chainId);

SuggestChain

Utilize the suggestChain method to suggest any chains of coin type 118.

Usage:

import { suggestChain } from '@leapwallet/cosmos-snap-provider';
await suggestChain({
  chainId: 'coreum-mainnet-1',
  chainName: 'coreum',
  bech32Config: {
    bech32PrefixAccAddr: 'core',
  },
  bip44: {
    coinType: 990,
  },
  feeCurrencies: [
    {
      coinDenom: "ucore",
      coinMinimalDenom: "ucore",
      coinDecimals: 6,
      coinGeckoId: "coreum",
      gasPriceStep: {
        low: 0.0625,
        average: 0.5,
        high: 62.5,
      },
    },
  ],
});
@leapwallet/cosmos-snap-provider
CosmJS