⚛️
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
  • Installation
  • Methods
  • 1. Get Keys
  • 2. Sign Direct
  • 3. Suggest Chain
  1. Leap Metamask Snap
  2. Integrating Snaps

Metamask Cosmos Snap

PreviousIntegrating SnapsNextCosmos Snap Provider

Last updated 1 year ago

Installation

To either establish a connection or initiate an installation followed by a connection to the metamask-cosmos-snap, execute the following code:


try {
  const result = await window.ethereum.request({
    method: 'wallet_requestSnaps',
    params: {
      'npm:@leapwallet/metamask-cosmos-snap': {},
    },
  });

  console.log(result);

} catch (error) {
  console.log(error);
}

For the official docs on connecting or installing a Metamask snap, refer .

Methods

1. Get Keys

The getKey method retrieves the wallet's public address corresponding to a specific chain ID. Currently, we support chains of coin type 118.

Usage:

const accountData = await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: "npm:@leapwallet/metamask-cosmos-snap",
    request: {
      method: 'getKey',
      params: {
        chainId,
      },
    },
  },
});

2. Sign Direct

Utilize the signDirect method to sign transactions or signDoc using the connected wallet.

Usage:

await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: "npm:@leapwallet/metamask-cosmos-snap",
    request: {
      method: 'signDirect',
      params: {
        chainId,
        signerAddress,
        signDoc,
      },
    },
  },
});

3. Suggest Chain

Utilize the suggestChain method to suggest any chains of coin types 118,

Usage:

await window.ethereum.request({
  method: 'wallet_invokeSnap',
  params: {
    snapId: 'local:http://localhost:8000',
    request: {
      method: 'suggestChain',
      params: {
        chainInfo: {
          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,
            },
          },
        ],
        }
      },
    },
  },
});
here