Trust Wallet Integration

We design and develop full-cycle blockchain solutions: from smart contract architecture to launching DeFi protocols, NFT marketplaces and crypto exchanges. Security audits, tokenomics, integration with existing infrastructure.
Showing 1 of 1 servicesAll 1306 services
Trust Wallet Integration
Simple
~2-3 business days
FAQ
Blockchain Development Services
Blockchain Development Stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1051
  • image_logo-advance_0.png
    B2B Advance company logo design
    561
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    827
  • image_logo-aider_0.jpg
    AIDER company logo development
    762
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    850

Trust Wallet Integration

Trust Wallet is a mobile-first wallet with a built-in DApp browser. Integration differs from MetaMask in one important aspect: users either open your dApp directly in the Trust Wallet browser, or connect to Trust Wallet via WalletConnect. Two completely different connection paths that need to be handled correctly.

Connection Mechanisms

Trust Wallet Built-in Browser

When a user opens a dApp in the browser inside the Trust Wallet app, the app injects a window.ethereum provider. This is a standard EIP-1193 provider — works like MetaMask. You can identify Trust Wallet by window.ethereum.isTrust or window.trustwallet:

const isTrustWalletBrowser = window.ethereum?.isTrust || !!window.trustwallet

For this path, standard ethers.js or viem with window.ethereum is sufficient:

import { createWalletClient, custom } from "viem"
import { mainnet } from "viem/chains"

const client = createWalletClient({
  chain: mainnet,
  transport: custom(window.ethereum)
})

const [address] = await client.requestAddresses()

WalletConnect v2

For desktop browser users, Trust Wallet connects via WalletConnect. WalletConnect v2 is a WebSocket relay with end-to-end encryption, connection via QR code or deep link.

WalletConnect v1 is deprecated. Migrate to v2. Since June 2023, v1 servers are turned off.

For implementation we use wagmi + @web3modal/wagmi or RainbowKit — they already include the WalletConnect connector and Trust Wallet. Manually:

import { WalletConnectConnector } from "@wagmi/connectors/walletConnect"

const connector = new WalletConnectConnector({
  options: {
    projectId: "YOUR_WC_PROJECT_ID",  // from cloud.walletconnect.com
    metadata: {
      name: "My dApp",
      description: "Description",
      url: "https://app.example.com",
      icons: ["https://app.example.com/icon.png"]
    }
  }
})

Recommended Approach: wagmi + WalletConnect

The correct approach is not to write integration from scratch, but to use wagmi with RainbowKit or ConnectKit. Trust Wallet is supported out of the box.

import { TrustWalletConnector } from "@wagmi/connectors/trustWallet"
import { createConfig, configureChains } from "wagmi"
import { mainnet, polygon } from "wagmi/chains"
import { alchemyProvider } from "wagmi/providers/alchemy"

const { chains, publicClient } = configureChains(
  [mainnet, polygon],
  [alchemyProvider({ apiKey: process.env.ALCHEMY_KEY! })]
)

const config = createConfig({
  autoConnect: true,
  connectors: [
    new TrustWalletConnector({ chains }),
    // WalletConnect as fallback
  ],
  publicClient
})

Deep Links for Mobile Users

Trust Wallet supports deep link scheme to open dApp directly in its browser:

https://link.trustwallet.com/open_url?coin_id=60&url=https%3A%2F%2Fapp.example.com

coin_id=60 is Ethereum. For other networks: 195 (TRON), 714 (BNB Chain), 966 (Polygon).

An "Open in Trust Wallet" button on the mobile version of the site is a UX improvement that significantly increases conversion to wallet connection on mobile devices.

Signing Transactions and Messages

Trust Wallet supports standard methods:

  • personal_sign — signature of arbitrary message
  • eth_signTypedData_v4 — EIP-712 structured data
  • eth_sendTransaction — transaction sending

Nuance: when displaying a transaction, Trust Wallet shows decoded data if it knows the ABI. For better UX — verify the contract on Etherscan, then the user sees a readable view of the transaction instead of hex data.

Timeline

Basic integration via wagmi + Trust Wallet connector + WalletConnect v2 — 1 day. Including mobile deep link and testing in actual Trust Wallet app — 2 days.