question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ethers.js MetaMask Mobile error: eth_sendTransaction

See original GitHub issue

Not sure where this issue originates - MetaMask, Ethers.js, or here. Apologies if this is the wrong place.

Issue

Attempting to fire a transaction fails with error The method eth_sendTransaction does not exist/is not available.

This flow works for WalletConnect with the test wallet (test.walletconnect.org). It also works well with MetaMask browser extension (ie. not using WalletConnect)

@walletconnect/web3-provider v1.0.13 @ethersproject/providers ^5.0.4

const provider = new WalletConnectProvider({
      infuraId: infuraKey // Required
});

await provider.enable();
const walletProvider = new Web3Provider(provider);

contracts[name] = new Contract(
   CONTRACTS[name][networkName],
    CONTRACTS[name].abi,
    walletProvider
);

const approvalAmount = amountBn || parseUnits("500000", 18);
const tx = await contracts[token].approve(
  spender,
  approvalAmount
);

Discussion

Going to continue researching…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
pi0neerpatcommented, Aug 10, 2020

IT WORKS!!!

    "@ethersproject/contracts": "^5.0.1",
    "@ethersproject/providers": "^5.0.4",
    "@walletconnect/web3-provider": "1.2.0-alpha.0",
4reactions
pedrouidcommented, Aug 10, 2020

Could you try the following which we are currently testing?

  1. Install pre-release version available on NPM at next tag (v1.2.0-alpha.0)
  2. Make sure that you get the Signer from the provider

Example:

const web3Provider = new WalletConnectProvider(..)

const provider = new ethers.providers.Web3Provider(web3Provider)

const tokenContract = new Contract(tokenAddress, tokenAbi, provider.getSigner())

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding and resolving MetaMask error codes
This guide outlines the most common and confusing MetaMask error codes to help you resolve errors for a smoother Web3 development ...
Read more >
Ether.js works fine on desktop but not with metamask app ...
1 Answer 1 · 1- Try to connect to Metamask on mobile via wallet connect. · 2- if you're using React, use @react-web3/core...
Read more >
Sending Transactions - MetaMask Docs
Transactions are a formal action on a blockchain. They are always initiated in MetaMask with a call to the eth_sendTransaction method. They can ......
Read more >
ethers: processing response error code -32000 ...
I am trying to get MetaMask to popup to approve a dapp to use my erc20 tokens like: const provider = new ethers.providers....
Read more >
Documentation - Ethers.js
A Web3Provider wraps a standard Web3 provider, which is // what MetaMask injects as ... error.hash - the hash of the original transaction...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found