MetaMask / metamask-extension

:globe_with_meridians: :electric_plug: The MetaMask browser extension enables browsing Ethereum blockchain enabled websites
https://metamask.io
Other
11.84k stars 4.83k forks source link

[Bug]: I have issue when use web3js web3.eth.sendTransaction(transactionObject [, callback]) #23836

Open thongnhatgraphic opened 5 months ago

thongnhatgraphic commented 5 months ago

Describe the bug

I have a source code in nodejs. Client send request buyNft to nodeJs. NodeJs had encodeAbi function buyNft and respon rawFunction to Client. After that, Client receive rawFunction buyNft in responsive of api, client use rawFunction buyNft put into web3.eth.sendTransaction({ data:rawFunction, gas, from, to, value,... }). afterward extension metamask don't open, and show error message. Please tell me this issue where come from?. I tried rpc in infura.io but it not work effectively

Expected behavior

Open extension metamask

Screenshots/Recordings

issue

Steps to reproduce

  1. Client send request buyNft to nodeJs. NodeJs had encodeAbi function buyNft and respon rawFunction to Client.
  2. Client receive rawFunction buyNft in responsive of api, client use rawFunction buyNft put into web3.eth.sendTransaction({ data:rawFunction, gas, from, to, value,... })
  3. extension metamask don't open, and show error message "MetaMask - RPC Error: e.startsWith is not a function. " code: -32603 data: "{\n \"originalError\": {}\n}" message: "e.startsWith is not a function"

Error messages or log output

MetaMask - RPC Error: e.startsWith is not a function

Version

11.13.1

Build type

None

Browser

Chrome

Operating system

Windows

Hardware wallet

No response

Additional context

No response

Severity

My project is working on production

dattran92 commented 5 months ago

Same issue to me. I tried to manually install a previous Version 11.12.4, and it work normally.

vandan commented 4 months ago

Need to confirm that the issue can be reproduced.

dattran92 commented 3 months ago

A work around could be using window.ethereum.request instead

window.ethereum
    .request({
      method: 'eth_sendTransaction',
      // The following sends an EIP-1559 transaction. Legacy transactions are also supported.
      params: [
        {
          from: account,
          to: address,
          value: web3.utils.toHex(web3.utils.toWei(amount.toString())),
          gasPrice,
          gasLimit: '0x5028',
          // Customizable by the user during MetaMask confirmation.
          maxPriorityFeePerGas: '0x3b9aca00',
          // Customizable by the user during MetaMask confirmation.
          maxFeePerGas: '0x2540be400',
        },
      ],
    })
jiajames commented 2 months ago

@vandan we're witnessing this issue as well, it is reproduceable on newer versions of Metamask for a certain set of calldata (also on sendTransaction)