MetaMask / metamask-mobile

Mobile web browser providing access to websites that use the Ethereum blockchain
https://metamask.io
Other
2.05k stars 1.07k forks source link

error while interacting with dapp on mobile #6932

Open Rickshanelorie opened 11 months ago

Rickshanelorie commented 11 months ago

note : am using wallet connect

i get the error on mobile only but on PC it's working fine inpage.js:1 MetaMask - RPC Error: The requested account and/or method has not been authorized by the user. {code: 4100, message: 'The requested account and/or method has not been authorized by the user.'} while using metamask or trust wallet

here's my code

======================================================================================

"import { EthereumClient, w3mConnectors, w3mProvider, WagmiCore, WagmiCoreChains, WagmiCoreConnectors, } from "https://unpkg.com/@web3modal/ethereum@2.6.2"; import { Web3Modal } from "https://unpkg.com/@web3modal/html@2.6.2";

// 0. Import wagmi dependencies const { bscTestnet, bsc } = WagmiCoreChains; const { configureChains, createConfig } = WagmiCore;

// 1. Define chains const chains = [bscTestnet, bsc]; const projectId = "#";

// 2. Configure wagmi client const { publicClient } = configureChains(chains, [w3mProvider({ projectId })]); const wagmiConfig = createConfig({ autoConnect: true, connectors: [ ...w3mConnectors({ chains, version: 2, projectId }), new WagmiCoreConnectors.CoinbaseWalletConnector({ chains, options: { appName: "#", }, }), ], publicClient, });

// 3. Create ethereum and modal clients const ethereumClient = new EthereumClient(wagmiConfig, chains); export const web3Modal = new Web3Modal( { projectId, themeVariables: { "--w3m-accent-color": "background: linear-gradient(157.81deg, #DEF9FA -43.27%, #BEF3F5 -21.24%, #9DEDF0 12.19%, #7DE7EB 29.82%, #5CE1E6 51.94%, #33BBCF 90.29%);", }, walletImages: { safe: "https://pbs.twimg.com/profile_images/1566773491764023297/IvmCdGnM_400x400.jpg", }, }, ethereumClient );

const getAccountAndHandle = async () => { try { account = await ethereumClient.getAccount(); console.log(account); } catch (err) { console.error(err); } };

ethereumClient.watchAccount(async (accounts) => { console.log("Accounts:", accounts); await getAccountAndHandle(); });

getAccountAndHandle();"

danjm commented 11 months ago

fyi @httpJunkie, there might be someone on your team who can help here

pycckuu commented 11 months ago

I've encountered a similar issue with the desktop MetaMask extension.