Integrate Mobile Wallet

Mobile Wallet Support

A third-party mobile wallet can easily inject the following object into window object to support all dApps that use the Tomo Connect SDK.

export type InjectedTomo = {
  info: {
    name: string
    logo: string
  }
  cosmos?: TomoCosmosInjected
  bitcoin?: TomoBitcoinInjected
}

export type TomoBitcoinInjected =  {
  // connect
  requestAccounts: () => Promise<string[]>
  getAccounts: () => Promise<string[]>
  getPublicKey: () => Promise<string>
  signPsbt: (psbtHex: string) => Promise<string>
  signPsbts: (psbtsHexes: string[]) => Promise<string[]>
  getNetwork: () => Promise<Network>
  signMessage: (message: string, type: 'bip322-simple') => Promise<string>
  switchNetwork: (network: Network) => Promise<void>
  sendBitcoin: (to: string, amount: number) => Promise<string>
  pushTx?: (txHex: string) => Promise<string>
  getBalance?: (address: string) => Promise<number>
  getInscriptions?: (
    cursor?: number,
    size?: number
  ) => Promise<InscriptionResult[]>
  on?: (eventName: string, callBack: () => void) => void
  off?: (eventName: string, callBack: () => void) => void
}

For TomoCosmosInjected, please refer to the Keplr.

If your wallet already supports Bitcoin and Cosmos, you can simply use:

window.injectedTomo = {
  info: {
    name: 'XYZ Wallet',
    logo: 'https://your.website/wallet.png'
  },
  bitcoin: window.yourBitcoin,
  cosmos: window.yourCosmos
}

Last updated