-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
web3-eth.rst
2254 lines (1439 loc) · 70.7 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
- ``"earliest"`` - ``String``: The genesis block
- ``"latest"`` - ``String``: The latest block (current head of the blockchain)
- ``"pending"`` - ``String``: The currently mined block (including pending transactions)
- ``"finalized"`` - ``String``: (For POS networks) The finalized block is one which has been accepted as canonical by >2/3 of validators.
- ``"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.
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``
- ``"berlin"`` - ``String``
- ``"london"`` - ``String``
Default is ``"london"``
-------
Example
-------
.. code-block:: javascript
web3.eth.defaultHardfork;
> "london"
// 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``, ``istanbul``, ``berlin``, or ``london``
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`` is used over socket-based connections. This option defines the amount of new blocks it should wait until the first confirmation happens, otherwise the PromiEvent rejects with a timeout error.
-------
Returns
-------
``number``: The current value of transactionBlockTimeout (default: 50)
-------
Example
-------
.. code-block:: javascript
web3.eth.transactionBlockTimeout;
> 50
// set the transaction block timeout
web3.eth.transactionBlockTimeout = 100;
------------------------------------------------------------------------------
.. _eth-contract-blockHeaderTimeout:
blockHeaderTimeout
=====================
.. code-block:: javascript
web3.eth.Contract.blockHeaderTimeout
contract.blockHeaderTimeout // on contract instance
The ``blockHeaderTimeout`` is used over socket-based connections. This option defines the amount seconds it should wait for "newBlockHeaders" event before falling back to polling to fetch transaction receipt.
-------
Returns
-------
``number``: The current value of blockHeaderTimeout (default: 10 seconds)
-------
Example
-------
.. code-block:: javascript
web3.eth.blockHeaderTimeout;
> 5
// set the transaction confirmations blocks
web3.eth.blockHeaderTimeout = 10;
------------------------------------------------------------------------------
.. _web3-module-transactionconfirmationblocks:
transactionConfirmationBlocks
=====================
.. code-block:: javascript
web3.eth.transactionConfirmationBlocks
This defines the number of blocks it requires until a transaction is considered confirmed.
-------
Returns
-------
``number``: The current value of transactionConfirmationBlocks (default: 24)
-------
Example
-------
.. code-block:: javascript
web3.eth.transactionConfirmationBlocks;
> 24
// set the transaction confirmations blocks
web3.eth.transactionConfirmationBlocks = 50;
------------------------------------------------------------------------------
.. _web3-module-transactionpollingtimeout:
transactionPollingTimeout
=====================
.. code-block:: javascript
web3.eth.transactionPollingTimeout
The ``transactionPollingTimeout`` is used over HTTP connections. This option defines the number of seconds Web3 will wait for a receipt which confirms that a transaction was mined by the network. Note: If this method times out, the transaction may still be pending.
-------
Returns
-------
``number``: The current value of transactionPollingTimeout (default: 750)
-------
Example
-------
.. code-block:: javascript
web3.eth.transactionPollingTimeout;
> 750
// set the transaction polling timeout
web3.eth.transactionPollingTimeout = 1000;
------------------------------------------------------------------------------
.. _eth-module-transactionpollinginterval:
transactionPollingInterval
=====================
.. code-block:: javascript
web3.eth.transactionPollingInterval
The ``transactionPollingInterval`` is used over HTTP connections. This option defines the number of seconds between Web3 calls for a receipt which confirms that a transaction was mined by the network.
-------
Returns
-------
``number``: The current value of transactionPollingInterval (default: 1000ms)
------------------------------------------------------------------------------
.. _web3-module-handlerevert:
handleRevert
============
.. code-block:: javascript
web3.eth.handleRevert
The ``handleRevert`` options property defaults to ``false`` and returns 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 signature exist as a property on the returned error.
-------
Returns
-------
``boolean``: The current value of ``handleRevert`` (default: false)
-------
Example
-------
.. code-block:: javascript
web3.eth.handlRevert;
> false
// turn revert handling on
web3.eth.handleRevert = true;
------------------------------------------------------------------------------
.. _web3-module-maxListenersWarningThreshold:
maxListenersWarningThreshold
=====================
.. code-block:: javascript
web3.eth.maxListenersWarningThreshold
This defines the threshold above which a warning about the number of event listeners
attached to a provider which supports sockets subscriptions will be written to the console.
You may see this warning if you call ``setProvider`` on large numbers of Web3 contract objects.
-------
Returns
-------
``number``: The current value of maxListenersWarningThreshold (default: 100)
-------
Example
-------
.. code-block:: javascript
web3.eth.maxListenersWarningThreshold;
> 100
// set the max listeners warning threshold
web3.eth.maxListenersWarningThreshold = 200;
------------------------------------------------------------------------------
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 the node is currently synced to.
- ``highestBlock`` - ``Number``: The estimated block number to sync to.
- ``knownStates`` - ``Number``: The number of estimated states to download.
- ``pulledStates`` - ``Number``: The number of 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"
------------------------------------------------------------------------------
.. _eth-feehistory:
getFeeHistory
=====================
.. code-block:: javascript
web3.eth.getFeeHistory(blockCount, newestBlock, rewardPercentiles, [callback])
Transaction fee history
Returns base fee per gas and transaction effective priority fee per gas history for the requested block range if available.
The range between headBlock-4 and headBlock is guaranteed to be available while retrieving data from the pending block and older
history are optional to support. For pre-EIP-1559 blocks the gas prices are returned as rewards and zeroes are returned for the base fee per gas.
----------
Parameters
----------
1. ``String|Number|BN|BigNumber`` - Number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. Less than requested may be returned if not all blocks are available.
2. ``String|Number|BN|BigNumber`` - Highest number block of the requested range.
3. ``Array of numbers`` - A monotonically increasing list of percentile values to sample from each block's effective priority fees per gas in ascending order, weighted by gas used. Example: `["0", "25", "50", "75", "100"]` or `["0", "0.5", "1", "1.5", "3", "80"]`
4. ``Function`` - (optional) Optional callback, returns an error object as first parameter and the result as second.
-------
Returns
-------
``Promise`` returns ``Object`` - Fee history for the returned block range. The object:
- ``Number`` oldestBlock - Lowest number block of the returned range.
- ``Array of strings`` baseFeePerGas - An array of block base fees per gas. This includes the next block after the newest of the returned range, because this value can be derived from the newest block. Zeroes are returned for pre-EIP-1559 blocks.
- ``Array of numbers`` gasUsedRatio - An array of block gas used ratios. These are calculated as the ratio of gasUsed and gasLimit.
- ``Array of string arrays`` reward - An array of effective priority fee per gas data points from a single block. All zeroes are returned if the block is empty.
------------------------------------------------------------------------------
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 ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` 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 <utils-bn>`.
-------
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 ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` 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 ``"earliest"``, ``"latest"`` , ``"pending"``, ``"safe"`` or ``"finalized"`` 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])