Wallet Connections

Injective supports both Ethereum and Cosmos native wallets. You can use popular wallets like Metamask, Ledger, Keplr, Leap, etc. to sign transactions on Injective.

Wallet Strategy

The recommended way to have support for all of these wallets out of the box is to use the WalletStrategy abstraction we've built. This approach will enable your dApp users to connect and interact with different wallets.

Combining it with the MsgBroadcaster abstraction allows you to sign transactions using one function call. This is what's being used on all products like Helix, Hub, Explorer, etc., and we strongly recommend using this approach in your dApp.

In case you still want to use some wallet natively (without the WalletStrategy class), we are going to provide examples of how to connect to a dApp built on Injective via Metamask and Keplr in this doc.

Metamask

Metamask is an Ethereum native wallet and can be used to connect and interact with your dApp built on Injective.

  • Get Injective addresses from Metamask


import { getInjectiveAddress } from '@injectivelabs/sdk-ts'

const getEthereum = () => {
  if (!window.ethereum) {
    throw new Error('Metamask extension not installed')
  }
  
  return window.ethereum
}

const ethereum = getEthereum()
const addresses = await ethereum.request({
  method: 'eth_requestAccounts',
}) /** these are evm addresses */

const injectiveAddresses = addresses.map(getInjectiveAddress)
console.log(injectiveAddresses)
  • Sign transactions using Metamask

An example of how to prepare + sign + broadcast a transaction on Injective using Metamask can be found here.

Keplr

Keplr is an Cosmos native wallet and can be used to connect and interact with your dApp built on Injective.

  • Get Injective addresses from Keplr


import { getInjectiveAddress } from '@injectivelabs/sdk-ts'
import { ChainId } from '@injectivelabs/ts-types'

const getKeplr = () => {
  if (!window.keplr) {
    throw new Error('Keplr extension not installed')
  }
  
  return window.keplr
}

(async() => {
  const keplr = getKeplr()
  const chainId = ChainId.Mainnet
  await keplr.enable(chainId)
  const injectiveAddresses = await keplr.getOfflineSigner(chainId).getAccounts()

  console.log(injectiveAddresses)
})()
  • Sign transactions using Keplr

An example of how to prepare + sign + broadcast a transaction on Injective using Keplr can be found here.

Last updated