MetaMask / MetaMask/metamask-mobile
error while interacting with dapp on mobile
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 1.7k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 669
Description
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();"
Contributor guide
Research direction
Start with the supplied mobile-only reproduction using WalletConnect, MetaMask or Trust Wallet and the shown Web3Modal configuration. Compare the account and authorization flow on mobile with the working PC behavior, focusing on the RPC error 4100. Done means the cause is identified and the mobile dapp interaction works without the unauthorized-account or method error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- blockchain, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100