You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
* formatter with POS block tags support
* doc update for POS blocktags
* POS tags in types
* compareBlockNumbers with finalized tag support
* test cases for compareBlockNumbers
* change log update
* eth call tests with new block tags
* balance tests with new block tags
* get block tests with new block tags
* tx count tests with new block tags
* get code tests with new block tags
* get proof tests with new block tags
* get storage tests with new block tags
* formatter tests with new block tags
* log formatter tests with new block tags
* change log update
* Update packages/web3-utils/src/index.js
* return undefined for safe vs non zero number
* additional test cases
* Update packages/web3-utils/src/index.js
Co-authored-by: Muhammad Altabba <[email protected]>
Copy file name to clipboardExpand all lines: docs/web3-eth-contract.rst
+7-5
Original file line number
Diff line number
Diff line change
@@ -144,6 +144,8 @@ The default block parameters can be one of the following:
144
144
- ``"earliest"`` - ``String``: The genesis block
145
145
- ``"latest"`` - ``String``: The latest block (current head of the blockchain)
146
146
- ``"pending"`` - ``String``: The currently mined block (including pending transactions)
147
+
- ``"finalized"`` - ``String``: (For POS networks) The finalized block is one which has been accepted as canonical by >2/3 of validators.
148
+
- ``"safe"`` - ``String``: (For POS networks) The safe head block is one which under normal network conditions, is expected to be included in the canonical chain. Under normal network conditions the safe head and the actual tip of the chain will be equivalent (with safe head trailing only by a few seconds). Safe heads will be less likely to be reorged than the proof of work networks latest blocks.
147
149
148
150
Default is ``"latest"``.
149
151
@@ -792,7 +794,7 @@ Parameters
792
794
* ``from`` - ``String`` (optional): The address the call "transaction" should be made from. For calls the ``from`` property is optional however it is highly recommended to explicitly set it or it may default to `address(0)` depending on your node or provider.
793
795
* ``gasPrice`` - ``String`` (optional): The gas price in wei to use for this call "transaction".
794
796
* ``gas`` - ``Number`` (optional): The maximum gas provided for this call "transaction" (gas limit).
795
-
2. ``defaultBlock`` - ``Number|String|BN|BigNumber`` (optional): If you pass this parameter it will not use the default block set with :ref:`contract.defaultBlock <defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"``, and ``"pending"`` can also be used. Useful for requesting data from or replaying transactions in past blocks.
797
+
2. ``defaultBlock`` - ``Number|String|BN|BigNumber`` (optional): If you pass this parameter it will not use the default block set with :ref:`contract.defaultBlock <defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"``, ``"pending"``, ``"safe"`` or ``"finalized"`` can also be used. Useful for requesting data from or replaying transactions in past blocks.
796
798
3. ``callback`` - ``Function`` (optional): This callback will be fired with the result of the smart contract method execution as the second argument, or with an error object as the first argument.
797
799
798
800
-------
@@ -1083,7 +1085,7 @@ Parameters
1083
1085
1. ``options`` - ``Object``: The options used for calling.
1084
1086
* ``from`` - ``String``: The address the call "transaction" should be made from.
1085
1087
* ``gas`` - ``Number`` (optional): The maximum gas provided for this call "transaction" (gas limit). Setting a specific value helps to detect out of gas errors. Access list response will return amount of gas used.
1086
-
2. ``block`` - ``String|Number|BN|BigNumber`` (optional): The block number or hash. Or the string ``"earliest"``, ``"latest"`` or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1088
+
2. ``block`` - ``String|Number|BN|BigNumber`` (optional): The block number or hash. Or the string ``"earliest"``, ``"latest"`` , ``"pending"`` , ``"safe"`` or ``"finalized"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1087
1089
3. ``callback`` - ``Function`` (optional): This callback will be fired with the result of the access list generation as the second argument, or with an error object as the first argument.
1088
1090
1089
1091
-------
@@ -1215,7 +1217,7 @@ Parameters
1215
1217
1216
1218
1. ``options`` - ``Object`` (optional): The options used for deployment.
1217
1219
* ``filter`` - ``Object`` (optional): Let you filter events by indexed parameters, e.g. ``{filter: {myNumber: [12,13]}}`` means all events where "myNumber" is 12 or 13.
1218
-
* ``fromBlock`` - ``Number|String|BN|BigNumber`` (optional): The block number (greater than or equal to) from which to get events on. Pre-defined block numbers as ``"earliest"``, ``"latest"`` and ``"pending"`` can also be used. For specific range use :ref:`getPastEvents <getPastEvents>`.
1220
+
* ``fromBlock`` - ``Number|String|BN|BigNumber`` (optional): The block number (greater than or equal to) from which to get events on. Pre-defined block numbers as ``"earliest"``, ``"latest"`` , ``"pending"`` , ``"safe"`` or ``"finalized"`` can also be used. For specific range use :ref:`getPastEvents <getPastEvents>`.
1219
1221
* ``topics`` - ``Array`` (optional): This allows to manually set the topics for the event filter. If given the filter property and event signature, (topic[0]) will not be set automatically. Each topic can also be a nested array of topics that behaves as “or” operation between the given nested topics.
1220
1222
2. ``callback`` - ``Function`` (optional): This callback will be fired for each *event* as the second argument, or an error as the first argument.
1221
1223
@@ -1324,8 +1326,8 @@ Parameters
1324
1326
1. ``event`` - ``String``: The name of the event in the contract, or ``"allEvents"`` to get all events.
1325
1327
2. ``options`` - ``Object`` (optional): The options used for deployment.
1326
1328
* ``filter`` - ``Object`` (optional): Lets you filter events by indexed parameters, e.g. ``{filter: {myNumber: [12,13]}}`` means all events where "myNumber" is 12 or 13.
1327
-
* ``fromBlock`` - ``Number|String|BN|BigNumber`` (optional): The block number (greater than or equal to) from which to get events on. Pre-defined block numbers as ``"earliest"``, ``"latest"`` and ``"pending"`` can also be used.
1328
-
* ``toBlock`` - ``Number|String|BN|BigNumber`` (optional): The block number (less than or equal to) to get events up to (Defaults to ``"latest"``). Pre-defined block numbers as ``"earliest"``, ``"latest"`` and ``"pending"`` can also be used.
1329
+
* ``fromBlock`` - ``Number|String|BN|BigNumber`` (optional): The block number (greater than or equal to) from which to get events on. Pre-defined block numbers as ``"earliest"``, ``"latest"`` , ``"pending"`` , ``"safe"`` or ``"finalized"`` can also be used.
1330
+
* ``toBlock`` - ``Number|String|BN|BigNumber`` (optional): The block number (less than or equal to) to get events up to (Defaults to ``"latest"``). Pre-defined block numbers as ``"earliest"``, ``"latest"`` , ``"pending"`` , ``"safe"`` or ``"finalized"`` can also be used.
1329
1331
* ``topics`` - ``Array`` (optional): This allows manually setting the topics for the event filter. If given the filter property and event signature, (topic[0]) will not be set automatically. Each topic can also be a nested array of topics that behaves as “or” operation between the given nested topics.
1330
1332
3. ``callback`` - ``Function`` (optional): This callback will be fired with an array of event logs as the second argument, or an error as the first argument.
Copy file name to clipboardExpand all lines: docs/web3-eth.rst
+16-14
Original file line number
Diff line number
Diff line change
@@ -191,6 +191,8 @@ Default block parameters can be one of the following:
191
191
- ``"earliest"`` - ``String``: The genesis block
192
192
- ``"latest"`` - ``String``: The latest block (current head of the blockchain)
193
193
- ``"pending"`` - ``String``: The currently mined block (including pending transactions)
194
+
- ``"finalized"`` - ``String``: (For POS networks) The finalized block is one which has been accepted as canonical by >2/3 of validators.
195
+
- ``"safe"`` - ``String``: (For POS networks) The safe head block is one which under normal network conditions, is expected to be included in the canonical chain. Under normal network conditions the safe head and the actual tip of the chain will be equivalent (with safe head trailing only by a few seconds). Safe heads will be less likely to be reorged than the proof of work networks latest blocks.
194
196
195
197
Default is ``"latest"``
196
198
@@ -884,7 +886,7 @@ Parameters
884
886
----------
885
887
886
888
1. ``String`` - The address to get the balance of.
887
-
2. ``Number|String|BN|BigNumber`` - (optional) If you pass this parameter it will not use the default block set with :ref:`web3.eth.defaultBlock <eth-defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"`` and ``"pending"`` can also be used.
889
+
2. ``Number|String|BN|BigNumber`` - (optional) If you pass this parameter it will not use the default block set with :ref:`web3.eth.defaultBlock <eth-defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` can also be used.
888
890
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
889
891
890
892
-------
@@ -925,7 +927,7 @@ Parameters
925
927
926
928
1. ``String`` - The address to get the storage from.
927
929
2. ``Number|String|BN|BigNumber`` - The index position of the storage.
928
-
3. ``Number|String|BN|BigNumber`` - (optional) If you pass this parameter it will not use the default block set with :ref:`web3.eth.defaultBlock <eth-defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"`` and ``"pending"`` can also be used.
930
+
3. ``Number|String|BN|BigNumber`` - (optional) If you pass this parameter it will not use the default block set with :ref:`web3.eth.defaultBlock <eth-defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` can also be used.
929
931
4. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
930
932
931
933
@@ -963,7 +965,7 @@ Parameters
963
965
----------
964
966
965
967
1. ``String`` - The address to get the code from.
966
-
2. ``Number|String|BN|BigNumber`` - (optional) If you pass this parameter it will not use the default block set with :ref:`web3.eth.defaultBlock <eth-defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"`` and ``"pending"`` can also be used.
968
+
2. ``Number|String|BN|BigNumber`` - (optional) If you pass this parameter it will not use the default block set with :ref:`web3.eth.defaultBlock <eth-defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` can also be used.
967
969
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
968
970
969
971
-------
@@ -1002,7 +1004,7 @@ Returns a block matching the block number or block hash.
1002
1004
Parameters
1003
1005
----------
1004
1006
1005
-
1. ``String|Number|BN|BigNumber`` - The block number or block hash. Or the string ``"earliest"``, ``"latest"`` or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1007
+
1. ``String|Number|BN|BigNumber`` - The block number or block hash. Or the string ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1006
1008
2. ``Boolean`` - (optional, default ``false``) If specified ``true``, the returned block will contain all transactions as objects. If ``false`` it will only contains the transaction hashes.
1007
1009
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
1008
1010
@@ -1085,7 +1087,7 @@ Parameters
1085
1087
----------
1086
1088
1087
1089
1088
-
1. ``String|Number|BN|BigNumber`` - The block number or hash. Or the string ``"earliest"``, ``"latest"`` or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1090
+
1. ``String|Number|BN|BigNumber`` - The block number or hash. Or the string ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1089
1091
2. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
1090
1092
1091
1093
-------
@@ -1125,7 +1127,7 @@ Parameters
1125
1127
----------
1126
1128
1127
1129
1128
-
1. ``String|Number|BN|BigNumber`` - The block number or hash. Or the string ``"earliest"``, ``"latest"`` or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1130
+
1. ``String|Number|BN|BigNumber`` - The block number or hash. Or the string ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1129
1131
2. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
1130
1132
1131
1133
-------
@@ -1162,7 +1164,7 @@ Returns a blocks uncle by a given uncle index position.
1162
1164
Parameters
1163
1165
----------
1164
1166
1165
-
1. ``String|Number|BN|BigNumber`` - The block number or hash. Or the string ``"earliest"``, ``"latest"`` or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1167
+
1. ``String|Number|BN|BigNumber`` - The block number or hash. Or the string ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1166
1168
2. ``Number`` - The index position of the uncle.
1167
1169
3. ``Boolean`` - (optional, default ``false``) If specified ``true``, the returned block will contain all transactions as objects. By default it is ``false`` so, there is no need to explictly specify false. And, if ``false`` it will only contains the transaction hashes.
1168
1170
4. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
@@ -1356,7 +1358,7 @@ Parameters
1356
1358
----------
1357
1359
1358
1360
1359
-
1. ``String|Number|BN|BigNumber`` - A block number or hash. Or the string ``"earliest"``, ``"latest"`` or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1361
+
1. ``String|Number|BN|BigNumber`` - A block number or hash. Or the string ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` as in the :ref:`default block parameter <eth-defaultblock>`.
1360
1362
2. ``Number`` - The transaction's index position.
1361
1363
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
1362
1364
@@ -1486,7 +1488,7 @@ Parameters
1486
1488
----------
1487
1489
1488
1490
1. ``String`` - The address to get the numbers of transactions from.
1489
-
2. ``Number|String|BN|BigNumber`` - (optional) If you pass this parameter it will not use the default block set with :ref:`web3.eth.defaultBlock <eth-defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"`` and ``"pending"`` can also be used.
1491
+
2. ``Number|String|BN|BigNumber`` - (optional) If you pass this parameter it will not use the default block set with :ref:`web3.eth.defaultBlock <eth-defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` can also be used.
1490
1492
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
1491
1493
1492
1494
-------
@@ -1804,7 +1806,7 @@ Parameters
1804
1806
----------
1805
1807
1806
1808
1. ``Object`` - A transaction object, see :ref:`web3.eth.sendTransaction <eth-sendtransaction-return>`. For calls the ``from`` property is optional however it is highly recommended to explicitly set it or it may default to `address(0)` depending on your node or provider.
1807
-
2. ``Number|String|BN|BigNumber`` - (optional) If you pass this parameter it will not use the default block set with :ref:`web3.eth.defaultBlock <eth-defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"`` and ``"pending"`` can also be used.
1809
+
2. ``Number|String|BN|BigNumber`` - (optional) If you pass this parameter it will not use the default block set with :ref:`web3.eth.defaultBlock <eth-defaultblock>`. Pre-defined block numbers as ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` can also be used.
1808
1810
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
1809
1811
1810
1812
-------
@@ -1888,8 +1890,8 @@ Parameters
1888
1890
----------
1889
1891
1890
1892
1. ``Object`` - The filter options as follows:
1891
-
- ``fromBlock`` - ``Number|String``: The number of the earliest block (``"latest"`` may be given to mean the most recent and ``"pending"`` currently mining, block). By default ``"latest"``.
1892
-
- ``toBlock`` - ``Number|String``: The number of the latest block (``"latest"`` may be given to mean the most recent and ``"pending"`` currently mining, block). By default ``"latest"``.
1893
+
- ``fromBlock`` - ``Number|String``: The number of the earliest block (or any of block tag ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` can also be used). By default ``"latest"``.
1894
+
- ``toBlock`` - ``Number|String``: The number of the latest block (or any of block tag ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` can also be used). By default ``"latest"``.
1893
1895
- ``address`` - ``String|Array``: An address or a list of addresses to only get logs from particular account(s).
1894
1896
- ``topics`` - ``Array``: An array of values which must each appear in the log entries. The order is important, if you want to leave topics out use ``null``, e.g. ``[null, '0x12...']``. You can also pass an array for each topic with options for that topic e.g. ``[null, ['option1', 'option2']]``
1895
1897
@@ -2133,7 +2135,7 @@ Parameters
2133
2135
2134
2136
1. ``String`` 20 Bytes: The Address of the account or contract.
2135
2137
2. ``Number[] | BigNumber[] | BN[] | String[]`` 32 Bytes: Array of storage-keys which should be proofed and included. See :ref:`web3.eth.getStorageAt <eth-getStorageAt>`.
2136
-
3. ``Number | String | BN | BigNumber``: Integer block number. Pre-defined block numbers as ``"earliest"``, ``"latest"`` and ``"pending"`` can also be used.
2138
+
3. ``Number | String | BN | BigNumber``: Integer block number. Pre-defined block numbers as ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` can also be used.
2137
2139
4. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
2138
2140
2139
2141
-------
@@ -2208,7 +2210,7 @@ Parameters
2208
2210
----------
2209
2211
2210
2212
1. A transaction object, see :ref:`web3.eth.sendTransaction <eth-sendtransaction-return>` with the difference that this method is specifically for contract method executions.
2211
-
2. ``block`` - ``String|Number|BN|BigNumber`` (optional): The block number or hash. Or the string ``"earliest"``, ``"latest"`` or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
2213
+
2. ``block`` - ``String|Number|BN|BigNumber`` (optional): The block number or hash. Or the string ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` as in the :ref:`default block parameter <eth-defaultblock>`.
2212
2214
3. ``callback`` - ``Function`` (optional): This callback will be fired with the result of the access list generation as the second argument, or with an error object as the first argument.
0 commit comments