How can I connect Dapp and Wallet in Webview?

Hello, I am the developer of the Keywallet Touch application that supports hardwallet and apps.
I want to automatically link MetaMask to Dapp such as uniswap, 1inch, and sushiswap in “webview”. As a result of looking into it, I know how to insert a web3-object in javascript, but I don’t know where to start because it’s hard to find an example. The final purpose is to link Dapp and MetaMask in Webview, so can you tell me how to do it?

below is my code and the result of webview

스크린샷 2022-09-15 오전 10.50.43

Hi @kwh !

Check out the Best Practices section of the MetaMask Docs here:

1 Like

Hello @kwh ! Welcome to MetaMask community !

Try change your code:

if(window.ethereum !== undefined) {} else {}

or do another check:

import detectEthereumProvider from "@metamask/detect-provider";
const provider = await detectEthereumProvider();
if(provider) {} else {}

This topic was automatically closed after 30 days. New replies are no longer allowed.