Add a provider

Add a provider

1. Update your DApp server

Ledger has a DApp browser (opens in a new tab) to host your web3 DApp.

One of the most useful features of this DApp Browser is to be able to log-in automatically from a Ledger Live Ethereum account, therefore obviating the step to manually “Connect a Wallet”.

As a DApp developer, you must add the specific iframe provider from Ledger as web3 provider.

The server must allow DApps to be embedded into iframes. To know more on how to proceed, have a look at this documentation (opens in a new tab). This explains how to easily authorize your DApp to be embedded only by Ledger Live DApp Browser by specifying the DApp Browser URL without using wildcards.

There is a useful reference article (opens in a new tab) on the Ledger Blog.

The package to add a new web3 provider (opens in a new tab) is available here. This simply diverts all RPC calls made from the DApp to the parent window using the PostMessage API. It does not do any Ledger-specific computing. It could in the future become a development standard to work out-of-the-box with other wallets.

A DApp must run differently if it is called from within an iframe or not. If it is, then directly initialize the web3 instance with the iframe provider. In this way, there is no web3modal connect flow at all, and users are automatically connected to the wallet of the parent window. To detect if a call is made from within an iframe or not, use a query param such as ?embed=true.

Feel free to check out how Lido did it here (opens in a new tab), it is later used in their sdk here (opens in a new tab), Yearn impl can be found her (opens in a new tab).

The DApp can submit a tx with or without gas fee set. If it is set, Ledger Live will use it as is, otherwise, Ledger Live will propose low/medium/high based on gas fee estimations.

2. Smooth out user experience

  • Please make sure basic cases are handled.

    For instance, check what happens when you click on the log out or disconnect button in your Dapp. The user may be automatically logged back in Ledger Live iframe provider or redirected to the standard list of providers (Metamask, connect wallet, and such…).

  • We currently supports Ethereum mainnet, BSC and Polygon POS chains. We also support the Goerli testnet: to use it, make sur you have a Goerli testnet account available in Ledger Live. (To enable testnet networks, head over to Settings -> Experimental features and turn on the Developer mode setting.)

  • Please remove any references to third-party services that are not part of the current Ledger environment. You are free however to redirect to Ledger Live Buy or Swap services.

  • UI must be responsive and available for both Desktop and Mobile screen sizes.