Table of Contents

Deep linking to DApp through Trust Wallet

Table of Contents

How LikeCoin brings her mobile UX to the next level

In LikeCoin foundation, when we design, one core principle is security comes first.

Users are identified by their Ethereum wallet address, and all sensitive actions should be authenticated by user private signing the payload. We achieve this by using web3.js interface.

Things worked quite smoothly on desktop, like all other DApps, we guide new users to install Metamask.

(Mobile) Problem

For mobile, there was indeed some DApp browser available, but telling the users to

1. Tap the popup in
2. Go to Google Play/iTunes to download the DApp browser
3. Pray for the users to remember which pages they were in, after all the initial wallet setup of such browser

seems to be a very poor UX.

We ended up sending the user back to desktop instead.

Deep linking to DApp through Trust Wallet
Deep linking to DApp through Trust Wallet

However, as our marketing campaign launched, we came to the shocking realisation that world indeed runs on mobile now, and more than 40% of our users are on mobile browsers. Blocking them with a popup doesn’t seem to be a good idea.

Trust Wallet + Deep link to the rescue

Deep linking to DApp through Trust Wallet
Deep linking to DApp through Trust Wallet

Using the dynamic deep link feature provided by Trust Wallet, we are now able to refine the UX to a much more friendly one, now it is:

  1. Detect mobile user, pops up Trust Wallet installation dialog
  2. User click on the deep link button in the dialog. Trust Wallet will be triggered and open the page automatically if installed; if not:
  3. User will be redirected to Google Play/iTunes to install Trust Wallet. After installation and setup wallet steps are complete, user are automatically redirected to the page where they came in from, in the Trust Wallet DApp browser.

Actual Implementation

The implementation is surprisingly simple, since Trust Wallet is using for deep-linking, there are multiple ways to create deep link. More details can be found at Trust Wallet article.

Here I will focus on how generate dynamic deeplink on-the-fly, without calling any api.

export const TRUST_URL = '';const currentURI = window.location.href;const deepLink = `${TRUST_URL}${encodeURIComponent(currentURI)}`;

The above code formats a long URL. In fact given any branch dynamic link domain, we can format any payload required by appending suitable query string. Here we put in two payloads event=openURL and url=${window.location.href}defined in Trust Wallet source code here.

For more customised behaviour, you can also define more options like fallback URL on different platforms. Read’s documentation for more examples.

Thanks Trust Wallet team for the great work.

Further Reading:

#trust wallet deeplink #trust wallet browser #dapp trust wallet #deeplink not supported metamask