Metamask mobile. Incorrect error handling using eth_sendRawTransaction method.
Describe the bug
We have developed an interface imitating ethereum JSON RPC interface to integrate our blockchain with metamask desktop and mobile application. We developed eth_sendRawTransaction method that returns an error instead of transaction hash when a transaction is rejected in our blockchain for some reason. After receiving that error Provider uses an error code -32603 'Internal JSON-RPC error.'
{"code":-32603,"message":"[ethjs-query] while formatting outputs from RPC '{\"error\":306,\"message\":\"Error while executing account-script: FailedTransactionError(code = 1, error = AccountBalanceError(Map(3FY1GwbNSZyLKCVpwTkjnta2vgw676zn3gW -> negative waves balance: 3FY1GwbNSZyLKCVpwTkjnta2vgw676zn3gW, old: 999700000, new: -98900300000)), log =)\",\"transaction\":{\"type\":18,\"id\":\"EDKmKLayaBXorJJ1v9LUK65Hn5Pq1kyfbpMm12mFSeJJ\",\"fee\":500000,\"feeAssetId\":null,\"timestamp\":1662639042356,\"version\":1,\"chainId\":68,\"bytes\":\"0xf8b18601831d026f348502540be4008307a120947d1a54f985831a37bf2034e525a671cde171048380b84421d4a0390000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000081aba010b91146f64fddc5e12b026890def83baf43a5b139d8a160dd97605a5a911964a018a8ed2f1238c2a3413abe8dafaa0561305f1ed91fec6e98912e6a69d8609200\",\"sender\":\"3Fbo3zW4F1MeZvbw54TGAkstzk4Kzrkm3Sh\",\"senderPublicKey\":\"3T9fL3XpeaHYbumohePPUmeuUqhyEeyzifi9vKouV8QoNtAT6kYV1oPAe9e2KCVquPcyXJpr2QwUiQKEUQPGZnc6\"}}' for method 'sendRawTransaction' Error: [ethjs-format] hex string '[object Object]' must be an alphanumeric 66 utf8 byte hex (chars: a-fA-F) string, is 0 bytes","stack":"{\n \"code\": -32603,\n \"message\": \"[ethjs-query] while formatting outputs from RPC '{\\\"error\\\":306,\\\"message\\\":\\\"Error while executing account-script: FailedTransactionError(code = 1, error = AccountBalanceError(Map(3FY1GwbNSZyLKCVpwTkjnta2vgw676zn3gW -> negative waves balance: 3FY1GwbNSZyLKCVpwTkjnta2vgw676zn3gW, old: 999700000, new: -98900300000)), ...
Upon receiving that error metamask mobile starts permanently sending eth_getTransactionByHash requests with null hash params.
{ "id": 2145909897078296, "jsonrpc": "2.0", "method": "eth_getTransactionByHash", "params": [ {} ] }
Here’s the screenshot of that transaction that was made in Android Metamask application via internal browser.

In desktop Metamask extension problem doesn't reproduce - that transactions is tagged 'Failed' instead of 'Submitted', error is displayed correctly.
Expected behavior After eth_sendRawTransaction method receives a response without transaction hash, mobile application doesn't start a loop of eth_getTransactionByHash requests with null hash params. Transaction in the transactions list is displayed as Failed.
Smartphone:
- Xiaomi MI A1
- Android 9
- v5.6.0 (950)
to be added after bug submission by internal support / PM Severity
- How critical is the impact of this bug on a user?
- Add stats if available on % of customers impacted
- Is this visible to all users?
- Is this tech debt?
Hey @darksyd94, thanks for reporting! It would be helpful for us if you could give us an example of how to reproduce it so we can test it easily
Hello @tommasini ! I give you a instruction how to reproduce it:
-
Login in Metamask account in Metamask Mobile.
-
Choose browser in Menu.
-
Go to next link in Metamask Browser: https://metamask.wvservices.com/metamask/.
-
Push Gear Button and choose testnet.

-
Reload the Page.
-
Choose "Login via Metamask"

-
Accept Allowance to add a network.

-
In list of actions choose Invoke Script

-
Use Transaction data below:

{ "dApp":"3MtEFgs9JgvadLTPHxmNTLoYdWeb2q6S8NB", "call":{ "function":"fail", "args":[] } }
10. Push Broadcast button.
-
Confirm Transaction.

-
Look on Error.

-
Look on transaction in history:

Device - Samsung Galaxy S22 Ultra.
hey @darksyd94 your dapp has been flagged as a phishing site, do you have another dapp that we can use that is non-malicious?
Hey @cortisiko! We made an issue some time ago, to make our dApp trusted, unfortunately this issue still open by now time.
We have another dApp: https://signer-sandbox.waves.tech/. Instruction the same, but before you should use a seed phrase in "import an Account" menu. Seed on spoiler below.
seed
slender test hungry field dinosaur special dash dish accuse crack paddle fashion
thank you @darksyd94 for sharing. I will pass this onto the rest of the team!
This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 7 days. Thank you for your contributions.
This issue was closed because it has been stalled for 7 days with no activity. If you feel this was closed in error please reopen and provide evidence on the current production app. Thank you for your contributions.