MetaMask / MetaMask/metamask-extension
Allow RPC Server to signal a failed transaction after submission
- Dominant language
- TypeScript
- Stars
- 13.2k
- Forks
- 5.6k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 451
Description
#### **Problem**:
When transactions sent through Flashbots RPC [rpc.flashbots.net](http://rpc.flashbots.net/) server fail to land on-chain for many reasons (one example could be its not included within the `maxBlockNumber` hint provided to flashbots or defaults to 25 max block range for any tx). Then this transaction will remain stuck in MetaMasks pending list indefinitely.
#### **Current Workaround:**
- when `eth_getTransactionReceipt(txHash)` is called and has failed (in this case not landed within 25 blocks) then the server sets a nonce fix for the sender address
- source: [https://github.com/flashbots/rpc-endpoint/blob/main/server/request_intercepts.go#L17](https://github.com/flashbots/rpc-endpoint/blob/main/server/request_intercepts.go#L17)
- then any rpc request for `eth_getTransactionCount` for that address the server fakes a nonce with a very high number (1,000,000,001 to ensure that the network nonce is [greater than the pending nonce](https://github.com/MetaMask/core/blob/main/packages/transaction-controller/src/helpers/PendingTransactionTracker.ts#L504)) for exactly 4 requests, (enough for metamasks [`DROPPED_BLOCK_COUNT`](https://github.com/MetaMask/core/blob/main/packages/transaction-controller/src/helpers/PendingTransactionTracker.ts#L515-L524)) so that MetaMask drops it from its pending list.
- source: [https://github.com/flashbots/rpc-endpoint/blob/main/server/request_intercepts.go#L124](https://github.com/flashbots/rpc-endpoint/blob/main/server/request_intercepts.go#L124)
#### Proposed Fix:
Flashbots could return a specific error and code from `eth_getTransactionReceipt` to explicitly signal transaction cancellation to wallets. A more specific message could go in the `data` field.
```json5
{
"jsonrpc": "2.0",
"error": {
"code": 9999, // placeholder
"message": "transaction cancelled"
},
"id": 1
}
```
#### Alternatives
Any error returned from `eth_getTransactionReceipt` could result in removing the pending transaction.
Contributor guide
Assessment
This issue has not been assessed yet.