-
Notifications
You must be signed in to change notification settings - Fork 3
/
web3-eth.rst
1991 lines (1265 loc) · 61.3 KB
/
web3-eth.rst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
.. _eth:
========
web3.eth
========
The ``web3-eth`` package allows you to interact with an Ethereum blockchain and Ethereum smart contracts.
.. code-block:: javascript
var Eth = require('web3-eth');
// "Eth.providers.givenProvider" will be set if in an Ethereum supported browser.
var eth = new Eth(Eth.givenProvider || 'ws://some.local-or-remote.node:8546');
// or using the web3 umbrella package
var Web3 = require('web3');
var web3 = new Web3(Web3.givenProvider || 'ws://some.local-or-remote.node:8546');
// -> web3.eth
Note on checksum addresses
=======
All Ethereum addresses returned by functions of this package are returned as checksum addresses.
This means some letters are uppercase and some are lowercase.
Based on that it will calculate a checksum for the address and prove its correctness.
Incorrect checksum addresses will throw an error when passed into functions.
If you want to circumvent the checksum check you can make an address all lower- or uppercase.
-------
Example
-------
.. code-block:: javascript
web3.eth.getAccounts(console.log);
> ["0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe" ,"0x85F43D8a49eeB85d32Cf465507DD71d507100C1d"]
------------------------------------------------------------------------------
subscribe
=====================
For ``web3.eth.subscribe`` see the :ref:`Subscribe reference documentation <eth-subscribe>`
------------------------------------------------------------------------------
Contract
=====================
For ``web3.eth.Contract`` see the :ref:`Contract reference documentation <eth-contract>`
------------------------------------------------------------------------------
Iban
=====================
For ``web3.eth.Iban`` see the :ref:`Iban reference documentation <eth-iban>`
------------------------------------------------------------------------------
personal
=====================
For ``web3.eth.personal`` see the :ref:`personal reference documentation <eth-personal>`
------------------------------------------------------------------------------
accounts
=====================
For ``web3.eth.accounts`` see the :ref:`accounts reference documentation <eth-accounts>`
------------------------------------------------------------------------------
ens
=====================
For ``web3.eth.ens`` see the :ref:`ENS reference documentation <eth-ens>`
------------------------------------------------------------------------------
abi
=====================
For ``web3.eth.abi`` see the :ref:`ABI reference documentation <eth-abi>`
------------------------------------------------------------------------------
net
=====================
For ``web3.eth.net`` see the :ref:`net reference documentation <eth-net>`
------------------------------------------------------------------------------
.. include:: include_package-core.rst
------------------------------------------------------------------------------
.. _eth-defaultaccount
defaultAccount
=====================
.. code-block:: javascript
web3.eth.defaultAccount
This default address is used as the default ``"from"`` property, if no ``"from"`` property is specified in for the following methods:
- :ref:`web3.eth.sendTransaction() <eth-sendtransaction>`
- :ref:`web3.eth.call() <eth-call>`
- :ref:`new web3.eth.Contract() -> myContract.methods.myMethod().call() <eth-contract-call>`
- :ref:`new web3.eth.Contract() -> myContract.methods.myMethod().send() <eth-contract-send>`
--------
Property
--------
``String`` - 20 Bytes: Any ethereum address. You should have the private key for that address in your node or keystore. (Default is ``undefined``)
-------
Example
-------
.. code-block:: javascript
web3.eth.defaultAccount;
> undefined
// set the default account
web3.eth.defaultAccount = '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe';
------------------------------------------------------------------------------
.. _eth-defaultblock:
defaultBlock
=====================
.. code-block:: javascript
web3.eth.defaultBlock
The default block is used for certain methods. You can override it by passing in the defaultBlock as last parameter.
The default value is "latest".
- :ref:`web3.eth.getBalance() <eth-getbalance>`
- :ref:`web3.eth.getCode() <eth-getcode>`
- :ref:`web3.eth.getTransactionCount() <eth-gettransactioncount>`
- :ref:`web3.eth.getStorageAt() <eth-getstorageat>`
- :ref:`web3.eth.call() <eth-call>`
- :ref:`new web3.eth.Contract() -> myContract.methods.myMethod().call() <eth-contract-call>`
----------
Property
----------
Default block parameters can be one of the following:
- ``Number|BN|BigNumber``: A block number
- ``"genesis"`` - ``String``: The genesis block
- ``"latest"`` - ``String``: The latest block (current head of the blockchain)
- ``"pending"`` - ``String``: The currently mined block (including pending transactions)
- ``"earliest"`` - ``String``: The genesis block
Default is ``"latest"``
-------
Example
-------
.. code-block:: javascript
web3.eth.defaultBlock;
> "latest"
// set the default block
web3.eth.defaultBlock = 231;
------------------------------------------------------------------------------
.. _eth-defaulthardfork:
defaultHardfork
=====================
.. code-block:: javascript
web3.eth.defaultHardfork
The default hardfork property is used for signing transactions locally.
----------
Property
----------
The default hardfork property can be one of the following:
- ``"chainstart"`` - ``String``
- ``"homestead"`` - ``String``
- ``"dao"`` - ``String``
- ``"tangerineWhistle"`` - ``String``
- ``"spuriousDragon"`` - ``String``
- ``"byzantium"`` - ``String``
- ``"constantinople"`` - ``String``
- ``"petersburg"`` - ``String``
- ``"istanbul"`` - ``String``
Default is ``"petersburg"``
-------
Example
-------
.. code-block:: javascript
web3.eth.defaultHardfork;
> "petersburg"
// set the default block
web3.eth.defaultHardfork = 'istanbul';
------------------------------------------------------------------------------
.. _eth-defaultchain:
defaultChain
=====================
.. code-block:: javascript
web3.eth.defaultChain
The default chain property is used for signing transactions locally.
----------
Property
----------
The default chain property can be one of the following:
- ``"mainnet"`` - ``String``
- ``"goerli"`` - ``String``
- ``"kovan"`` - ``String``
- ``"rinkeby"`` - ``String``
- ``"ropsten"`` - ``String``
Default is ``"mainnet"``
-------
Example
-------
.. code-block:: javascript
web3.eth.defaultChain;
> "mainnet"
// set the default chain
web3.eth.defaultChain = 'goerli';
------------------------------------------------------------------------------
.. _eth-defaultcommon:
defaultCommon
=====================
.. code-block:: javascript
web3.eth.defaultCommon
The default common property is used for signing transactions locally.
----------
Property
----------
The default common property does contain the following ``Common`` object:
- ``customChain`` - ``Object``: The custom chain properties
- ``name`` - ``string``: (optional) The name of the chain
- ``networkId`` - ``number``: Network ID of the custom chain
- ``chainId`` - ``number``: Chain ID of the custom chain
- ``baseChain`` - ``string``: (optional) ``mainnet``, ``goerli``, ``kovan``, ``rinkeby``, or ``ropsten``
- ``hardfork`` - ``string``: (optional) ``chainstart``, ``homestead``, ``dao``, ``tangerineWhistle``, ``spuriousDragon``, ``byzantium``, ``constantinople``, ``petersburg``, or ``istanbul``
Default is ``undefined``.
-------
Example
-------
.. code-block:: javascript
web3.eth.defaultCommon;
> {customChain: {name: 'custom-network', chainId: 1, networkId: 1}, baseChain: 'mainnet', hardfork: 'petersburg'}
// set the default common
web3.eth.defaultCommon = {customChain: {name: 'custom-network', chainId: 1, networkId: 1}, baseChain: 'mainnet', hardfork: 'petersburg'};
------------------------------------------------------------------------------
.. _web3-module-transactionblocktimeout:
transactionBlockTimeout
=====================
.. code-block:: javascript
web3.eth.transactionBlockTimeout
The ``transactionBlockTimeout`` will be used over a socket based connection. This option does define the amount of new blocks it should wait until the first confirmation happens.
This means the PromiEvent rejects with a timeout error when the timeout got exceeded.
-------
Returns
-------
``number``: The current value of transactionBlockTimeout (default: 50)
------------------------------------------------------------------------------
.. _web3-module-transactionconfirmationblocks:
transactionConfirmationBlocks
=====================
.. code-block:: javascript
web3.eth.transactionConfirmationBlocks
This defines the number of blocks it requires until a transaction will be handled as confirmed.
-------
Returns
-------
``number``: The current value of transactionConfirmationBlocks (default: 24)
------------------------------------------------------------------------------
.. _web3-module-transactionpollingtimeout:
transactionPollingTimeout
=====================
.. code-block:: javascript
web3.eth.transactionPollingTimeout
The ``transactionPollingTimeout`` will be used over a HTTP connection.
This option defines the number of seconds Web3 will wait for a receipt which confirms that a transaction was mined by the network. NB: If this method times out, the transaction may still be pending.
-------
Returns
-------
``number``: The current value of transactionPollingTimeout (default: 750)
------------------------------------------------------------------------------
.. _web3-module-handlerevert:
handleRevert
============
.. code-block:: javascript
web3.eth.handleRevert
The ``handleRevert`` options property does default to ``false`` and will return the revert reason string if enabled for the following methods:
- :ref:`web3.eth.call() <eth-call>`
- :ref:`web3.eth.sendTransaction() <eth-sendtransaction>`
- :ref:`contract.methods.myMethod(...).send(...) <contract-send>`
- :ref:`contract.methods.myMethod(...).call(...) <contract-call>`
.. note:: The revert reason string and the signature does exist as property on the returned error.
-------
Returns
-------
``boolean``: The current value of ``handleRevert`` (default: false)
------------------------------------------------------------------------------
getProtocolVersion
=====================
.. code-block:: javascript
web3.eth.getProtocolVersion([callback])
Returns the ethereum protocol version of the node.
-------
Returns
-------
``Promise`` returns ``String``: the protocol version.
-------
Example
-------
.. code-block:: javascript
web3.eth.getProtocolVersion()
.then(console.log);
> "63"
------------------------------------------------------------------------------
isSyncing
=====================
.. code-block:: javascript
web3.eth.isSyncing([callback])
Checks if the node is currently syncing and returns either a syncing object, or ``false``.
.. _eth-issyncing-return:
-------
Returns
-------
``Promise`` returns ``Object|Boolean`` - A sync object when the node is currently syncing or ``false``:
- ``startingBlock`` - ``Number``: The block number where the sync started.
- ``currentBlock`` - ``Number``: The block number where at which block the node currently synced to already.
- ``highestBlock`` - ``Number``: The estimated block number to sync to.
- ``knownStates`` - ``Number``: The estimated states to download
- ``pulledStates`` - ``Number``: The already downloaded states
-------
Example
-------
.. code-block:: javascript
web3.eth.isSyncing()
.then(console.log);
> {
startingBlock: 100,
currentBlock: 312,
highestBlock: 512,
knownStates: 234566,
pulledStates: 123455
}
------------------------------------------------------------------------------
getCoinbase
=====================
.. code-block:: javascript
getCoinbase([callback])
Returns the coinbase address to which mining rewards will go.
-------
Returns
-------
``Promise`` returns ``String`` - bytes 20: The coinbase address set in the node for mining rewards.
-------
Example
-------
.. code-block:: javascript
web3.eth.getCoinbase()
.then(console.log);
> "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe"
------------------------------------------------------------------------------
isMining
=====================
.. code-block:: javascript
web3.eth.isMining([callback])
Checks whether the node is mining or not.
-------
Returns
-------
``Promise`` returns ``Boolean``: ``true`` if the node is mining, otherwise ``false``.
-------
Example
-------
.. code-block:: javascript
web3.eth.isMining()
.then(console.log);
> true
------------------------------------------------------------------------------
getHashrate
=====================
.. code-block:: javascript
web3.eth.getHashrate([callback])
Returns the number of hashes per second that the node is mining with.
-------
Returns
-------
``Promise`` returns ``Number``: Number of hashes per second.
-------
Example
-------
.. code-block:: javascript
web3.eth.getHashrate()
.then(console.log);
> 493736
------------------------------------------------------------------------------
.. _eth-gasprice:
getGasPrice
=====================
.. code-block:: javascript
web3.eth.getGasPrice([callback])
Returns the current gas price oracle.
The gas price is determined by the last few blocks median gas price.
-------
Returns
-------
``Promise`` returns ``String`` - Number string of the current gas price in :ref:`wei <what-is-wei>`.
See the :ref:`A note on dealing with big numbers in JavaScript <utils-bn>`.
-------
Example
-------
.. code-block:: javascript
web3.eth.getGasPrice()
.then(console.log);
> "20000000000"
------------------------------------------------------------------------------
getAccounts
=====================
.. code-block:: javascript
web3.eth.getAccounts([callback])
Returns a list of accounts the node controls.
-------
Returns
-------
``Promise`` returns ``Array`` - An array of addresses controlled by node.
-------
Example
-------
.. code-block:: javascript
web3.eth.getAccounts()
.then(console.log);
> ["0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "0xDCc6960376d6C6dEa93647383FfB245CfCed97Cf"]
------------------------------------------------------------------------------
getBlockNumber
=====================
.. code-block:: javascript
web3.eth.getBlockNumber([callback])
Returns the current block number.
-------
Returns
-------
``Promise`` returns ``Number`` - The number of the most recent block.
-------
Example
-------
.. code-block:: javascript
web3.eth.getBlockNumber()
.then(console.log);
> 2744
------------------------------------------------------------------------------
getBalance
=====================
.. code-block:: javascript
web3.eth.getBalance(address [, defaultBlock] [, callback])
Get the balance of an address at a given block.
----------
Parameters
----------
1. ``String`` - The address to get the balance of.
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 ``"latest"``, ``"earliest"``, ``"pending"``, and ``"genesis"`` can also be used.
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
-------
Returns
-------
``Promise`` returns ``String`` - The current balance for the given address in :ref:`wei <what-is-wei>`.
See the :ref:`A note on dealing with big numbers in JavaScript <big-numbers-in-javascript>`.
-------
Example
-------
.. code-block:: javascript
web3.eth.getBalance("0x407d73d8a49eeb85d32cf465507dd71d507100c1")
.then(console.log);
> "1000000000000"
------------------------------------------------------------------------------
getStorageAt
=====================
.. code-block:: javascript
web3.eth.getStorageAt(address, position [, defaultBlock] [, callback])
Get the storage at a specific position of an address.
----------
Parameters
----------
1. ``String`` - The address to get the storage from.
2. ``Number|String|BN|BigNumber`` - The index position of the storage.
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 ``"latest"``, ``"earliest"``, ``"pending"``, and ``"genesis"`` can also be used.
4. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
-------
Returns
-------
``Promise`` returns ``String`` - The value in storage at the given position.
-------
Example
-------
.. code-block:: javascript
web3.eth.getStorageAt("0x407d73d8a49eeb85d32cf465507dd71d507100c1", 0)
.then(console.log);
> "0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234"
------------------------------------------------------------------------------
getCode
=====================
.. code-block:: javascript
web3.eth.getCode(address [, defaultBlock] [, callback])
Get the code at a specific address.
----------
Parameters
----------
1. ``String`` - The address to get the code from.
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 ``"latest"``, ``"earliest"``, ``"pending"``, and ``"genesis"`` can also be used.
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
-------
Returns
-------
``Promise`` returns ``String`` - The data at given address ``address``.
-------
Example
-------
.. code-block:: javascript
web3.eth.getCode("0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8")
.then(console.log);
> "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"
------------------------------------------------------------------------------
.. _eth-getblock:
getBlock
=====================
.. code-block:: javascript
web3.eth.getBlock(blockHashOrBlockNumber [, returnTransactionObjects] [, callback])
Returns a block matching the block number or block hash.
----------
Parameters
----------
1. ``String|Number|BN|BigNumber`` - The block number or block hash. Or the string ``"genesis"``, ``"latest"``, ``"earliest"``, or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
2. ``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.
3. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
-------
Returns
-------
``Promise`` returns ``Object`` - The block object:
- ``number`` - ``Number``: The block number. ``null`` when its pending block.
- ``hash`` 32 Bytes - ``String``: Hash of the block. ``null`` when its pending block.
- ``parentHash`` 32 Bytes - ``String``: Hash of the parent block.
- ``nonce`` 8 Bytes - ``String``: Hash of the generated proof-of-work. ``null`` when its pending block.
- ``sha3Uncles`` 32 Bytes - ``String``: SHA3 of the uncles data in the block.
- ``logsBloom`` 256 Bytes - ``String``: The bloom filter for the logs of the block. ``null`` when its pending block.
- ``transactionsRoot`` 32 Bytes - ``String``: The root of the transaction trie of the block
- ``stateRoot`` 32 Bytes - ``String``: The root of the final state trie of the block.
- ``miner`` - ``String``: The address of the beneficiary to whom the mining rewards were given.
- ``difficulty`` - ``String``: Integer of the difficulty for this block.
- ``totalDifficulty`` - ``String``: Integer of the total difficulty of the chain until this block.
- ``extraData`` - ``String``: The "extra data" field of this block.
- ``size`` - ``Number``: Integer the size of this block in bytes.
- ``gasLimit`` - ``Number``: The maximum gas allowed in this block.
- ``gasUsed`` - ``Number``: The total used gas by all transactions in this block.
- ``timestamp`` - ``Number``: The unix timestamp for when the block was collated.
- ``transactions`` - ``Array``: Array of transaction objects, or 32 Bytes transaction hashes depending on the ``returnTransactionObjects`` parameter.
- ``uncles`` - ``Array``: Array of uncle hashes.
-------
Example
-------
.. code-block:: javascript
web3.eth.getBlock(3150)
.then(console.log);
> {
"number": 3,
"hash": "0xef95f2f1ed3ca60b048b4bf67cde2195961e0bba6f70bcbea9a2c4e133e34b46",
"parentHash": "0x2302e1c0b972d00932deb5dab9eb2982f570597d9d42504c05d9c2147eaf9c88",
"nonce": "0xfb6e1a62d119228b",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"transactionsRoot": "0x3a1b03875115b79539e5bd33fb00d8f7b7cd61929d5a3c574f507b8acf415bee",
"stateRoot": "0xf1133199d44695dfa8fd1bcfe424d82854b5cebef75bddd7e40ea94cda515bcb",
"miner": "0x8888f1f195afa192cfee860698584c030f4c9db1",
"difficulty": '21345678965432',
"totalDifficulty": '324567845321',
"size": 616,
"extraData": "0x",
"gasLimit": 3141592,
"gasUsed": 21662,
"timestamp": 1429287689,
"transactions": [
"0x9fc76417374aa880d4449a1f7f31ec597f00b1f6f3dd2d66f4c9c6c445836d8b"
],
"uncles": []
}
------------------------------------------------------------------------------
getBlockTransactionCount
=====================
.. code-block:: javascript
web3.eth.getBlockTransactionCount(blockHashOrBlockNumber [, callback])
Returns the number of transaction in a given block.
----------
Parameters
----------
1. ``String|Number|BN|BigNumber`` - The block number or hash. Or the string ``"genesis"``, ``"latest"``, ``"earliest"``, or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
2. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
-------
Returns
-------
``Promise`` returns ``Number`` - The number of transactions in the given block.
-------
Example
-------
.. code-block:: javascript
web3.eth.getBlockTransactionCount("0x407d73d8a49eeb85d32cf465507dd71d507100c1")
.then(console.log);
> 1
------------------------------------------------------------------------------
getBlockUncleCount
=====================
.. code-block:: javascript
web3.eth.getBlockUncleCount(blockHashOrBlockNumber [, callback])
Returns the number of uncles in a block from a block matching the given block hash.
----------
Parameters
----------
1. ``String|Number|BN|BigNumber`` - The block number or hash. Or the string ``"genesis"``, ``"latest"``, ``"earliest"``, or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
2. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
-------
Returns
-------
``Promise`` returns ``Number`` - The number of transactions in the given block.
-------
Example
-------
.. code-block:: javascript
web3.eth.getBlockUncleCount("0x407d73d8a49eeb85d32cf465507dd71d507100c1")
.then(console.log);
> 1
------------------------------------------------------------------------------
getUncle
=====================
.. code-block:: javascript
web3.eth.getUncle(blockHashOrBlockNumber, uncleIndex [, returnTransactionObjects] [, callback])
Returns a blocks uncle by a given uncle index position.
----------
Parameters
----------
1. ``String|Number|BN|BigNumber`` - The block number or hash. Or the string ``"genesis"``, ``"latest"``, ``"earliest"``, or ``"pending"`` as in the :ref:`default block parameter <eth-defaultblock>`.
2. ``Number`` - The index position of the uncle.
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.
4. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
-------
Returns
-------
``Promise`` returns ``Object`` - the returned uncle. For a return value see :ref:`web3.eth.getBlock() <eth-getblock>`.
.. note:: An uncle doesn't contain individual transactions.
-------
Example
-------