Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP - JSONRPC: Transaction receipt subscription #611

Open
Kriys94 opened this issue Dec 17, 2024 · 0 comments
Open

WIP - JSONRPC: Transaction receipt subscription #611

Kriys94 opened this issue Dec 17, 2024 · 0 comments

Comments

@Kriys94
Copy link

Kriys94 commented Dec 17, 2024

Motivation


As a Dapp/Wallet, the way to be notified of a block inclusion of a transaction are as follows:

  1. Use private non-standard subscription method https://docs.alchemy.com/reference/alchemy-minedtransactions
  2. Polling mechanism of eth_getTransactionReceipt(txHash)

But

  1. It is not great for a Dapp/Wallet to use a proprietary API, whereas the open standard RPC interface is more reliable.
  2. L1 and L2s have significantly different throughputs; ideally, a different polling mechanism should be put in place for each network, but that is not a great developer experience to maintain this configuration. In addition, some RPC endpoints, like public endpoints, do not well support fast polling due to a low rate limit.

Instead, the open specification should propose a push mechanism for a mature user and developer experience for transaction inclusion notification

Spec


Parameters:

  1. transactionReceipts
  2. object
    2.a. addresses: list of addresses to filter transaction receipts by to or from
    2.b. includeRemoved (optional): boolean specifier to include transactions that have been removed from the cannonical chain (or re-orged).

Example:

{
  "jsonrpc": "2.0",
  "method": "eth_subscribe",
  "params": [
    "transactionReceipts",
    {
      "addresses": [
        {
          "to": "0x9f3ce0ad29b767d809642a53c2bccc9a130659d7",
          "from": "0x228f108fd09450d083bb33fe0cc50ae449bc7e11"
        },
        {
          "from": "0x1be82f08385faf6d00f88935c236497f94daa06f"
        }
      ],
      "includeRemoved": false,
    }
  ],
  "id": 1
}

Response:

  1. subscription id

Example:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x9ce59a13059e417087c02d3236a0b1cc"
}

Notifications:

  1. blockHash
  2. blockNumber
  3. transactionIndex
  4. transactionHash
  5. from
  6. to
  7. cumulativeGasUsed
  8. gasUsed
  9. contractAddress
  10. logs
  11. logsBloom
  12. status
  13. effectiveGasPrice
  14. type
{
  "jsonrpc":  "2.0",
  "method":  "eth_subscription",
  "params":  {
      "subscription":  "0x9ce59a13059e417087c02d3236a0b1cc",
      "result":  {
        "blockHash": "0x66103840578be3bc9c865e0961c4a4de31b5df7a45dcd13ffe2679ff9c7315d8",
        "blockNumber": "0x10023ee",
        "contractAddress": null,
        "cumulativeGasUsed": "0x9dd8f4",
        "effectiveGasPrice": "0x95792911f",
        "from": "0x1be82f08385faf6d00f88935c236497f94daa06f",
        "gasUsed": "0x4a328",
        "logs": [
          {
            "address": "0x000000000022d473030f116ddee9f6b43ac78ba3",
            "topics": [
              "0xc6a377bfc4eb120024a8ac08eef205be16b817020812c73223e81d1bdb9708ec",
              "0x0000000000000000000000001be82f08385faf6d00f88935c236497f94daa06f",
              "0x00000000000000000000000034103e1190b824a44c6a638438d425cba21143ba",
              "0x000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b"
            ],
            "data": "0x000000000000000000000000ffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000006430932d0000000000000000000000000000000000000000000000000000000000000000",
            "blockNumber": "0x10023ee",
            "transactionHash": "0xf033310487c37a86db8099a738ffa2bb62bb06efeb486a65ff595d411b5321f4",
            "transactionIndex": "0x63",
            "blockHash": "0x66103840578be3bc9c865e0961c4a4de31b5df7a45dcd13ffe2679ff9c7315d8",
            "logIndex": "0xda",
            "removed": false
          },
          [...]
          {
            "address": "0x1417be63afec8d175c2dc8a691fca1a898bc5b8d",
            "topics": [
              "0xd78ad95fa46c994b6551d0da85fc275fe613ce37657fb8d5e3d130840159d822",
              "0x000000000000000000000000ef1c6e67703c7bd7107eed8303fbe6ec2554bf6b",
              "0x0000000000000000000000001be82f08385faf6d00f88935c236497f94daa06f"
            ],
            "data": "0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000c81b15967b79f200000000000000000000000000000000000000000000001920aa875deb611cad0000000000000000000000000000000000000000000000000000000000000000",
            "blockNumber": "0x10023ee",
            "transactionHash": "0xf033310487c37a86db8099a738ffa2bb62bb06efeb486a65ff595d411b5321f4",
            "transactionIndex": "0x63",
            "blockHash": "0x66103840578be3bc9c865e0961c4a4de31b5df7a45dcd13ffe2679ff9c7315d8",
            "logIndex": "0xe5",
            "removed": false
          }
        ],
        "logsBloom": "0x00210000000000000002004080000000000000080000000000008100000000000000000000000000010000000000000402010000880000000000000000280000000000000080000000004008000000200000000000000800000084000000000000000200000000000000000000000000002000100800000000000010000000000000004000000000000000080000000100000000000000080000004000000800021800000000010000000000000000000401000000000000000000000000000000004022000000000000400000000014400200000000001000000000000000800010200000000000000000100000000000000800000000000000000080000400",
        "status": "0x1",
        "to": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
        "transactionHash": "0xf033310487c37a86db8099a738ffa2bb62bb06efeb486a65ff595d411b5321f4",
        "transactionIndex": "0x63",
        "type": "0x2"
      }
  }
}
@Kriys94 Kriys94 changed the title JSONRPC: Transaction receipt subscription WIP - JSONRPC: Transaction receipt subscription Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant