|
| 1 | +.. _eth-txpool: |
| 2 | + |
| 3 | +.. include:: include_announcement.rst |
| 4 | + |
| 5 | +=============== |
| 6 | +web3.eth.txpool |
| 7 | +=============== |
| 8 | + |
| 9 | + |
| 10 | +The ``web3-eth-txpool`` package gives you access to several non-standard RPC methods to inspect the contents of the transaction pool containing all the currently pending transactions as well as the ones queued for future processing. |
| 11 | + |
| 12 | + |
| 13 | +.. code-block:: javascript |
| 14 | +
|
| 15 | + import Web3 from 'web3'; |
| 16 | + import {Txpool} from 'web3-eth-txpool'; |
| 17 | +
|
| 18 | + // "Web3.givenProvider" will be set if in an Ethereum supported browser. |
| 19 | + const txpool = new Txpool(Web3.givenProvider || 'ws://some.local-or-remote.node:8546', null, options); |
| 20 | +
|
| 21 | +
|
| 22 | + // or using the web3 umbrella package |
| 23 | + const web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546', null, options); |
| 24 | +
|
| 25 | + // -> web3.eth.txpool |
| 26 | +
|
| 27 | +
|
| 28 | +------------------------------------------------------------------------------ |
| 29 | + |
| 30 | + |
| 31 | +.. include:: include_package-core.rst |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +------------------------------------------------------------------------------ |
| 36 | + |
| 37 | +.. _txpool-content: |
| 38 | + |
| 39 | +content |
| 40 | +========= |
| 41 | + |
| 42 | +.. code-block:: javascript |
| 43 | +
|
| 44 | + web3.eth.txpool.content([callback]) |
| 45 | +
|
| 46 | +This API can be used to list the exact details of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future executions. |
| 47 | +The RPC method used is ``txpool_content``. |
| 48 | + |
| 49 | +---------- |
| 50 | +Parameters |
| 51 | +---------- |
| 52 | + |
| 53 | +1. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. |
| 54 | + |
| 55 | +------- |
| 56 | +Returns |
| 57 | +------- |
| 58 | + |
| 59 | +``Promise<Object>`` - The list of pending as well as queued transactions. |
| 60 | + |
| 61 | + - ``pending`` - ``string{}``: List of pending transactions with transaction details. |
| 62 | + - ``queued`` - ``string{}``: List of queued transactions with transaction details. |
| 63 | + |
| 64 | + - ``hash`` 32 Bytes - ``String``: Hash of the transaction. |
| 65 | + - ``nonce`` - ``Number``: The number of transactions made by the sender prior to this one. |
| 66 | + - ``blockHash`` 32 Bytes - ``String``: Hash of the block where this transaction was in. ``null`` when its pending. |
| 67 | + - ``blockNumber`` - ``Number``: Block number where this transaction was in. ``null`` when its pending. |
| 68 | + - ``transactionIndex`` - ``Number``: Integer of the transactions index position in the block. ``null`` when its pending. |
| 69 | + - ``from`` - ``String``: Address of the sender. |
| 70 | + - ``to`` - ``String``: Address of the receiver. ``null`` when its a contract creation transaction. |
| 71 | + - ``value`` - ``String``: Value transferred in :ref:`wei <what-is-wei>`. |
| 72 | + - ``gasPrice`` - ``String``: The wei per unit of gas provided by the sender in :ref:`wei <what-is-wei>`. |
| 73 | + - ``gas`` - ``Number``: Gas provided by the sender. |
| 74 | + - ``input`` - ``String``: The data sent along with the transaction. |
| 75 | + |
| 76 | +------- |
| 77 | +Example |
| 78 | +------- |
| 79 | + |
| 80 | +.. code-block:: javascript |
| 81 | +
|
| 82 | + web3.eth.txpool.content().then(console.log); |
| 83 | + > { |
| 84 | + pending: { |
| 85 | + 0x0216d5032f356960cd3749c31ab34eeff21b3395: { |
| 86 | + 806: [{ |
| 87 | + blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000", |
| 88 | + blockNumber: null, |
| 89 | + from: "0x0216d5032f356960cd3749c31ab34eeff21b3395", |
| 90 | + gas: "0x5208", |
| 91 | + gasPrice: "0xba43b7400", |
| 92 | + hash: "0xaf953a2d01f55cfe080c0c94150a60105e8ac3d51153058a1f03dd239dd08586", |
| 93 | + input: "0x", |
| 94 | + nonce: "0x326", |
| 95 | + to: "0x7f69a91a3cf4be60020fb58b893b7cbb65376db8", |
| 96 | + transactionIndex: null, |
| 97 | + value: "0x19a99f0cf456000" |
| 98 | + }] |
| 99 | + }, |
| 100 | + 0x24d407e5a0b506e1cb2fae163100b5de01f5193c: { |
| 101 | + 34: [{ |
| 102 | + blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000", |
| 103 | + blockNumber: null, |
| 104 | + from: "0x24d407e5a0b506e1cb2fae163100b5de01f5193c", |
| 105 | + gas: "0x44c72", |
| 106 | + gasPrice: "0x4a817c800", |
| 107 | + hash: "0xb5b8b853af32226755a65ba0602f7ed0e8be2211516153b75e9ed640a7d359fe", |
| 108 | + input: "0xb61d27f600000000000000000000000024d407e5a0b506e1cb2fae163100b5de01f5193c00000000000000000000000000000000000000000000000053444835ec580000000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", |
| 109 | + nonce: "0x22", |
| 110 | + to: "0x7320785200f74861b69c49e4ab32399a71b34f1a", |
| 111 | + transactionIndex: null, |
| 112 | + value: "0x0" |
| 113 | + }] |
| 114 | + } |
| 115 | + }, |
| 116 | + queued: { |
| 117 | + 0x976a3fc5d6f7d259ebfb4cc2ae75115475e9867c: { |
| 118 | + 3: [{ |
| 119 | + blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000", |
| 120 | + blockNumber: null, |
| 121 | + from: "0x976a3fc5d6f7d259ebfb4cc2ae75115475e9867c", |
| 122 | + gas: "0x15f90", |
| 123 | + gasPrice: "0x4a817c800", |
| 124 | + hash: "0x57b30c59fc39a50e1cba90e3099286dfa5aaf60294a629240b5bbec6e2e66576", |
| 125 | + input: "0x", |
| 126 | + nonce: "0x3", |
| 127 | + to: "0x346fb27de7e7370008f5da379f74dd49f5f2f80f", |
| 128 | + transactionIndex: null, |
| 129 | + value: "0x1f161421c8e0000" |
| 130 | + }] |
| 131 | + }, |
| 132 | + 0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a: { |
| 133 | + 2: [{ |
| 134 | + blockHash: "0x0000000000000000000000000000000000000000000000000000000000000000", |
| 135 | + blockNumber: null, |
| 136 | + from: "0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a", |
| 137 | + gas: "0x15f90", |
| 138 | + gasPrice: "0xba43b7400", |
| 139 | + hash: "0x3a3c0698552eec2455ed3190eac3996feccc806970a4a056106deaf6ceb1e5e3", |
| 140 | + input: "0x", |
| 141 | + nonce: "0x2", |
| 142 | + to: "0x24a461f25ee6a318bdef7f33de634a67bb67ac9d", |
| 143 | + transactionIndex: null, |
| 144 | + value: "0xebec21ee1da40000" |
| 145 | + }] |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | +
|
| 150 | +------------------------------------------------------------------------------ |
| 151 | + |
| 152 | + |
| 153 | +inspect |
| 154 | +===================== |
| 155 | + |
| 156 | +.. code-block:: javascript |
| 157 | +
|
| 158 | + web3.eth.txpool.inspect([, callback]) |
| 159 | +
|
| 160 | +The property can be queried to list a textual summary of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future executions. |
| 161 | +The RPC method used is ``txpool_inspect``. |
| 162 | + |
| 163 | +---------- |
| 164 | +Parameters |
| 165 | +---------- |
| 166 | + |
| 167 | + |
| 168 | +1. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. |
| 169 | + |
| 170 | + |
| 171 | +------- |
| 172 | +Returns |
| 173 | +------- |
| 174 | + |
| 175 | + |
| 176 | +``Promise<Object>`` - The List of pending and queued transactions summary. |
| 177 | + |
| 178 | + - ``pending`` - ``string{}``: List of pending transactions with transaction details. |
| 179 | + - ``queued`` - ``string{}``: List of queued transactions with transaction details. |
| 180 | + |
| 181 | +------- |
| 182 | +Example |
| 183 | +------- |
| 184 | + |
| 185 | + |
| 186 | +.. code-block:: javascript |
| 187 | +
|
| 188 | + web3.eth.txpool.inspect().then(console.log); |
| 189 | + > { |
| 190 | + pending: { |
| 191 | + 0x26588a9301b0428d95e6fc3a5024fce8bec12d51: { |
| 192 | + 31813: ["0x3375ee30428b2a71c428afa5e89e427905f95f7e: 0 wei + 500000 × 20000000000 gas"] |
| 193 | + }, |
| 194 | + 0x2a65aca4d5fc5b5c859090a6c34d164135398226: { |
| 195 | + 563662: ["0x958c1fa64b34db746925c6f8a3dd81128e40355e: 1051546810000000000 wei + 90000 × 20000000000 gas"], |
| 196 | + 563663: ["0x77517b1491a0299a44d668473411676f94e97e34: 1051190740000000000 wei + 90000 × 20000000000 gas"], |
| 197 | + 563664: ["0x3e2a7fe169c8f8eee251bb00d9fb6d304ce07d3a: 1050828950000000000 wei + 90000 × 20000000000 gas"], |
| 198 | + 563665: ["0xaf6c4695da477f8c663ea2d8b768ad82cb6a8522: 1050544770000000000 wei + 90000 × 20000000000 gas"], |
| 199 | + 563666: ["0x139b148094c50f4d20b01caf21b85edb711574db: 1048598530000000000 wei + 90000 × 20000000000 gas"], |
| 200 | + 563667: ["0x48b3bd66770b0d1eecefce090dafee36257538ae: 1048367260000000000 wei + 90000 × 20000000000 gas"], |
| 201 | + 563668: ["0x468569500925d53e06dd0993014ad166fd7dd381: 1048126690000000000 wei + 90000 × 20000000000 gas"], |
| 202 | + 563669: ["0x3dcb4c90477a4b8ff7190b79b524773cbe3be661: 1047965690000000000 wei + 90000 × 20000000000 gas"], |
| 203 | + 563670: ["0x6dfef5bc94b031407ffe71ae8076ca0fbf190963: 1047859050000000000 wei + 90000 × 20000000000 gas"] |
| 204 | + }, |
| 205 | + 0x9174e688d7de157c5c0583df424eaab2676ac162: { |
| 206 | + 3: ["0xbb9bc244d798123fde783fcc1c72d3bb8c189413: 30000000000000000000 wei + 85000 × 21000000000 gas"] |
| 207 | + }, |
| 208 | + 0xb18f9d01323e150096650ab989cfecd39d757aec: { |
| 209 | + 777: ["0xcd79c72690750f079ae6ab6ccd7e7aedc03c7720: 0 wei + 1000000 × 20000000000 gas"] |
| 210 | + }, |
| 211 | + 0xb2916c870cf66967b6510b76c07e9d13a5d23514: { |
| 212 | + 2: ["0x576f25199d60982a8f31a8dff4da8acb982e6aba: 26000000000000000000 wei + 90000 × 20000000000 gas"] |
| 213 | + }, |
| 214 | + 0xbc0ca4f217e052753614d6b019948824d0d8688b: { |
| 215 | + 0: ["0x2910543af39aba0cd09dbb2d50200b3e800a63d2: 1000000000000000000 wei + 50000 × 1171602790622 gas"] |
| 216 | + }, |
| 217 | + 0xea674fdde714fd979de3edf0f56aa9716b898ec8: { |
| 218 | + 70148: ["0xe39c55ead9f997f7fa20ebe40fb4649943d7db66: 1000767667434026200 wei + 90000 × 20000000000 gas"] |
| 219 | + } |
| 220 | + }, |
| 221 | + queued: { |
| 222 | + 0x0f6000de1578619320aba5e392706b131fb1de6f: { |
| 223 | + 6: ["0x8383534d0bcd0186d326c993031311c0ac0d9b2d: 9000000000000000000 wei + 21000 × 20000000000 gas"] |
| 224 | + }, |
| 225 | + 0x5b30608c678e1ac464a8994c3b33e5cdf3497112: { |
| 226 | + 6: ["0x9773547e27f8303c87089dc42d9288aa2b9d8f06: 50000000000000000000 wei + 90000 × 50000000000 gas"] |
| 227 | + }, |
| 228 | + 0x976a3fc5d6f7d259ebfb4cc2ae75115475e9867c: { |
| 229 | + 3: ["0x346fb27de7e7370008f5da379f74dd49f5f2f80f: 140000000000000000 wei + 90000 × 20000000000 gas"] |
| 230 | + }, |
| 231 | + 0x9b11bf0459b0c4b2f87f8cebca4cfc26f294b63a: { |
| 232 | + 2: ["0x24a461f25ee6a318bdef7f33de634a67bb67ac9d: 17000000000000000000 wei + 90000 × 50000000000 gas"], |
| 233 | + 6: ["0x6368f3f8c2b42435d6c136757382e4a59436a681: 17990000000000000000 wei + 90000 × 20000000000 gas", "0x8db7b4e0ecb095fbd01dffa62010801296a9ac78: 16998950000000000000 wei + 90000 × 20000000000 gas"], |
| 234 | + 7: ["0x6368f3f8c2b42435d6c136757382e4a59436a681: 17900000000000000000 wei + 90000 × 20000000000 gas"] |
| 235 | + } |
| 236 | + } |
| 237 | + } |
| 238 | +
|
| 239 | +
|
| 240 | +------------------------------------------------------------------------------ |
| 241 | + |
| 242 | + |
| 243 | +status |
| 244 | +===================== |
| 245 | + |
| 246 | +.. code-block:: javascript |
| 247 | +
|
| 248 | + web3.eth.txpool.status([, callback]) |
| 249 | +
|
| 250 | +This will provide the number of transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future executions. |
| 251 | +The RPC method used is ``txpool_status``. |
| 252 | + |
| 253 | +---------- |
| 254 | +Parameters |
| 255 | +---------- |
| 256 | + |
| 257 | + |
| 258 | +1. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second. |
| 259 | + |
| 260 | + |
| 261 | +------- |
| 262 | +Returns |
| 263 | +------- |
| 264 | + |
| 265 | + |
| 266 | +``Promise<Object>`` - A list of number of pending and queued transactions. |
| 267 | + |
| 268 | + - ``pending`` - ``number``: Number of pending transactions. |
| 269 | + - ``queued`` - ``number``: Number of queued transactions. |
| 270 | + |
| 271 | +------- |
| 272 | +Example |
| 273 | +------- |
| 274 | + |
| 275 | + |
| 276 | +.. code-block:: javascript |
| 277 | +
|
| 278 | + web3.eth.txpool.status().then(console.log); |
| 279 | + > { |
| 280 | + pending: 10, |
| 281 | + queued: 7 |
| 282 | + } |
| 283 | +
|
| 284 | +------------------------------------------------------------------------------ |
0 commit comments