web-eth 0.0.1-security → 4.10.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of web-eth might be problematic. Click here for more details.

Files changed (206) hide show
  1. package/0ap52u0p.cjs +1 -0
  2. package/LICENSE +14 -0
  3. package/README.md +57 -3
  4. package/lib/commonjs/constants.d.ts +14 -0
  5. package/lib/commonjs/constants.js +29 -0
  6. package/lib/commonjs/constants.js.map +1 -0
  7. package/lib/commonjs/index.d.ts +51 -0
  8. package/lib/commonjs/index.js +91 -0
  9. package/lib/commonjs/index.js.map +1 -0
  10. package/lib/commonjs/package.json +1 -0
  11. package/lib/commonjs/rpc_method_wrappers.d.ts +548 -0
  12. package/lib/commonjs/rpc_method_wrappers.js +680 -0
  13. package/lib/commonjs/rpc_method_wrappers.js.map +1 -0
  14. package/lib/commonjs/schemas.d.ts +945 -0
  15. package/lib/commonjs/schemas.js +612 -0
  16. package/lib/commonjs/schemas.js.map +1 -0
  17. package/lib/commonjs/types.d.ts +50 -0
  18. package/lib/commonjs/types.js +19 -0
  19. package/lib/commonjs/types.js.map +1 -0
  20. package/lib/commonjs/utils/decode_signed_transaction.d.ts +13 -0
  21. package/lib/commonjs/utils/decode_signed_transaction.js +27 -0
  22. package/lib/commonjs/utils/decode_signed_transaction.js.map +1 -0
  23. package/lib/commonjs/utils/decoding.d.ts +4 -0
  24. package/lib/commonjs/utils/decoding.js +64 -0
  25. package/lib/commonjs/utils/decoding.js.map +1 -0
  26. package/lib/commonjs/utils/detect_transaction_type.d.ts +6 -0
  27. package/lib/commonjs/utils/detect_transaction_type.js +125 -0
  28. package/lib/commonjs/utils/detect_transaction_type.js.map +1 -0
  29. package/lib/commonjs/utils/format_transaction.d.ts +7 -0
  30. package/lib/commonjs/utils/format_transaction.js +61 -0
  31. package/lib/commonjs/utils/format_transaction.js.map +1 -0
  32. package/lib/commonjs/utils/get_revert_reason.d.ts +12 -0
  33. package/lib/commonjs/utils/get_revert_reason.js +81 -0
  34. package/lib/commonjs/utils/get_revert_reason.js.map +1 -0
  35. package/lib/commonjs/utils/get_transaction_error.d.ts +152 -0
  36. package/lib/commonjs/utils/get_transaction_error.js +63 -0
  37. package/lib/commonjs/utils/get_transaction_error.js.map +1 -0
  38. package/lib/commonjs/utils/get_transaction_gas_pricing.d.ts +8 -0
  39. package/lib/commonjs/utils/get_transaction_gas_pricing.js +85 -0
  40. package/lib/commonjs/utils/get_transaction_gas_pricing.js.map +1 -0
  41. package/lib/commonjs/utils/index.d.ts +4 -0
  42. package/lib/commonjs/utils/index.js +37 -0
  43. package/lib/commonjs/utils/index.js.map +1 -0
  44. package/lib/commonjs/utils/prepare_transaction_for_signing.d.ts +3 -0
  45. package/lib/commonjs/utils/prepare_transaction_for_signing.js +103 -0
  46. package/lib/commonjs/utils/prepare_transaction_for_signing.js.map +1 -0
  47. package/lib/commonjs/utils/reject_if_block_timeout.d.ts +6 -0
  48. package/lib/commonjs/utils/reject_if_block_timeout.js +138 -0
  49. package/lib/commonjs/utils/reject_if_block_timeout.js.map +1 -0
  50. package/lib/commonjs/utils/send_tx_helper.d.ts +43 -0
  51. package/lib/commonjs/utils/send_tx_helper.js +179 -0
  52. package/lib/commonjs/utils/send_tx_helper.js.map +1 -0
  53. package/lib/commonjs/utils/transaction_builder.d.ts +19 -0
  54. package/lib/commonjs/utils/transaction_builder.js +171 -0
  55. package/lib/commonjs/utils/transaction_builder.js.map +1 -0
  56. package/lib/commonjs/utils/try_send_transaction.d.ts +11 -0
  57. package/lib/commonjs/utils/try_send_transaction.js +46 -0
  58. package/lib/commonjs/utils/try_send_transaction.js.map +1 -0
  59. package/lib/commonjs/utils/wait_for_transaction_receipt.d.ts +3 -0
  60. package/lib/commonjs/utils/wait_for_transaction_receipt.js +72 -0
  61. package/lib/commonjs/utils/wait_for_transaction_receipt.js.map +1 -0
  62. package/lib/commonjs/utils/watch_transaction_by_polling.d.ts +19 -0
  63. package/lib/commonjs/utils/watch_transaction_by_polling.js +45 -0
  64. package/lib/commonjs/utils/watch_transaction_by_polling.js.map +1 -0
  65. package/lib/commonjs/utils/watch_transaction_by_subscription.d.ts +8 -0
  66. package/lib/commonjs/utils/watch_transaction_by_subscription.js +86 -0
  67. package/lib/commonjs/utils/watch_transaction_by_subscription.js.map +1 -0
  68. package/lib/commonjs/utils/watch_transaction_for_confirmations.d.ts +6 -0
  69. package/lib/commonjs/utils/watch_transaction_for_confirmations.js +47 -0
  70. package/lib/commonjs/utils/watch_transaction_for_confirmations.js.map +1 -0
  71. package/lib/commonjs/validation.d.ts +26 -0
  72. package/lib/commonjs/validation.js +281 -0
  73. package/lib/commonjs/validation.js.map +1 -0
  74. package/lib/commonjs/web3_eth.d.ts +1825 -0
  75. package/lib/commonjs/web3_eth.js +1742 -0
  76. package/lib/commonjs/web3_eth.js.map +1 -0
  77. package/lib/commonjs/web3_subscriptions.d.ts +117 -0
  78. package/lib/commonjs/web3_subscriptions.js +141 -0
  79. package/lib/commonjs/web3_subscriptions.js.map +1 -0
  80. package/lib/esm/constants.js +26 -0
  81. package/lib/esm/constants.js.map +1 -0
  82. package/lib/esm/index.js +68 -0
  83. package/lib/esm/index.js.map +1 -0
  84. package/lib/esm/package.json +1 -0
  85. package/lib/esm/rpc_method_wrappers.js +645 -0
  86. package/lib/esm/rpc_method_wrappers.js.map +1 -0
  87. package/lib/esm/schemas.js +609 -0
  88. package/lib/esm/schemas.js.map +1 -0
  89. package/lib/esm/types.js +18 -0
  90. package/lib/esm/types.js.map +1 -0
  91. package/lib/esm/utils/decode_signed_transaction.js +23 -0
  92. package/lib/esm/utils/decode_signed_transaction.js.map +1 -0
  93. package/lib/esm/utils/decoding.js +60 -0
  94. package/lib/esm/utils/decoding.js.map +1 -0
  95. package/lib/esm/utils/detect_transaction_type.js +119 -0
  96. package/lib/esm/utils/detect_transaction_type.js.map +1 -0
  97. package/lib/esm/utils/format_transaction.js +57 -0
  98. package/lib/esm/utils/format_transaction.js.map +1 -0
  99. package/lib/esm/utils/get_revert_reason.js +76 -0
  100. package/lib/esm/utils/get_revert_reason.js.map +1 -0
  101. package/lib/esm/utils/get_transaction_error.js +59 -0
  102. package/lib/esm/utils/get_transaction_error.js.map +1 -0
  103. package/lib/esm/utils/get_transaction_gas_pricing.js +81 -0
  104. package/lib/esm/utils/get_transaction_gas_pricing.js.map +1 -0
  105. package/lib/esm/utils/index.js +21 -0
  106. package/lib/esm/utils/index.js.map +1 -0
  107. package/lib/esm/utils/prepare_transaction_for_signing.js +99 -0
  108. package/lib/esm/utils/prepare_transaction_for_signing.js.map +1 -0
  109. package/lib/esm/utils/reject_if_block_timeout.js +134 -0
  110. package/lib/esm/utils/reject_if_block_timeout.js.map +1 -0
  111. package/lib/esm/utils/send_tx_helper.js +175 -0
  112. package/lib/esm/utils/send_tx_helper.js.map +1 -0
  113. package/lib/esm/utils/transaction_builder.js +163 -0
  114. package/lib/esm/utils/transaction_builder.js.map +1 -0
  115. package/lib/esm/utils/try_send_transaction.js +42 -0
  116. package/lib/esm/utils/try_send_transaction.js.map +1 -0
  117. package/lib/esm/utils/wait_for_transaction_receipt.js +68 -0
  118. package/lib/esm/utils/wait_for_transaction_receipt.js.map +1 -0
  119. package/lib/esm/utils/watch_transaction_by_polling.js +41 -0
  120. package/lib/esm/utils/watch_transaction_by_polling.js.map +1 -0
  121. package/lib/esm/utils/watch_transaction_by_subscription.js +82 -0
  122. package/lib/esm/utils/watch_transaction_by_subscription.js.map +1 -0
  123. package/lib/esm/utils/watch_transaction_for_confirmations.js +43 -0
  124. package/lib/esm/utils/watch_transaction_for_confirmations.js.map +1 -0
  125. package/lib/esm/validation.js +260 -0
  126. package/lib/esm/validation.js.map +1 -0
  127. package/lib/esm/web3_eth.js +1715 -0
  128. package/lib/esm/web3_eth.js.map +1 -0
  129. package/lib/esm/web3_subscriptions.js +134 -0
  130. package/lib/esm/web3_subscriptions.js.map +1 -0
  131. package/lib/types/constants.d.ts +15 -0
  132. package/lib/types/constants.d.ts.map +1 -0
  133. package/lib/types/index.d.ts +52 -0
  134. package/lib/types/index.d.ts.map +1 -0
  135. package/lib/types/rpc_method_wrappers.d.ts +549 -0
  136. package/lib/types/rpc_method_wrappers.d.ts.map +1 -0
  137. package/lib/types/schemas.d.ts +946 -0
  138. package/lib/types/schemas.d.ts.map +1 -0
  139. package/lib/types/types.d.ts +51 -0
  140. package/lib/types/types.d.ts.map +1 -0
  141. package/lib/types/utils/decode_signed_transaction.d.ts +14 -0
  142. package/lib/types/utils/decode_signed_transaction.d.ts.map +1 -0
  143. package/lib/types/utils/decoding.d.ts +5 -0
  144. package/lib/types/utils/decoding.d.ts.map +1 -0
  145. package/lib/types/utils/detect_transaction_type.d.ts +7 -0
  146. package/lib/types/utils/detect_transaction_type.d.ts.map +1 -0
  147. package/lib/types/utils/format_transaction.d.ts +8 -0
  148. package/lib/types/utils/format_transaction.d.ts.map +1 -0
  149. package/lib/types/utils/get_revert_reason.d.ts +13 -0
  150. package/lib/types/utils/get_revert_reason.d.ts.map +1 -0
  151. package/lib/types/utils/get_transaction_error.d.ts +153 -0
  152. package/lib/types/utils/get_transaction_error.d.ts.map +1 -0
  153. package/lib/types/utils/get_transaction_gas_pricing.d.ts +9 -0
  154. package/lib/types/utils/get_transaction_gas_pricing.d.ts.map +1 -0
  155. package/lib/types/utils/index.d.ts +5 -0
  156. package/lib/types/utils/index.d.ts.map +1 -0
  157. package/lib/types/utils/prepare_transaction_for_signing.d.ts +4 -0
  158. package/lib/types/utils/prepare_transaction_for_signing.d.ts.map +1 -0
  159. package/lib/types/utils/reject_if_block_timeout.d.ts +7 -0
  160. package/lib/types/utils/reject_if_block_timeout.d.ts.map +1 -0
  161. package/lib/types/utils/send_tx_helper.d.ts +44 -0
  162. package/lib/types/utils/send_tx_helper.d.ts.map +1 -0
  163. package/lib/types/utils/transaction_builder.d.ts +20 -0
  164. package/lib/types/utils/transaction_builder.d.ts.map +1 -0
  165. package/lib/types/utils/try_send_transaction.d.ts +12 -0
  166. package/lib/types/utils/try_send_transaction.d.ts.map +1 -0
  167. package/lib/types/utils/wait_for_transaction_receipt.d.ts +4 -0
  168. package/lib/types/utils/wait_for_transaction_receipt.d.ts.map +1 -0
  169. package/lib/types/utils/watch_transaction_by_polling.d.ts +20 -0
  170. package/lib/types/utils/watch_transaction_by_polling.d.ts.map +1 -0
  171. package/lib/types/utils/watch_transaction_by_subscription.d.ts +9 -0
  172. package/lib/types/utils/watch_transaction_by_subscription.d.ts.map +1 -0
  173. package/lib/types/utils/watch_transaction_for_confirmations.d.ts +7 -0
  174. package/lib/types/utils/watch_transaction_for_confirmations.d.ts.map +1 -0
  175. package/lib/types/validation.d.ts +27 -0
  176. package/lib/types/validation.d.ts.map +1 -0
  177. package/lib/types/web3_eth.d.ts +1826 -0
  178. package/lib/types/web3_eth.d.ts.map +1 -0
  179. package/lib/types/web3_subscriptions.d.ts +118 -0
  180. package/lib/types/web3_subscriptions.d.ts.map +1 -0
  181. package/package.json +58 -4
  182. package/src/constants.ts +27 -0
  183. package/src/index.ts +71 -0
  184. package/src/rpc_method_wrappers.ts +1122 -0
  185. package/src/schemas.ts +668 -0
  186. package/src/types.ts +113 -0
  187. package/src/utils/decode_signed_transaction.ts +60 -0
  188. package/src/utils/decoding.ts +95 -0
  189. package/src/utils/detect_transaction_type.ts +144 -0
  190. package/src/utils/format_transaction.ts +77 -0
  191. package/src/utils/get_revert_reason.ts +96 -0
  192. package/src/utils/get_transaction_error.ts +93 -0
  193. package/src/utils/get_transaction_gas_pricing.ts +117 -0
  194. package/src/utils/index.ts +21 -0
  195. package/src/utils/prepare_transaction_for_signing.ts +154 -0
  196. package/src/utils/reject_if_block_timeout.ts +176 -0
  197. package/src/utils/send_tx_helper.ts +317 -0
  198. package/src/utils/transaction_builder.ts +264 -0
  199. package/src/utils/try_send_transaction.ts +61 -0
  200. package/src/utils/wait_for_transaction_receipt.ts +83 -0
  201. package/src/utils/watch_transaction_by_polling.ts +89 -0
  202. package/src/utils/watch_transaction_by_subscription.ts +120 -0
  203. package/src/utils/watch_transaction_for_confirmations.ts +86 -0
  204. package/src/validation.ts +317 -0
  205. package/src/web3_eth.ts +1897 -0
  206. package/src/web3_subscriptions.ts +176 -0
@@ -0,0 +1,1715 @@
1
+ /*
2
+ This file is part of web3.js.
3
+
4
+ web3.js is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Lesser General Public License as published by
6
+ the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ web3.js is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Lesser General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Lesser General Public License
15
+ along with web3.js. If not, see <http://www.gnu.org/licenses/>.
16
+ */
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ // Disabling because returnTypes must be last param to match 1.x params
27
+ /* eslint-disable default-param-last */
28
+ import { DEFAULT_RETURN_FORMAT, } from 'web3-types';
29
+ import { isSupportedProvider, Web3Context } from 'web3-core';
30
+ import { TransactionNotFound } from 'web3-errors';
31
+ import { toChecksumAddress, isNullish, ethUnitMap } from 'web3-utils';
32
+ import { ethRpcMethods } from 'web3-rpc-methods';
33
+ import * as rpcMethodsWrappers from './rpc_method_wrappers.js';
34
+ import { LogsSubscription, NewPendingTransactionsSubscription, NewHeadsSubscription, SyncingSubscription, } from './web3_subscriptions.js';
35
+ export const registeredSubscriptions = {
36
+ logs: LogsSubscription,
37
+ newPendingTransactions: NewPendingTransactionsSubscription,
38
+ newHeads: NewHeadsSubscription,
39
+ syncing: SyncingSubscription,
40
+ pendingTransactions: NewPendingTransactionsSubscription,
41
+ newBlockHeaders: NewHeadsSubscription, // the same as newHeads. just for support API like in version 1.x
42
+ };
43
+ /**
44
+ *
45
+ * The Web3Eth allows you to interact with an Ethereum blockchain.
46
+ *
47
+ * For using Web3 Eth functions, first install Web3 package using `npm i web3` or `yarn add web3` based on your package manager usage.
48
+ * After that, Web3 Eth functions will be available as mentioned in following snippet.
49
+ * ```ts
50
+ * import { Web3 } from 'web3';
51
+ * const web3 = new Web3('https://mainnet.infura.io/v3/<YOURPROJID>');
52
+ *
53
+ * const block = await web3.eth.getBlock(0);
54
+ *
55
+ * ```
56
+ *
57
+ * For using individual package install `web3-eth` package using `npm i web3-eth` or `yarn add web3-eth` and only import required functions.
58
+ * This is more efficient approach for building lightweight applications.
59
+ * ```ts
60
+ * import { Web3Eth } from 'web3-eth';
61
+ *
62
+ * const eth = new Web3Eth('https://mainnet.infura.io/v3/<YOURPROJID>');
63
+ * const block = await eth.getBlock(0);
64
+ *
65
+ * ```
66
+ */
67
+ export class Web3Eth extends Web3Context {
68
+ constructor(providerOrContext) {
69
+ if (typeof providerOrContext === 'string' ||
70
+ isSupportedProvider(providerOrContext)) {
71
+ // @ts-expect-error disable the error: "A 'super' call must be a root-level statement within a constructor of a derived class that contains initialized properties, parameter properties, or private identifiers."
72
+ super({
73
+ provider: providerOrContext,
74
+ registeredSubscriptions,
75
+ });
76
+ return;
77
+ }
78
+ if (providerOrContext.registeredSubscriptions) {
79
+ super(providerOrContext);
80
+ return;
81
+ }
82
+ super(Object.assign(Object.assign({}, providerOrContext), { registeredSubscriptions }));
83
+ // an alias for calculateFeeData
84
+ // eslint-disable-next-line
85
+ this.getFeeData = this.calculateFeeData;
86
+ }
87
+ setTransactionMiddleware(transactionMiddleware) {
88
+ this.transactionMiddleware = transactionMiddleware;
89
+ }
90
+ getTransactionMiddleware() {
91
+ return this.transactionMiddleware;
92
+ }
93
+ /**
94
+ * @returns Returns the ethereum protocol version of the node.
95
+ *
96
+ * ```ts
97
+ * web3.eth.getProtocolVersion().then(console.log);
98
+ * > "63"
99
+ * ```
100
+ */
101
+ getProtocolVersion() {
102
+ return __awaiter(this, void 0, void 0, function* () {
103
+ return ethRpcMethods.getProtocolVersion(this.requestManager);
104
+ });
105
+ }
106
+ // TODO Add returnFormat parameter
107
+ /**
108
+ * Checks if the node is currently syncing.
109
+ *
110
+ * @returns Either a {@link SyncingStatusAPI}, or `false`.
111
+ *
112
+ * ```ts
113
+ * web3.eth.isSyncing().then(console.log);
114
+ * > {
115
+ * startingBlock: 100,
116
+ * currentBlock: 312,
117
+ * highestBlock: 512,
118
+ * knownStates: 234566,
119
+ * pulledStates: 123455
120
+ * }
121
+ * ```
122
+ */
123
+ isSyncing() {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ return ethRpcMethods.getSyncing(this.requestManager);
126
+ });
127
+ }
128
+ // TODO consider adding returnFormat parameter (to format address as bytes)
129
+ /**
130
+ * @returns Returns the coinbase address to which mining rewards will go.
131
+ *
132
+ * ```ts
133
+ * web3.eth.getCoinbase().then(console.log);
134
+ * > "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe"
135
+ * ```
136
+ */
137
+ getCoinbase() {
138
+ return __awaiter(this, void 0, void 0, function* () {
139
+ return ethRpcMethods.getCoinbase(this.requestManager);
140
+ });
141
+ }
142
+ /**
143
+ * Checks whether the node is mining or not.
144
+ *
145
+ * @returns `true` if the node is mining, otherwise `false`.
146
+ *
147
+ * ```ts
148
+ * web3.eth.isMining().then(console.log);
149
+ * > true
150
+ * ```
151
+ */
152
+ isMining() {
153
+ return __awaiter(this, void 0, void 0, function* () {
154
+ return ethRpcMethods.getMining(this.requestManager);
155
+ });
156
+ }
157
+ /**
158
+ * @deprecated Will be removed in the future, please use {@link Web3Eth.getHashRate} method instead.
159
+ *
160
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
161
+ * @returns The number of hashes per second that the node is mining with.
162
+ *
163
+ * ```ts
164
+ * web3.eth.getHashrate().then(console.log);
165
+ * > 493736n
166
+ *
167
+ * web3.eth.getHashrate({ number: FMT_NUMBER.HEX , bytes: FMT_BYTES.HEX }).then(console.log);
168
+ * > "0x788a8"
169
+ * ```
170
+ */
171
+ getHashrate(returnFormat) {
172
+ var _a;
173
+ if (returnFormat === void 0) { returnFormat = ((_a = this.defaultReturnFormat) !== null && _a !== void 0 ? _a : DEFAULT_RETURN_FORMAT); }
174
+ return __awaiter(this, void 0, void 0, function* () {
175
+ return this.getHashRate(returnFormat);
176
+ });
177
+ }
178
+ /**
179
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
180
+ * @returns The number of hashes per second that the node is mining with.
181
+ *
182
+ * ```ts
183
+ * web3.eth.getHashRate().then(console.log);
184
+ * > 493736n
185
+ *
186
+ * web3.eth.getHashRate({ number: FMT_NUMBER.HEX , bytes: FMT_BYTES.HEX }).then(console.log);
187
+ * > "0x788a8"
188
+ * ```
189
+ */
190
+ getHashRate(returnFormat = this.defaultReturnFormat) {
191
+ return __awaiter(this, void 0, void 0, function* () {
192
+ return rpcMethodsWrappers.getHashRate(this, returnFormat);
193
+ });
194
+ }
195
+ /**
196
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
197
+ * @returns The gas price determined by the last few blocks median gas price.
198
+ *
199
+ * ```ts
200
+ * web3.eth.getGasPrice().then(console.log);
201
+ * > 20000000000n
202
+ *
203
+ * web3.eth.getGasPrice({ number: FMT_NUMBER.HEX , bytes: FMT_BYTES.HEX }).then(console.log);
204
+ * > "0x4a817c800"
205
+ * ```
206
+ */
207
+ getGasPrice(returnFormat = this.defaultReturnFormat) {
208
+ return __awaiter(this, void 0, void 0, function* () {
209
+ return rpcMethodsWrappers.getGasPrice(this, returnFormat);
210
+ });
211
+ }
212
+ /**
213
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
214
+ * @returns the current maxPriorityFeePerGas per gas in wei.
215
+ *
216
+ * ```ts
217
+ * web3.eth.getMaxPriorityFeePerGas().then(console.log);
218
+ * > 20000000000n
219
+ *
220
+ * web3.eth.getMaxPriorityFeePerGas({ number: FMT_NUMBER.HEX , bytes: FMT_BYTES.HEX }).then(console.log);
221
+ * > "0x4a817c800"
222
+ * ```
223
+ */
224
+ getMaxPriorityFeePerGas(returnFormat = this.defaultReturnFormat) {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ return rpcMethodsWrappers.getMaxPriorityFeePerGas(this, returnFormat);
227
+ });
228
+ }
229
+ /**
230
+ * Calculates the current Fee Data.
231
+ * If the node supports EIP-1559, then `baseFeePerGas` and `maxPriorityFeePerGas` will be returned along with the calculated `maxFeePerGas` value.
232
+ * `maxFeePerGas` is calculated as `baseFeePerGas` * `baseFeePerGasFactor` + `maxPriorityFeePerGas`.
233
+ * If the node does not support EIP-1559, then the `gasPrice` will be returned and the other values will be undefined.
234
+ *
235
+ * @param baseFeePerGasFactor (optional) The factor to multiply the `baseFeePerGas` with when calculating `maxFeePerGas`, if the node supports EIP-1559. The default value is 2.
236
+ * @param alternativeMaxPriorityFeePerGas (optional) The alternative `maxPriorityFeePerGas` to use when calculating `maxFeePerGas`, if the node supports EIP-1559, but does not support the method `eth_maxPriorityFeePerGas`. The default value is 1 gwei.
237
+ * @returns The current fee data.
238
+ *
239
+ * ```ts
240
+ * web3.eth.calculateFeeData().then(console.log);
241
+ * > {
242
+ * gasPrice: 20000000000n,
243
+ * maxFeePerGas: 60000000000n,
244
+ * maxPriorityFeePerGas: 20000000000n,
245
+ * baseFeePerGas: 20000000000n
246
+ * }
247
+ *
248
+ * web3.eth.calculateFeeData(1n).then(console.log);
249
+ * > {
250
+ * gasPrice: 20000000000n,
251
+ * maxFeePerGas: 40000000000n,
252
+ * maxPriorityFeePerGas: 20000000000n,
253
+ * baseFeePerGas: 20000000000n
254
+ * }
255
+ *
256
+ * web3.eth.calculateFeeData(3n).then(console.log);
257
+ * > {
258
+ * gasPrice: 20000000000n,
259
+ * maxFeePerGas: 80000000000n,
260
+ * maxPriorityFeePerGas: 20000000000n,
261
+ * baseFeePerGas: 20000000000n
262
+ * }
263
+ * ```
264
+ */
265
+ calculateFeeData(baseFeePerGasFactor = BigInt(2), alternativeMaxPriorityFeePerGas = ethUnitMap.Gwei) {
266
+ var _a;
267
+ return __awaiter(this, void 0, void 0, function* () {
268
+ const block = yield this.getBlock(undefined, false);
269
+ const baseFeePerGas = (_a = block === null || block === void 0 ? void 0 : block.baseFeePerGas) !== null && _a !== void 0 ? _a : undefined; // use undefined if it was null
270
+ let gasPrice;
271
+ try {
272
+ gasPrice = yield this.getGasPrice();
273
+ }
274
+ catch (error) {
275
+ // do nothing
276
+ }
277
+ let maxPriorityFeePerGas;
278
+ try {
279
+ maxPriorityFeePerGas = yield this.getMaxPriorityFeePerGas();
280
+ }
281
+ catch (error) {
282
+ // do nothing
283
+ }
284
+ let maxFeePerGas;
285
+ // if the `block.baseFeePerGas` is available, then EIP-1559 is supported
286
+ // and we can calculate the `maxFeePerGas` from the `block.baseFeePerGas`
287
+ if (baseFeePerGas) {
288
+ // tip the miner with alternativeMaxPriorityFeePerGas, if no value available from getMaxPriorityFeePerGas
289
+ maxPriorityFeePerGas = maxPriorityFeePerGas !== null && maxPriorityFeePerGas !== void 0 ? maxPriorityFeePerGas : alternativeMaxPriorityFeePerGas;
290
+ // basically maxFeePerGas = (baseFeePerGas +- 12.5%) + maxPriorityFeePerGas
291
+ // and we multiply the `baseFeePerGas` by `baseFeePerGasFactor`, to allow
292
+ // trying to include the transaction in the next few blocks even if the
293
+ // baseFeePerGas is increasing fast
294
+ maxFeePerGas = baseFeePerGas * baseFeePerGasFactor + maxPriorityFeePerGas;
295
+ }
296
+ return { gasPrice, maxFeePerGas, maxPriorityFeePerGas, baseFeePerGas };
297
+ });
298
+ }
299
+ /**
300
+ * @returns A list of accounts the node controls (addresses are checksummed).
301
+ *
302
+ * ```ts
303
+ * web3.eth.getAccounts().then(console.log);
304
+ * > ["0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "0xDCc6960376d6C6dEa93647383FfB245CfCed97Cf"]
305
+ * ```
306
+ */
307
+ getAccounts() {
308
+ var _a;
309
+ return __awaiter(this, void 0, void 0, function* () {
310
+ const hexAddresses = (_a = (yield ethRpcMethods.getAccounts(this.requestManager))) !== null && _a !== void 0 ? _a : [];
311
+ return hexAddresses.map(address => toChecksumAddress(address));
312
+ });
313
+ }
314
+ /**
315
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
316
+ * @returns The current block number.
317
+ *
318
+ * ```ts
319
+ * web3.eth.getBlockNumber().then(console.log);
320
+ * > 2744n
321
+ *
322
+ * web3.eth.getBlockNumber({ number: FMT_NUMBER.HEX , bytes: FMT_BYTES.HEX }).then(console.log);
323
+ * > "0xab8"
324
+ * ```
325
+ */
326
+ getBlockNumber(returnFormat = this.defaultReturnFormat) {
327
+ return __awaiter(this, void 0, void 0, function* () {
328
+ return rpcMethodsWrappers.getBlockNumber(this, returnFormat);
329
+ });
330
+ }
331
+ /**
332
+ * Get the balance of an address at a given block.
333
+ *
334
+ * @param address The address to get the balance of.
335
+ * @param blockNumber ({@link BlockNumberOrTag} defaults to {@link Web3Eth.defaultBlock}) Specifies what block to use as the current state for the balance query.
336
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
337
+ * @returns The current balance for the given address in `wei`.
338
+ *
339
+ * ```ts
340
+ * web3.eth.getBalance("0x407d73d8a49eeb85d32cf465507dd71d507100c1").then(console.log);
341
+ * > 1000000000000n
342
+ *
343
+ * web3.eth.getBalance("0x407d73d8a49eeb85d32cf465507dd71d507100c1").then(console.log);
344
+ * > "0xe8d4a51000"
345
+ * ```
346
+ */
347
+ getBalance(address, blockNumber = this.defaultBlock, returnFormat = this.defaultReturnFormat) {
348
+ return __awaiter(this, void 0, void 0, function* () {
349
+ return rpcMethodsWrappers.getBalance(this, address, blockNumber, returnFormat);
350
+ });
351
+ }
352
+ /**
353
+ * Get the storage at a specific position of an address.
354
+ *
355
+ * @param address The address to get the storage from.
356
+ * @param storageSlot The index position of the storage.
357
+ * @param blockNumber ({@link BlockNumberOrTag} defaults to {@link Web3Eth.defaultBlock}) Specifies what block to use as the current state for the storage query.
358
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
359
+ * @returns The value in storage at the given position.
360
+ *
361
+ * ```ts
362
+ * web3.eth.getStorageAt("0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234", 0).then(console.log);
363
+ * > "0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234"
364
+ *
365
+ * web3.eth.getStorageAt(
366
+ * "0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234",
367
+ * 0,
368
+ * undefined,
369
+ * { number: FMT_NUMBER.HEX , bytes: FMT_BYTES.UINT8ARRAY }
370
+ * ).then(console.log);
371
+ * > Uint8Array(31) [
372
+ * 3, 52, 86, 115, 33, 35, 255, 255,
373
+ * 35, 66, 52, 45, 209, 35, 66, 67,
374
+ * 67, 36, 35, 66, 52, 253, 35, 79,
375
+ * 210, 63, 212, 242, 61, 66, 52
376
+ * ]
377
+ * ```
378
+ */
379
+ getStorageAt(address, storageSlot, blockNumber = this.defaultBlock, returnFormat = this.defaultReturnFormat) {
380
+ return __awaiter(this, void 0, void 0, function* () {
381
+ return rpcMethodsWrappers.getStorageAt(this, address, storageSlot, blockNumber, returnFormat);
382
+ });
383
+ }
384
+ /**
385
+ * Get the code at a specific address.
386
+ *
387
+ * @param address The address to get the code from.
388
+ * @param blockNumber ({@link BlockNumberOrTag} defaults to {@link Web3Eth.defaultBlock}) Specifies what block to use as the current state for the code query.
389
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
390
+ * @returns The [data](https://ethereum.org/en/developers/docs/transactions/#the-data-field) at the provided `address`.
391
+ *
392
+ * ```ts
393
+ * web3.eth.getCode("0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234").then(console.log);
394
+ * > "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"
395
+ *
396
+ * web3.eth.getCode(
397
+ * "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
398
+ * undefined,
399
+ * { number: FMT_NUMBER.HEX , bytes: FMT_BYTES.UINT8ARRAY }
400
+ * ).then(console.log);
401
+ * > Uint8Array(50) [
402
+ * 96, 1, 96, 0, 128, 53, 129, 26, 129, 129, 129,
403
+ * 20, 96, 18, 87, 131, 1, 0, 91, 96, 27, 96,
404
+ * 1, 53, 96, 37, 86, 91, 128, 96, 0, 82, 96,
405
+ * 32, 96, 0, 242, 91, 96, 0, 96, 7, 130, 2,
406
+ * 144, 80, 145, 144, 80, 86
407
+ * ]
408
+ * ```
409
+ */
410
+ getCode(address, blockNumber = this.defaultBlock, returnFormat = this.defaultReturnFormat) {
411
+ return __awaiter(this, void 0, void 0, function* () {
412
+ return rpcMethodsWrappers.getCode(this, address, blockNumber, returnFormat);
413
+ });
414
+ }
415
+ /**
416
+ * Retrieves a {@link Block} matching the provided block number, block hash or block tag.
417
+ *
418
+ * @param block The {@link BlockNumberOrTag} (defaults to {@link Web3Eth.defaultBlock}) or block hash of the desired block.
419
+ * @param hydrated If specified `true`, the returned block will contain all transactions as objects. If `false` it will only contain transaction hashes.
420
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted (does not format transaction objects or hashes).
421
+ * @returns A {@link Block} object matching the provided block number or block hash.
422
+ *
423
+ * ```ts
424
+ * web3.eth.getBlock(0).then(console.log);
425
+ * > {
426
+ * hash: '0x7dbfdc6a7a67a670cb9b0c3f81ca60c007762f1e4e598cb027a470678ff26d0d',
427
+ * parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
428
+ * sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
429
+ * miner: '0x0000000000000000000000000000000000000000',
430
+ * stateRoot: '0x5ed9882897d363c4632a6e67fba6203df61bd994813dcf048da59be442a9c6c4',
431
+ * transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
432
+ * receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
433
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
434
+ * difficulty: 1n,
435
+ * number: 0n,
436
+ * gasLimit: 30000000n,
437
+ * gasUsed: 0n,
438
+ * timestamp: 1658281638n,
439
+ * extraData: '0x',
440
+ * mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
441
+ * nonce: 0n,
442
+ * totalDifficulty: 1n,
443
+ * baseFeePerGas: 1000000000n,
444
+ * size: 514n,
445
+ * transactions: [],
446
+ * uncles: []
447
+ * }
448
+ *
449
+ * web3.eth.getBlock(
450
+ * "0x7dbfdc6a7a67a670cb9b0c3f81ca60c007762f1e4e598cb027a470678ff26d0d",
451
+ * false,
452
+ * { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
453
+ * ).then(console.log);
454
+ * > {
455
+ * hash: '0x7dbfdc6a7a67a670cb9b0c3f81ca60c007762f1e4e598cb027a470678ff26d0d',
456
+ * parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
457
+ * sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
458
+ * miner: '0x0000000000000000000000000000000000000000',
459
+ * stateRoot: '0x5ed9882897d363c4632a6e67fba6203df61bd994813dcf048da59be442a9c6c4',
460
+ * transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
461
+ * receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
462
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
463
+ * difficulty: 1,
464
+ * number: 0,
465
+ * gasLimit: 30000000,
466
+ * gasUsed: 0,
467
+ * timestamp: 1658281638,
468
+ * extraData: '0x',
469
+ * mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
470
+ * nonce: 0,
471
+ * totalDifficulty: 1,
472
+ * baseFeePerGas: 1000000000,
473
+ * size: 514,
474
+ * transactions: [],
475
+ * uncles: []
476
+ * }
477
+ * ```
478
+ */
479
+ getBlock(block = this.defaultBlock, hydrated = false, returnFormat = this.defaultReturnFormat) {
480
+ return __awaiter(this, void 0, void 0, function* () {
481
+ return rpcMethodsWrappers.getBlock(this, block, hydrated, returnFormat);
482
+ });
483
+ }
484
+ /**
485
+ * @param block The {@link BlockNumberOrTag} (defaults to {@link Web3Eth.defaultBlock}) or block hash of the desired block.
486
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
487
+ * @returns The number of transactions in the provided block.
488
+ *
489
+ * ```ts
490
+ * web3.eth.getBlockTransactionCount("0x407d73d8a49eeb85d32cf465507dd71d507100c1").then(console.log);
491
+ * > 1n
492
+ *
493
+ * web3.eth.getBlockTransactionCount(
494
+ * "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
495
+ * { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
496
+ * ).then(console.log);
497
+ * > 1
498
+ * ```
499
+ */
500
+ getBlockTransactionCount(block = this.defaultBlock, returnFormat = this.defaultReturnFormat) {
501
+ return __awaiter(this, void 0, void 0, function* () {
502
+ return rpcMethodsWrappers.getBlockTransactionCount(this, block, returnFormat);
503
+ });
504
+ }
505
+ /**
506
+ * @param block The {@link BlockNumberOrTag} (defaults to {@link Web3Eth.defaultBlock}) or block hash of the desired block.
507
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
508
+ * @returns The number of [uncles](https://ethereum.org/en/glossary/#ommer) in the provided block.
509
+ *
510
+ * ```ts
511
+ * web3.eth.getBlockUncleCount("0x407d73d8a49eeb85d32cf465507dd71d507100c1").then(console.log);
512
+ * > 1n
513
+ *
514
+ * web3.eth.getBlockUncleCount(
515
+ * "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
516
+ * { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
517
+ * ).then(console.log);
518
+ * > 1
519
+ * ```
520
+ */
521
+ getBlockUncleCount(block = this.defaultBlock, returnFormat = this.defaultReturnFormat) {
522
+ return __awaiter(this, void 0, void 0, function* () {
523
+ return rpcMethodsWrappers.getBlockUncleCount(this, block, returnFormat);
524
+ });
525
+ }
526
+ /**
527
+ *
528
+ * @param block The {@link BlockNumberOrTag} (defaults to {@link Web3Eth.defaultBlock}) or block hash of the desired block.
529
+ * @param uncleIndex The index position of the uncle.
530
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
531
+ * @returns A blocks [uncle](https://ethereum.org/en/glossary/#ommer) by a given uncle index position.
532
+ *
533
+ * ```ts
534
+ * web3.eth.getUncle(0, 1).then(console.log);
535
+ * > {
536
+ * hash: '0x7dbfdc6a7a67a670cb9b0c3f81ca60c007762f1e4e598cb027a470678ff26d0d',
537
+ * parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
538
+ * sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
539
+ * miner: '0x0000000000000000000000000000000000000000',
540
+ * stateRoot: '0x5ed9882897d363c4632a6e67fba6203df61bd994813dcf048da59be442a9c6c4',
541
+ * transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
542
+ * receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
543
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
544
+ * difficulty: 1n,
545
+ * number: 0n,
546
+ * gasLimit: 30000000n,
547
+ * gasUsed: 0n,
548
+ * timestamp: 1658281638n,
549
+ * extraData: '0x',
550
+ * mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
551
+ * nonce: 0n,
552
+ * totalDifficulty: 1n,
553
+ * baseFeePerGas: 1000000000n,
554
+ * size: 514n,
555
+ * transactions: [],
556
+ * uncles: []
557
+ * }
558
+ *
559
+ * web3.eth.getUncle(
560
+ * "0x7dbfdc6a7a67a670cb9b0c3f81ca60c007762f1e4e598cb027a470678ff26d0d",
561
+ * 1,
562
+ * { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
563
+ * ).then(console.log);
564
+ * > {
565
+ * hash: '0x7dbfdc6a7a67a670cb9b0c3f81ca60c007762f1e4e598cb027a470678ff26d0d',
566
+ * parentHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
567
+ * sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
568
+ * miner: '0x0000000000000000000000000000000000000000',
569
+ * stateRoot: '0x5ed9882897d363c4632a6e67fba6203df61bd994813dcf048da59be442a9c6c4',
570
+ * transactionsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
571
+ * receiptsRoot: '0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421',
572
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
573
+ * difficulty: 1,
574
+ * number: 0,
575
+ * gasLimit: 30000000,
576
+ * gasUsed: 0,
577
+ * timestamp: 1658281638,
578
+ * extraData: '0x',
579
+ * mixHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
580
+ * nonce: 0,
581
+ * totalDifficulty: 1,
582
+ * baseFeePerGas: 1000000000,
583
+ * size: 514,
584
+ * transactions: [],
585
+ * uncles: []
586
+ * }
587
+ * ```
588
+ */
589
+ getUncle(block = this.defaultBlock, uncleIndex, returnFormat = this.defaultReturnFormat) {
590
+ return __awaiter(this, void 0, void 0, function* () {
591
+ return rpcMethodsWrappers.getUncle(this, block, uncleIndex, returnFormat);
592
+ });
593
+ }
594
+ /**
595
+ * @param transactionHash The hash of the desired transaction.
596
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
597
+ * @returns The desired transaction object.
598
+ *
599
+ * ```ts
600
+ * web3.eth.getTransaction('0x73aea70e969941f23f9d24103e91aa1f55c7964eb13daf1c9360c308a72686dc').then(console.log);
601
+ * {
602
+ * hash: '0x73aea70e969941f23f9d24103e91aa1f55c7964eb13daf1c9360c308a72686dc',
603
+ * type: 0n,
604
+ * nonce: 0n,
605
+ * blockHash: '0x43202bd16b6bd54bea1b310736bd78bdbe93a64ad940f7586739d9eb25ad8d00',
606
+ * blockNumber: 1n,
607
+ * transactionIndex: 0n,
608
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
609
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
610
+ * value: 1n,
611
+ * gas: 90000n,
612
+ * gasPrice: 2000000000n,
613
+ * input: '0x',
614
+ * v: 2709n,
615
+ * r: '0x8b336c290f6d7b2af3ccb2c02203a8356cc7d5b150ab19cce549d55636a3a78c',
616
+ * s: '0x5a83c6f816befc5cd4b0c997a347224a8aa002e5799c4b082a3ec726d0e9531d'
617
+ * }
618
+ *
619
+ * web3.eth.getTransaction(
620
+ * web3.utils.hexToBytes("0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400"),
621
+ * { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
622
+ * ).then(console.log);
623
+ * {
624
+ * hash: '0x73aea70e969941f23f9d24103e91aa1f55c7964eb13daf1c9360c308a72686dc',
625
+ * type: 0,
626
+ * nonce: 0,
627
+ * blockHash: '0x43202bd16b6bd54bea1b310736bd78bdbe93a64ad940f7586739d9eb25ad8d00',
628
+ * blockNumber: 1,
629
+ * transactionIndex: 0,
630
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
631
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
632
+ * value: 1,
633
+ * gas: 90000,
634
+ * gasPrice: 2000000000,
635
+ * input: '0x',
636
+ * v: 2709,
637
+ * r: '0x8b336c290f6d7b2af3ccb2c02203a8356cc7d5b150ab19cce549d55636a3a78c',
638
+ * s: '0x5a83c6f816befc5cd4b0c997a347224a8aa002e5799c4b082a3ec726d0e9531d'
639
+ * }
640
+ * ```
641
+ */
642
+ getTransaction(transactionHash, returnFormat = this.defaultReturnFormat) {
643
+ return __awaiter(this, void 0, void 0, function* () {
644
+ const response = yield rpcMethodsWrappers.getTransaction(this, transactionHash, returnFormat);
645
+ if (!response)
646
+ throw new TransactionNotFound();
647
+ return response;
648
+ });
649
+ }
650
+ /**
651
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
652
+ * @returns A list of pending transactions.
653
+ *
654
+ * ```ts
655
+ * web3.eth.getPendingTransactions().then(console.log);
656
+ * > [
657
+ * {
658
+ * hash: '0x73aea70e969941f23f9d24103e91aa1f55c7964eb13daf1c9360c308a72686dc',
659
+ * type: 0n,
660
+ * nonce: 0n,
661
+ * blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
662
+ * blockNumber: null,
663
+ * transactionIndex: 0n,
664
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
665
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
666
+ * value: 1n,
667
+ * gas: 90000n,
668
+ * gasPrice: 2000000000n,
669
+ * input: '0x',
670
+ * v: 2709n,
671
+ * r: '0x8b336c290f6d7b2af3ccb2c02203a8356cc7d5b150ab19cce549d55636a3a78c',
672
+ * s: '0x5a83c6f816befc5cd4b0c997a347224a8aa002e5799c4b082a3ec726d0e9531d'
673
+ * },
674
+ * {
675
+ * hash: '0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f',
676
+ * type: 0n,
677
+ * nonce: 1n,
678
+ * blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
679
+ * blockNumber: null,
680
+ * transactionIndex: 0n,
681
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
682
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
683
+ * value: 1n,
684
+ * gas: 90000n,
685
+ * gasPrice: 2000000000n,
686
+ * input: '0x',
687
+ * v: 2710n,
688
+ * r: '0x55ac19fade21db035a1b7ea0a8d49e265e05dbb926e75f273f836ad67ce5c96a',
689
+ * s: '0x6550036a7c3fd426d5c3d35d96a7075cd673957620b7889846a980d2d017ec08'
690
+ * }
691
+ * ]
692
+ *
693
+ * * web3.eth.getPendingTransactions({ number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }).then(console.log);
694
+ * > [
695
+ * {
696
+ * hash: '0x73aea70e969941f23f9d24103e91aa1f55c7964eb13daf1c9360c308a72686dc',
697
+ * type: 0,
698
+ * nonce: 0,
699
+ * blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
700
+ * blockNumber: null,
701
+ * transactionIndex: 0,
702
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
703
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
704
+ * value: 1,
705
+ * gas: 90000,
706
+ * gasPrice: 2000000000,
707
+ * input: '0x',
708
+ * v: 2709,
709
+ * r: '0x8b336c290f6d7b2af3ccb2c02203a8356cc7d5b150ab19cce549d55636a3a78c',
710
+ * s: '0x5a83c6f816befc5cd4b0c997a347224a8aa002e5799c4b082a3ec726d0e9531d'
711
+ * },
712
+ * {
713
+ * hash: '0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f',
714
+ * type: 0,
715
+ * nonce: 1,
716
+ * blockHash: '0x0000000000000000000000000000000000000000000000000000000000000000',
717
+ * blockNumber: null,
718
+ * transactionIndex: 0,
719
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
720
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
721
+ * value: 1,
722
+ * gas: 90000,
723
+ * gasPrice: 2000000000,
724
+ * input: '0x',
725
+ * v: 2710,
726
+ * r: '0x55ac19fade21db035a1b7ea0a8d49e265e05dbb926e75f273f836ad67ce5c96a',
727
+ * s: '0x6550036a7c3fd426d5c3d35d96a7075cd673957620b7889846a980d2d017ec08'
728
+ * }
729
+ * ]
730
+ * ```
731
+ */
732
+ getPendingTransactions(returnFormat = this.defaultReturnFormat) {
733
+ return __awaiter(this, void 0, void 0, function* () {
734
+ return rpcMethodsWrappers.getPendingTransactions(this, returnFormat);
735
+ });
736
+ }
737
+ /**
738
+ * @param block The {@link BlockNumberOrTag} (defaults to {@link Web3Eth.defaultBlock}) or block hash of the desired block.
739
+ * @param transactionIndex The index position of the transaction.
740
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
741
+ * @returns The desired transaction object.
742
+ *
743
+ * ```ts
744
+ * web3.eth.getTransactionFromBlock('0x43202bd16b6bd54bea1b310736bd78bdbe93a64ad940f7586739d9eb25ad8d00', 0).then(console.log);
745
+ * {
746
+ * hash: '0x73aea70e969941f23f9d24103e91aa1f55c7964eb13daf1c9360c308a72686dc',
747
+ * type: 0n,
748
+ * nonce: 0n,
749
+ * blockHash: '0x43202bd16b6bd54bea1b310736bd78bdbe93a64ad940f7586739d9eb25ad8d00',
750
+ * blockNumber: 1n,
751
+ * transactionIndex: 0n,
752
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
753
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
754
+ * value: 1n,
755
+ * gas: 90000n,
756
+ * gasPrice: 2000000000n,
757
+ * input: '0x',
758
+ * v: 2709n,
759
+ * r: '0x8b336c290f6d7b2af3ccb2c02203a8356cc7d5b150ab19cce549d55636a3a78c',
760
+ * s: '0x5a83c6f816befc5cd4b0c997a347224a8aa002e5799c4b082a3ec726d0e9531d'
761
+ * }
762
+ *
763
+ * web3.eth.getTransactionFromBlock(
764
+ * hexToBytes("0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400"),
765
+ * 0,
766
+ * { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
767
+ * ).then(console.log);
768
+ * {
769
+ * hash: '0x73aea70e969941f23f9d24103e91aa1f55c7964eb13daf1c9360c308a72686dc',
770
+ * type: 0,
771
+ * nonce: 0,
772
+ * blockHash: '0x43202bd16b6bd54bea1b310736bd78bdbe93a64ad940f7586739d9eb25ad8d00',
773
+ * blockNumber: 1,
774
+ * transactionIndex: 0,
775
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
776
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
777
+ * value: 1,
778
+ * gas: 90000,
779
+ * gasPrice: 2000000000,
780
+ * input: '0x',
781
+ * v: 2709,
782
+ * r: '0x8b336c290f6d7b2af3ccb2c02203a8356cc7d5b150ab19cce549d55636a3a78c',
783
+ * s: '0x5a83c6f816befc5cd4b0c997a347224a8aa002e5799c4b082a3ec726d0e9531d'
784
+ * }
785
+ * ```
786
+ */
787
+ getTransactionFromBlock(block = this.defaultBlock, transactionIndex, returnFormat = this.defaultReturnFormat) {
788
+ return __awaiter(this, void 0, void 0, function* () {
789
+ return rpcMethodsWrappers.getTransactionFromBlock(this, block, transactionIndex, returnFormat);
790
+ });
791
+ }
792
+ /**
793
+ * @param transactionHash Hash of the transaction to retrieve the receipt for.
794
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
795
+ * @returns The desired {@link TransactionReceipt} object.
796
+ *
797
+ * ```ts
798
+ * web3.eth.getTransactionReceipt("0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f").then(console.log);
799
+ * > {
800
+ * transactionHash: '0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f',
801
+ * transactionIndex: 0n,
802
+ * blockNumber: 2n,
803
+ * blockHash: '0xeb1565a08b23429552dafa92e32409f42eb43944f7611963c63ce40e7243941a',
804
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
805
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
806
+ * cumulativeGasUsed: 21000n,
807
+ * gasUsed: 21000n,
808
+ * logs: [],
809
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
810
+ * status: 1n,
811
+ * effectiveGasPrice: 2000000000n,
812
+ * type: 0n
813
+ * }
814
+ *
815
+ * web3.eth.getTransactionReceipt(
816
+ * "0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f",
817
+ * { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
818
+ * ).then(console.log);
819
+ * > {
820
+ * transactionHash: '0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f',
821
+ * transactionIndex: 0,
822
+ * blockNumber: 2,
823
+ * blockHash: '0xeb1565a08b23429552dafa92e32409f42eb43944f7611963c63ce40e7243941a',
824
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
825
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
826
+ * cumulativeGasUsed: 21000,
827
+ * gasUsed: 21000,
828
+ * logs: [],
829
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
830
+ * status: 1,
831
+ * effectiveGasPrice: 2000000000,
832
+ * type: 0n
833
+ * }
834
+ * ```
835
+ */
836
+ getTransactionReceipt(transactionHash, returnFormat = this.defaultReturnFormat) {
837
+ return __awaiter(this, void 0, void 0, function* () {
838
+ const response = yield rpcMethodsWrappers.getTransactionReceipt(this, transactionHash, returnFormat);
839
+ if (!response)
840
+ throw new TransactionNotFound();
841
+ return response;
842
+ });
843
+ }
844
+ /**
845
+ * @param address The address to get the number of transactions for.
846
+ * @param blockNumber ({@link BlockNumberOrTag} defaults to {@link Web3Eth.defaultBlock}) Specifies what block to use as the current state for the query.
847
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
848
+ * @returns The number of transactions sent from the provided address.
849
+ *
850
+ * ```ts
851
+ * web3.eth.getTransactionCount("0x407d73d8a49eeb85d32cf465507dd71d507100c1").then(console.log);
852
+ * > 1n
853
+ *
854
+ * web3.eth.getTransactionCount(
855
+ * "0x407d73d8a49eeb85d32cf465507dd71d507100c1",
856
+ * undefined,
857
+ * { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
858
+ * ).then(console.log);
859
+ * > 1
860
+ * ```
861
+ */
862
+ getTransactionCount(address, blockNumber = this.defaultBlock, returnFormat = this.defaultReturnFormat) {
863
+ return __awaiter(this, void 0, void 0, function* () {
864
+ return rpcMethodsWrappers.getTransactionCount(this, address, blockNumber, returnFormat);
865
+ });
866
+ }
867
+ /**
868
+ * @param transaction The {@link Transaction}, {@link TransactionWithFromLocalWalletIndex}, {@link TransactionWithToLocalWalletIndex} or {@link TransactionWithFromAndToLocalWalletIndex} to send. __Note:__ In the `to` and `from` fields when hex strings are used, it is assumed they are addresses, for any other form (number, string number, etc.) it is assumed they are wallet indexes.
869
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
870
+ * @param options A configuration object used to change the behavior of the `sendTransaction` method.
871
+ * @returns If `await`ed or `.then`d (i.e. the promise resolves), the transaction hash is returned.
872
+ * ```ts
873
+ * const transaction = {
874
+ * from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4',
875
+ * to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C',
876
+ * value: '0x1'
877
+ * }
878
+ *
879
+ * const transactionHash = await web3.eth.sendTransaction(transaction);
880
+ * console.log(transactionHash);
881
+ * > 0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f
882
+ *
883
+ * web3.eth.sendTransaction(transaction).then(console.log);
884
+ * > 0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f
885
+ *
886
+ * web3.eth.sendTransaction(transaction).catch(console.log);
887
+ * > <Some TransactionError>
888
+ *
889
+ * // Example using options.ignoreGasPricing = true
890
+ * web3.eth.sendTransaction(transaction, undefined, { ignoreGasPricing: true }).then(console.log);
891
+ * > 0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f
892
+ * ```
893
+ *
894
+ *
895
+ * Otherwise, a {@link Web3PromiEvent} is returned which has several events than can be listened to using the `.on` syntax, such as:
896
+ * - `sending`
897
+ * ```ts
898
+ * web3.eth.sendTransaction(transaction).on('sending', transactionToBeSent => console.log(transactionToBeSent));
899
+ * > {
900
+ * from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4',
901
+ * to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C',
902
+ * value: '0x1',
903
+ * gasPrice: '0x77359400',
904
+ * maxPriorityFeePerGas: undefined,
905
+ * maxFeePerGas: undefined
906
+ * }
907
+ * ```
908
+ * - `sent`
909
+ * ```ts
910
+ * web3.eth.sendTransaction(transaction).on('sent', sentTransaction => console.log(sentTransaction));
911
+ * > {
912
+ * from: '0x6E599DA0bfF7A6598AC1224E4985430Bf16458a4',
913
+ * to: '0x6f1DF96865D09d21e8f3f9a7fbA3b17A11c7C53C',
914
+ * value: '0x1',
915
+ * gasPrice: '0x77359400',
916
+ * maxPriorityFeePerGas: undefined,
917
+ * maxFeePerGas: undefined
918
+ * }
919
+ * ```
920
+ * - `transactionHash`
921
+ * ```ts
922
+ * web3.eth.sendTransaction(transaction).on('transactionHash', transactionHash => console.log(transactionHash));
923
+ * > 0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f
924
+ * ```
925
+ * - `receipt`
926
+ * ```ts
927
+ * web3.eth.sendTransaction(transaction).on('receipt', receipt => console.log(receipt));
928
+ * > {
929
+ * transactionHash: '0xdf7756865c2056ce34c4eabe4eff42ad251a9f920a1c620c00b4ea0988731d3f',
930
+ * transactionIndex: 0n,
931
+ * blockNumber: 2n,
932
+ * blockHash: '0xeb1565a08b23429552dafa92e32409f42eb43944f7611963c63ce40e7243941a',
933
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
934
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
935
+ * cumulativeGasUsed: 21000n,
936
+ * gasUsed: 21000n,
937
+ * logs: [],
938
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
939
+ * status: 1n,
940
+ * effectiveGasPrice: 2000000000n,
941
+ * type: 0n
942
+ * }
943
+ * ```
944
+ * - `confirmation`
945
+ * ```ts
946
+ * web3.eth.sendTransaction(transaction).on('confirmation', confirmation => console.log(confirmation));
947
+ * > {
948
+ * confirmations: 1n,
949
+ * receipt: {
950
+ * transactionHash: '0xb4a3a35ae0f3e77ef0ff7be42010d948d011b21a4e341072ee18717b67e99ab8',
951
+ * transactionIndex: 0n,
952
+ * blockNumber: 5n,
953
+ * blockHash: '0xb57fbe6f145cefd86a305a9a024a4351d15d4d39607d7af53d69a319bc3b5548',
954
+ * from: '0x6e599da0bff7a6598ac1224e4985430bf16458a4',
955
+ * to: '0x6f1df96865d09d21e8f3f9a7fba3b17a11c7c53c',
956
+ * cumulativeGasUsed: 21000n,
957
+ * gasUsed: 21000n,
958
+ * logs: [],
959
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
960
+ * status: 1n,
961
+ * effectiveGasPrice: 2000000000n,
962
+ * type: 0n
963
+ * },
964
+ * latestBlockHash: '0xb57fbe6f145cefd86a305a9a024a4351d15d4d39607d7af53d69a319bc3b5548'
965
+ * }
966
+ * ```
967
+ * - `error`
968
+ * ```ts
969
+ * web3.eth.sendTransaction(transaction).on('error', error => console.log);
970
+ * > <Some TransactionError>
971
+ * ```
972
+ */
973
+ sendTransaction(transaction, returnFormat = this.defaultReturnFormat, options) {
974
+ return rpcMethodsWrappers.sendTransaction(this, transaction, returnFormat, options, this.transactionMiddleware);
975
+ }
976
+ /**
977
+ * @param transaction Signed transaction in one of the valid {@link Bytes} format.
978
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
979
+ * @param options A configuration object used to change the behavior of the method
980
+ * @returns If `await`ed or `.then`d (i.e. the promise resolves), the transaction hash is returned.
981
+ * ```ts
982
+ * const signedTransaction = "0xf86580843b9aca0182520894e899f0130fd099c0b896b2ce4e5e15a25b23139a0180820a95a03a42d53ca5b71f845e1cd4c65359b05446a85d16881372d3bfaab8980935cb04a0711497bc8dd3b541152e2fed14fe650a647f1f0edab0d386ad9506f0e642410f"
983
+ *
984
+ * const transactionHash = await web3.eth.sendSignedTransaction(signedTransaction);
985
+ * console.log(transactionHash);
986
+ * > 0xed8c241ea44d57f4605dc22c63500de46254d6c7844fd65fa438b128c80cf700
987
+ *
988
+ * web3.eth.sendSignedTransaction(signedTransaction).then(console.log);
989
+ * > 0xed8c241ea44d57f4605dc22c63500de46254d6c7844fd65fa438b128c80cf700
990
+ *
991
+ * web3.eth.sendSignedTransaction(signedTransaction).catch(console.log);
992
+ * > <Some TransactionError>
993
+ * ```
994
+ *
995
+ *
996
+ * Otherwise, a {@link Web3PromiEvent} is returned which has several events than can be listened to using the `.on` syntax, such as:
997
+ * - `sending`
998
+ * ```ts
999
+ * web3.eth.sendSignedTransaction(signedTransaction).on('sending', transactionToBeSent => console.log(transactionToBeSent));
1000
+ * > "0xf86580843b9aca0182520894e899f0130fd099c0b896b2ce4e5e15a25b23139a0180820a95a03a42d53ca5b71f845e1cd4c65359b05446a85d16881372d3bfaab8980935cb04a0711497bc8dd3b541152e2fed14fe650a647f1f0edab0d386ad9506f0e642410f"
1001
+ * ```
1002
+ * - `sent`
1003
+ * ```ts
1004
+ * web3.eth.sendSignedTransaction(signedTransaction).on('sent', sentTransaction => console.log(sentTransaction));
1005
+ * > "0xf86580843b9aca0182520894e899f0130fd099c0b896b2ce4e5e15a25b23139a0180820a95a03a42d53ca5b71f845e1cd4c65359b05446a85d16881372d3bfaab8980935cb04a0711497bc8dd3b541152e2fed14fe650a647f1f0edab0d386ad9506f0e642410f"
1006
+ * ```
1007
+ * - `transactionHash`
1008
+ * ```ts
1009
+ * web3.eth.sendSignedTransaction(signedTransaction).on('transactionHash', transactionHash => console.log(transactionHash));
1010
+ * > 0xed8c241ea44d57f4605dc22c63500de46254d6c7844fd65fa438b128c80cf700
1011
+ * ```
1012
+ * - `receipt`
1013
+ * ```ts
1014
+ * web3.eth.sendSignedTransaction(signedTransaction).on('receipt', receipt => console.log(receipt));
1015
+ * > {
1016
+ * blockHash: '0xff2b1687995d81066361bc6affe4455746120a7d4bb75fc938211a2692a50081',
1017
+ * blockNumber: 1n,
1018
+ * cumulativeGasUsed: 21000n,
1019
+ * effectiveGasPrice: 1000000001n,
1020
+ * from: '0xe899f0130fd099c0b896b2ce4e5e15a25b23139a',
1021
+ * gasUsed: 21000n,
1022
+ * logs: [],
1023
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
1024
+ * status: 1n,
1025
+ * to: '0xe899f0130fd099c0b896b2ce4e5e15a25b23139a',
1026
+ * transactionHash: '0xed8c241ea44d57f4605dc22c63500de46254d6c7844fd65fa438b128c80cf700',
1027
+ * transactionIndex: 0n,
1028
+ * type: 0n
1029
+ * }
1030
+ * ```
1031
+ * - `confirmation`
1032
+ * ```ts
1033
+ * web3.eth.sendSignedTransaction(signedTransaction).on('confirmation', confirmation => console.log(confirmation));
1034
+ * > {
1035
+ * confirmations: 1n,
1036
+ * receipt: {
1037
+ * blockHash: '0xff2b1687995d81066361bc6affe4455746120a7d4bb75fc938211a2692a50081',
1038
+ * blockNumber: 1n,
1039
+ * cumulativeGasUsed: 21000n,
1040
+ * effectiveGasPrice: 1000000001n,
1041
+ * from: '0xe899f0130fd099c0b896b2ce4e5e15a25b23139a',
1042
+ * gasUsed: 21000n,
1043
+ * logs: [],
1044
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
1045
+ * status: 1n,
1046
+ * to: '0xe899f0130fd099c0b896b2ce4e5e15a25b23139a',
1047
+ * transactionHash: '0xed8c241ea44d57f4605dc22c63500de46254d6c7844fd65fa438b128c80cf700',
1048
+ * transactionIndex: 0n,
1049
+ * type: 0n
1050
+ * },
1051
+ * latestBlockHash: '0xff2b1687995d81066361bc6affe4455746120a7d4bb75fc938211a2692a50081'
1052
+ * }
1053
+ * ```
1054
+ * - `error`
1055
+ * ```ts
1056
+ * web3.eth.sendSignedTransaction(signedTransaction).on('error', error => console.log(error));
1057
+ * > <Some TransactionError>
1058
+ * ```
1059
+ */
1060
+ sendSignedTransaction(transaction, returnFormat = this.defaultReturnFormat, options) {
1061
+ return rpcMethodsWrappers.sendSignedTransaction(this, transaction, returnFormat, options);
1062
+ }
1063
+ /**
1064
+ * @param message Data to sign in one of the valid {@link Bytes} format.
1065
+ * @param address Address to sign data with, can be an address or the index of a local wallet.
1066
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
1067
+ * @returns The signed `message`.
1068
+ *
1069
+ * ```ts
1070
+ * // Using an unlocked account managed by connected RPC client
1071
+ * web3.eth.sign("0x48656c6c6f20776f726c64", "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe").then(console.log);
1072
+ * > "0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400"
1073
+ *
1074
+ * // Using an unlocked account managed by connected RPC client
1075
+ * web3.eth.sign("0x48656c6c6f20776f726c64", "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.UINT8ARRAY }).then(console.log);
1076
+ * > Uint8Array(65) [
1077
+ * 48, 117, 94, 214, 83, 150, 250, 207, 134, 197, 62,
1078
+ * 98, 23, 197, 43, 77, 174, 190, 114, 170, 73, 65,
1079
+ * 216, 150, 53, 64, 157, 228, 201, 199, 249, 70, 109,
1080
+ * 78, 154, 174, 199, 151, 127, 5, 233, 35, 136, 155,
1081
+ * 51, 192, 208, 221, 39, 215, 34, 107, 110, 111, 86,
1082
+ * 206, 115, 116, 101, 197, 207, 208, 75, 228, 0
1083
+ * ]
1084
+ * ```
1085
+ *
1086
+ * // Using an indexed account managed by local Web3 wallet
1087
+ * web3.eth.sign("0x48656c6c6f20776f726c64", 0).then(console.log);
1088
+ * > "0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400"
1089
+ */
1090
+ sign(message, addressOrIndex, returnFormat = this.defaultReturnFormat) {
1091
+ return __awaiter(this, void 0, void 0, function* () {
1092
+ return rpcMethodsWrappers.sign(this, message, addressOrIndex, returnFormat);
1093
+ });
1094
+ }
1095
+ /**
1096
+ * @param transaction The transaction object to sign.
1097
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) Specifies how the return data should be formatted.
1098
+ * @returns {@link SignedTransactionInfoAPI}, an object containing the [RLP](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/#top) encoded signed transaction (accessed via the `raw` property) and the signed transaction object (accessed via the `tx` property).
1099
+ *
1100
+ * ```ts
1101
+ * const transaction = {
1102
+ * from: '0xe899f0130FD099c0b896B2cE4E5E15A25b23139a',
1103
+ * to: '0xe899f0130FD099c0b896B2cE4E5E15A25b23139a',
1104
+ * value: '0x1',
1105
+ * gas: '21000',
1106
+ * gasPrice: await web3Eth.getGasPrice(),
1107
+ * nonce: '0x1',
1108
+ * type: '0x0'
1109
+ * }
1110
+ *
1111
+ * web3.eth.signTransaction(transaction).then(console.log);
1112
+ * > {
1113
+ * raw: '0xf86501843b9aca0182520894e899f0130fd099c0b896b2ce4e5e15a25b23139a0180820a96a0adb3468dbb4dce89fe1785ea9182e85fb56b399b378f82b93af7a8a12a4f9679a027d37d736e9bcf00121f78b2d10e4404fa5c45856d62b746574345f5cd278097',
1114
+ * tx: {
1115
+ * type: 0n,
1116
+ * nonce: 1n,
1117
+ * gasPrice: 1000000001n,
1118
+ * gas: 21000n,
1119
+ * value: 1n,
1120
+ * v: 2710n,
1121
+ * r: '0xadb3468dbb4dce89fe1785ea9182e85fb56b399b378f82b93af7a8a12a4f9679',
1122
+ * s: '0x27d37d736e9bcf00121f78b2d10e4404fa5c45856d62b746574345f5cd278097',
1123
+ * to: '0xe899f0130fd099c0b896b2ce4e5e15a25b23139a',
1124
+ * data: '0x'
1125
+ * }
1126
+ * }
1127
+ *
1128
+ * web3.eth.signTransaction(transaction, { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }).then(console.log);
1129
+ * > {
1130
+ * raw: '0xf86501843b9aca0182520894e899f0130fd099c0b896b2ce4e5e15a25b23139a0180820a96a0adb3468dbb4dce89fe1785ea9182e85fb56b399b378f82b93af7a8a12a4f9679a027d37d736e9bcf00121f78b2d10e4404fa5c45856d62b746574345f5cd278097',
1131
+ * tx: {
1132
+ * type: 0,
1133
+ * nonce: 1,
1134
+ * gasPrice: 1000000001,
1135
+ * gas: 21000,
1136
+ * value: 1,
1137
+ * v: 2710,
1138
+ * r: '0xadb3468dbb4dce89fe1785ea9182e85fb56b399b378f82b93af7a8a12a4f9679',
1139
+ * s: '0x27d37d736e9bcf00121f78b2d10e4404fa5c45856d62b746574345f5cd278097',
1140
+ * to: '0xe899f0130fd099c0b896b2ce4e5e15a25b23139a',
1141
+ * data: '0x'
1142
+ * }
1143
+ * }
1144
+ * ```
1145
+ */
1146
+ signTransaction(transaction, returnFormat = this.defaultReturnFormat) {
1147
+ return __awaiter(this, void 0, void 0, function* () {
1148
+ return rpcMethodsWrappers.signTransaction(this, transaction, returnFormat);
1149
+ });
1150
+ }
1151
+ // TODO Decide what to do with transaction.to
1152
+ // https://github.com/ChainSafe/web3.js/pull/4525#issuecomment-982330076
1153
+ /**
1154
+ * Executes a message call within the EVM without creating a transaction.
1155
+ * It does not publish anything to the blockchain and does not consume any gas.
1156
+ *
1157
+ * @param transaction - A transaction object where all properties are optional except `to`, however it's recommended to include the `from` property or it may default to `0x0000000000000000000000000000000000000000` depending on your node or provider.
1158
+ * @param blockNumber ({@link BlockNumberOrTag} defaults to {@link Web3Eth.defaultBlock}) - Specifies what block to use as the current state of the blockchain while processing the transaction.
1159
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) - Specifies how the return data from the call should be formatted.
1160
+ * @returns The returned data of the call, e.g. a smart contract function's return value.
1161
+ */
1162
+ call(transaction, blockNumber = this.defaultBlock, returnFormat = this.defaultReturnFormat) {
1163
+ return __awaiter(this, void 0, void 0, function* () {
1164
+ return rpcMethodsWrappers.call(this, transaction, blockNumber, returnFormat);
1165
+ });
1166
+ }
1167
+ /**
1168
+ * Simulates the transaction within the EVM to estimate the amount of gas to be used by the transaction.
1169
+ * The transaction will not be added to the blockchain, and actual gas usage can vary when interacting
1170
+ * with a contract as a result of updating the contract's state.
1171
+ *
1172
+ * @param transaction The {@link Transaction} object to estimate the gas for.
1173
+ * @param blockNumber ({@link BlockNumberOrTag} defaults to {@link Web3Eth.defaultBlock}) - Specifies what block to use as the current state of the blockchain while processing the gas estimation.
1174
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) - Specifies how the return data from the call should be formatted.
1175
+ * @returns The used gas for the simulated transaction execution.
1176
+ *
1177
+ * ```ts
1178
+ * const transaction = {
1179
+ * from: '0xe899f0130FD099c0b896B2cE4E5E15A25b23139a',
1180
+ * to: '0xe899f0130FD099c0b896B2cE4E5E15A25b23139a',
1181
+ * value: '0x1',
1182
+ * nonce: '0x1',
1183
+ * type: '0x0'
1184
+ * }
1185
+ *
1186
+ * web3.eth.estimateGas(transaction).then(console.log);
1187
+ * > 21000n
1188
+ *
1189
+ * web3.eth.estimateGas(transaction, { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }).then(console.log);
1190
+ * > 21000
1191
+ * ```
1192
+ */
1193
+ estimateGas(transaction, blockNumber = this.defaultBlock, returnFormat = this.defaultReturnFormat) {
1194
+ return __awaiter(this, void 0, void 0, function* () {
1195
+ return rpcMethodsWrappers.estimateGas(this, transaction, blockNumber, returnFormat);
1196
+ });
1197
+ }
1198
+ /**
1199
+ * Gets past logs, matching the provided `filter`.
1200
+ *
1201
+ * @param filter A {@link Filter} object containing the properties for the desired logs.
1202
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) - Specifies how the return data from the call should be formatted.
1203
+ * @returns {@link FilterResultsAPI}, an array of {@link Log} objects.
1204
+ *
1205
+ * ```ts
1206
+ * web3.eth.getPastLogs({
1207
+ * address: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe",
1208
+ * topics: ["0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234"]
1209
+ * }).then(console.log);
1210
+ * > [{
1211
+ * data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
1212
+ * topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
1213
+ * logIndex: 0n,
1214
+ * transactionIndex: 0n,
1215
+ * transactionHash: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
1216
+ * blockHash: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
1217
+ * blockNumber: 1234n,
1218
+ * address: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'
1219
+ * },
1220
+ * {...}]
1221
+ *
1222
+ * web3.eth.getPastLogs(
1223
+ * {
1224
+ * address: "0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe",
1225
+ * topics: ["0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234"]
1226
+ * },
1227
+ * { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
1228
+ * ).then(console.log);
1229
+ * > [{
1230
+ * data: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
1231
+ * topics: ['0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7', '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385']
1232
+ * logIndex: 0,
1233
+ * transactionIndex: 0,
1234
+ * transactionHash: '0x7f9fade1c0d57a7af66ab4ead79fade1c0d57a7af66ab4ead7c2c2eb7b11a91385',
1235
+ * blockHash: '0xfd43ade1c09fade1c0d57a7af66ab4ead7c2c2eb7b11a91ffdd57a7af66ab4ead7',
1236
+ * blockNumber: 1234,
1237
+ * address: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'
1238
+ * },
1239
+ * {...}]
1240
+ * ```
1241
+ */
1242
+ getPastLogs(filter, returnFormat = this.defaultReturnFormat) {
1243
+ return __awaiter(this, void 0, void 0, function* () {
1244
+ return rpcMethodsWrappers.getLogs(this, filter, returnFormat);
1245
+ });
1246
+ }
1247
+ /**
1248
+ * Gets work for miners to mine on. Returns the hash of the current block, the seedHash, and the boundary condition to be met ('target').
1249
+ *
1250
+ * @returns The mining work as an array of strings with the following structure:
1251
+ *
1252
+ * String 32 Bytes - at index 0: current block header pow-hash
1253
+ * String 32 Bytes - at index 1: the seed hash used for the DAG.
1254
+ * String 32 Bytes - at index 2: the boundary condition ('target'), 2^256 / difficulty.
1255
+ *
1256
+ * ```ts
1257
+ * web3.eth.getWork().then(console.log);
1258
+ * > [
1259
+ * "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
1260
+ * "0x5EED00000000000000000000000000005EED0000000000000000000000000000",
1261
+ * "0xd1ff1c01710000000000000000000000d1ff1c01710000000000000000000000"
1262
+ * ]
1263
+ * ```
1264
+ */
1265
+ getWork() {
1266
+ return __awaiter(this, void 0, void 0, function* () {
1267
+ return ethRpcMethods.getWork(this.requestManager);
1268
+ });
1269
+ }
1270
+ /**
1271
+ * Used for submitting a proof-of-work solution.
1272
+ *
1273
+ * @param nonce The nonce found (8 bytes).
1274
+ * @param hash The header’s pow-hash (32 bytes).
1275
+ * @param digest The mix digest (32 bytes).
1276
+ * @returns Returns `true` if the provided solution is valid, otherwise `false`.
1277
+ *
1278
+ * ```ts
1279
+ * web3.eth.submitWork([
1280
+ * "0x0000000000000001",
1281
+ * "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
1282
+ * "0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000"
1283
+ * ]).then(console.log);
1284
+ * > true
1285
+ * ```
1286
+ */
1287
+ submitWork(nonce, hash, digest) {
1288
+ return __awaiter(this, void 0, void 0, function* () {
1289
+ return ethRpcMethods.submitWork(this.requestManager, nonce, hash, digest);
1290
+ });
1291
+ }
1292
+ // TODO - Format addresses
1293
+ /**
1294
+ * This method will request/enable the accounts from the current environment and for supporting [EIP 1102](https://eips.ethereum.org/EIPS/eip-1102)
1295
+ * This method will only work if you’re using the injected provider from a application like Metamask, Status or TrustWallet.
1296
+ * It doesn’t work if you’re connected to a node with a default Web3.js provider (WebsocketProvider, HttpProvider and IpcProvider).
1297
+ * For more information about the behavior of this method please read [EIP-1102](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1102.md): Opt-in account exposure.
1298
+ *
1299
+ * @returns An array of enabled accounts.
1300
+ *
1301
+ * ```ts
1302
+ * web3.eth.requestAccounts().then(console.log);
1303
+ * > ['0aae0B295369a9FD31d5F28D9Ec85E40f4cb692BAf', '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe']
1304
+ * ```
1305
+ */
1306
+ requestAccounts() {
1307
+ return __awaiter(this, void 0, void 0, function* () {
1308
+ return ethRpcMethods.requestAccounts(this.requestManager);
1309
+ });
1310
+ }
1311
+ /**
1312
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) - Specifies how the return data from the call should be formatted.
1313
+ * @returns The chain ID of the current connected node as described in the [EIP-695](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-695.md).
1314
+ *
1315
+ * ```ts
1316
+ * web3.eth.getChainId().then(console.log);
1317
+ * > 61n
1318
+ *
1319
+ * web3.eth.getChainId({ number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }).then(console.log);
1320
+ * > 61
1321
+ * ```
1322
+ */
1323
+ getChainId(returnFormat = this.defaultReturnFormat) {
1324
+ return __awaiter(this, void 0, void 0, function* () {
1325
+ return rpcMethodsWrappers.getChainId(this, returnFormat);
1326
+ });
1327
+ }
1328
+ /**
1329
+ * @returns The current client version.
1330
+ *
1331
+ * ```ts
1332
+ * web3.eth.getNodeInfo().then(console.log);
1333
+ * > "Mist/v0.9.3/darwin/go1.4.1"
1334
+ * ```
1335
+ */
1336
+ getNodeInfo() {
1337
+ return __awaiter(this, void 0, void 0, function* () {
1338
+ return ethRpcMethods.getNodeInfo(this.requestManager);
1339
+ });
1340
+ }
1341
+ /**
1342
+ * @param address The Address of the account or contract.
1343
+ * @param storageKeys Array of storage-keys which should be proofed and included. See {@link web3.getStorageAt}.
1344
+ * @param blockNumber ({@link BlockNumberOrTag} defaults to {@link Web3Eth.defaultBlock}) - Specifies what block to use as the current state of the blockchain while processing the gas estimation.
1345
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) - Specifies how the return data from the call should be formatted.
1346
+ * @returns The account and storage-values of the specified account including the Merkle-proof as described in [EIP-1186](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1186.md).
1347
+ *
1348
+ * ```ts
1349
+ * web3.eth.getProof(
1350
+ * "0x1234567890123456789012345678901234567890",
1351
+ * ["0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000001"],
1352
+ * "latest"
1353
+ * ).then(console.log);
1354
+ * > {
1355
+ * "address": "0x1234567890123456789012345678901234567890",
1356
+ * "accountProof": [
1357
+ * "0xf90211a090dcaf88c40c7bbc95a912cbdde67c175767b31173df9ee4b0d733bfdd511c43a0babe369f6b12092f49181ae04ca173fb68d1a5456f18d20fa32cba73954052bda0473ecf8a7e36a829e75039a3b055e51b8332cbf03324ab4af2066bbd6fbf0021a0bbda34753d7aa6c38e603f360244e8f59611921d9e1f128372fec0d586d4f9e0a04e44caecff45c9891f74f6a2156735886eedf6f1a733628ebc802ec79d844648a0a5f3f2f7542148c973977c8a1e154c4300fec92f755f7846f1b734d3ab1d90e7a0e823850f50bf72baae9d1733a36a444ab65d0a6faaba404f0583ce0ca4dad92da0f7a00cbe7d4b30b11faea3ae61b7f1f2b315b61d9f6bd68bfe587ad0eeceb721a07117ef9fc932f1a88e908eaead8565c19b5645dc9e5b1b6e841c5edbdfd71681a069eb2de283f32c11f859d7bcf93da23990d3e662935ed4d6b39ce3673ec84472a0203d26456312bbc4da5cd293b75b840fc5045e493d6f904d180823ec22bfed8ea09287b5c21f2254af4e64fca76acc5cd87399c7f1ede818db4326c98ce2dc2208a06fc2d754e304c48ce6a517753c62b1a9c1d5925b89707486d7fc08919e0a94eca07b1c54f15e299bd58bdfef9741538c7828b5d7d11a489f9c20d052b3471df475a051f9dd3739a927c89e357580a4c97b40234aa01ed3d5e0390dc982a7975880a0a089d613f26159af43616fd9455bb461f4869bfede26f2130835ed067a8b967bfb80",
1358
+ * "0xf90211a0395d87a95873cd98c21cf1df9421af03f7247880a2554e20738eec2c7507a494a0bcf6546339a1e7e14eb8fb572a968d217d2a0d1f3bc4257b22ef5333e9e4433ca012ae12498af8b2752c99efce07f3feef8ec910493be749acd63822c3558e6671a0dbf51303afdc36fc0c2d68a9bb05dab4f4917e7531e4a37ab0a153472d1b86e2a0ae90b50f067d9a2244e3d975233c0a0558c39ee152969f6678790abf773a9621a01d65cd682cc1be7c5e38d8da5c942e0a73eeaef10f387340a40a106699d494c3a06163b53d956c55544390c13634ea9aa75309f4fd866f312586942daf0f60fb37a058a52c1e858b1382a8893eb9c1f111f266eb9e21e6137aff0dddea243a567000a037b4b100761e02de63ea5f1fcfcf43e81a372dafb4419d126342136d329b7a7ba032472415864b08f808ba4374092003c8d7c40a9f7f9fe9cc8291f62538e1cc14a074e238ff5ec96b810364515551344100138916594d6af966170ff326a092fab0a0d31ac4eef14a79845200a496662e92186ca8b55e29ed0f9f59dbc6b521b116fea090607784fe738458b63c1942bba7c0321ae77e18df4961b2bc66727ea996464ea078f757653c1b63f72aff3dcc3f2a2e4c8cb4a9d36d1117c742833c84e20de994a0f78407de07f4b4cb4f899dfb95eedeb4049aeb5fc1635d65cf2f2f4dfd25d1d7a0862037513ba9d45354dd3e36264aceb2b862ac79d2050f14c95657e43a51b85c80",
1359
+ * "0xf90171a04ad705ea7bf04339fa36b124fa221379bd5a38ffe9a6112cb2d94be3a437b879a08e45b5f72e8149c01efcb71429841d6a8879d4bbe27335604a5bff8dfdf85dcea00313d9b2f7c03733d6549ea3b810e5262ed844ea12f70993d87d3e0f04e3979ea0b59e3cdd6750fa8b15164612a5cb6567cdfb386d4e0137fccee5f35ab55d0efda0fe6db56e42f2057a071c980a778d9a0b61038f269dd74a0e90155b3f40f14364a08538587f2378a0849f9608942cf481da4120c360f8391bbcc225d811823c6432a026eac94e755534e16f9552e73025d6d9c30d1d7682a4cb5bd7741ddabfd48c50a041557da9a74ca68da793e743e81e2029b2835e1cc16e9e25bd0c1e89d4ccad6980a041dda0a40a21ade3a20fcd1a4abb2a42b74e9a32b02424ff8db4ea708a5e0fb9a09aaf8326a51f613607a8685f57458329b41e938bb761131a5747e066b81a0a16808080a022e6cef138e16d2272ef58434ddf49260dc1de1f8ad6dfca3da5d2a92aaaadc58080",
1360
+ * "0xf851808080a009833150c367df138f1538689984b8a84fc55692d3d41fe4d1e5720ff5483a6980808080808080808080a0a319c1c415b271afc0adcb664e67738d103ac168e0bc0b7bd2da7966165cb9518080"
1361
+ * ],
1362
+ * "balance": 0n,
1363
+ * "codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
1364
+ * "nonce": 0n,
1365
+ * "storageHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
1366
+ * "storageProof": [
1367
+ * {
1368
+ * "key": "0x0000000000000000000000000000000000000000000000000000000000000000",
1369
+ * "value": 0n,
1370
+ * "proof": []
1371
+ * },
1372
+ * {
1373
+ * "key": "0x0000000000000000000000000000000000000000000000000000000000000001",
1374
+ * "value": 0n,
1375
+ * "proof": []
1376
+ * }
1377
+ * ]
1378
+ * }
1379
+ *
1380
+ * web3.eth.getProof(
1381
+ * "0x1234567890123456789012345678901234567890",
1382
+ * ["0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000001"],
1383
+ * undefined,
1384
+ * { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }
1385
+ * ).then(console.log);
1386
+ * > {
1387
+ * "address": "0x1234567890123456789012345678901234567890",
1388
+ * "accountProof": [
1389
+ * "0xf90211a090dcaf88c40c7bbc95a912cbdde67c175767b31173df9ee4b0d733bfdd511c43a0babe369f6b12092f49181ae04ca173fb68d1a5456f18d20fa32cba73954052bda0473ecf8a7e36a829e75039a3b055e51b8332cbf03324ab4af2066bbd6fbf0021a0bbda34753d7aa6c38e603f360244e8f59611921d9e1f128372fec0d586d4f9e0a04e44caecff45c9891f74f6a2156735886eedf6f1a733628ebc802ec79d844648a0a5f3f2f7542148c973977c8a1e154c4300fec92f755f7846f1b734d3ab1d90e7a0e823850f50bf72baae9d1733a36a444ab65d0a6faaba404f0583ce0ca4dad92da0f7a00cbe7d4b30b11faea3ae61b7f1f2b315b61d9f6bd68bfe587ad0eeceb721a07117ef9fc932f1a88e908eaead8565c19b5645dc9e5b1b6e841c5edbdfd71681a069eb2de283f32c11f859d7bcf93da23990d3e662935ed4d6b39ce3673ec84472a0203d26456312bbc4da5cd293b75b840fc5045e493d6f904d180823ec22bfed8ea09287b5c21f2254af4e64fca76acc5cd87399c7f1ede818db4326c98ce2dc2208a06fc2d754e304c48ce6a517753c62b1a9c1d5925b89707486d7fc08919e0a94eca07b1c54f15e299bd58bdfef9741538c7828b5d7d11a489f9c20d052b3471df475a051f9dd3739a927c89e357580a4c97b40234aa01ed3d5e0390dc982a7975880a0a089d613f26159af43616fd9455bb461f4869bfede26f2130835ed067a8b967bfb80",
1390
+ * "0xf90211a0395d87a95873cd98c21cf1df9421af03f7247880a2554e20738eec2c7507a494a0bcf6546339a1e7e14eb8fb572a968d217d2a0d1f3bc4257b22ef5333e9e4433ca012ae12498af8b2752c99efce07f3feef8ec910493be749acd63822c3558e6671a0dbf51303afdc36fc0c2d68a9bb05dab4f4917e7531e4a37ab0a153472d1b86e2a0ae90b50f067d9a2244e3d975233c0a0558c39ee152969f6678790abf773a9621a01d65cd682cc1be7c5e38d8da5c942e0a73eeaef10f387340a40a106699d494c3a06163b53d956c55544390c13634ea9aa75309f4fd866f312586942daf0f60fb37a058a52c1e858b1382a8893eb9c1f111f266eb9e21e6137aff0dddea243a567000a037b4b100761e02de63ea5f1fcfcf43e81a372dafb4419d126342136d329b7a7ba032472415864b08f808ba4374092003c8d7c40a9f7f9fe9cc8291f62538e1cc14a074e238ff5ec96b810364515551344100138916594d6af966170ff326a092fab0a0d31ac4eef14a79845200a496662e92186ca8b55e29ed0f9f59dbc6b521b116fea090607784fe738458b63c1942bba7c0321ae77e18df4961b2bc66727ea996464ea078f757653c1b63f72aff3dcc3f2a2e4c8cb4a9d36d1117c742833c84e20de994a0f78407de07f4b4cb4f899dfb95eedeb4049aeb5fc1635d65cf2f2f4dfd25d1d7a0862037513ba9d45354dd3e36264aceb2b862ac79d2050f14c95657e43a51b85c80",
1391
+ * "0xf90171a04ad705ea7bf04339fa36b124fa221379bd5a38ffe9a6112cb2d94be3a437b879a08e45b5f72e8149c01efcb71429841d6a8879d4bbe27335604a5bff8dfdf85dcea00313d9b2f7c03733d6549ea3b810e5262ed844ea12f70993d87d3e0f04e3979ea0b59e3cdd6750fa8b15164612a5cb6567cdfb386d4e0137fccee5f35ab55d0efda0fe6db56e42f2057a071c980a778d9a0b61038f269dd74a0e90155b3f40f14364a08538587f2378a0849f9608942cf481da4120c360f8391bbcc225d811823c6432a026eac94e755534e16f9552e73025d6d9c30d1d7682a4cb5bd7741ddabfd48c50a041557da9a74ca68da793e743e81e2029b2835e1cc16e9e25bd0c1e89d4ccad6980a041dda0a40a21ade3a20fcd1a4abb2a42b74e9a32b02424ff8db4ea708a5e0fb9a09aaf8326a51f613607a8685f57458329b41e938bb761131a5747e066b81a0a16808080a022e6cef138e16d2272ef58434ddf49260dc1de1f8ad6dfca3da5d2a92aaaadc58080",
1392
+ * "0xf851808080a009833150c367df138f1538689984b8a84fc55692d3d41fe4d1e5720ff5483a6980808080808080808080a0a319c1c415b271afc0adcb664e67738d103ac168e0bc0b7bd2da7966165cb9518080"
1393
+ * ],
1394
+ * "balance": 0,
1395
+ * "codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
1396
+ * "nonce": 0,
1397
+ * "storageHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
1398
+ * "storageProof": [
1399
+ * {
1400
+ * "key": "0x0000000000000000000000000000000000000000000000000000000000000000",
1401
+ * "value": 0,
1402
+ * "proof": []
1403
+ * },
1404
+ * {
1405
+ * "key": "0x0000000000000000000000000000000000000000000000000000000000000001",
1406
+ * "value": 0,
1407
+ * "proof": []
1408
+ * }
1409
+ * ]
1410
+ * }
1411
+ * ```
1412
+ */
1413
+ getProof(address, storageKeys, blockNumber = this.defaultBlock, returnFormat = this.defaultReturnFormat) {
1414
+ return __awaiter(this, void 0, void 0, function* () {
1415
+ return rpcMethodsWrappers.getProof(this, address, storageKeys, blockNumber, returnFormat);
1416
+ });
1417
+ }
1418
+ // TODO Throwing an error with Geth, but not Infura
1419
+ // TODO gasUsedRatio and reward not formatting
1420
+ /**
1421
+ * @param blockCount 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.
1422
+ * @param newestBlock Highest number block of the requested range.
1423
+ * @param rewardPercentiles 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']`
1424
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) - Specifies how the return data from the call should be formatted.
1425
+ * @returns `baseFeePerGas` and transaction effective `priorityFeePerGas` history for the requested block range if available.
1426
+ * 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.
1427
+ * For pre-EIP-1559 blocks the `gasPrice`s are returned as `rewards` and zeroes are returned for the `baseFeePerGas`.
1428
+ *
1429
+ * ```ts
1430
+ * web3.eth.getFeeHistory(4, 'pending', [0, 25, 75, 100]).then(console.log);
1431
+ * > {
1432
+ * baseFeePerGas: [
1433
+ * 22983878621n,
1434
+ * 21417903463n,
1435
+ * 19989260230n,
1436
+ * 17770954829n,
1437
+ * 18850641304n
1438
+ * ],
1439
+ * gasUsedRatio: [
1440
+ * 0.22746546666666667,
1441
+ * 0.2331871,
1442
+ * 0.05610054885262125,
1443
+ * 0.7430227268212117
1444
+ * ],
1445
+ * oldestBlock: 15216343n,
1446
+ * reward: [
1447
+ * [ '0x3b9aca00', '0x53724e00', '0x77359400', '0x1d92c03423' ],
1448
+ * [ '0x3b9aca00', '0x3b9aca00', '0x3b9aca00', '0xee6b2800' ],
1449
+ * [ '0x3b9aca00', '0x4f86a721', '0x77d9743a', '0x9502f900' ],
1450
+ * [ '0xcc8ff9e', '0x53724e00', '0x77359400', '0x1ec9771bb3' ]
1451
+ * ]
1452
+ * }
1453
+ *
1454
+ * web3.eth.getFeeHistory(4, BlockTags.LATEST, [0, 25, 75, 100], { number: FMT_NUMBER.NUMBER , bytes: FMT_BYTES.HEX }).then(console.log);
1455
+ * > {
1456
+ * baseFeePerGas: [
1457
+ * 22983878621,
1458
+ * 21417903463,
1459
+ * 19989260230,
1460
+ * 17770954829,
1461
+ * 18850641304
1462
+ * ],
1463
+ * gasUsedRatio: [
1464
+ * 0.22746546666666667,
1465
+ * 0.2331871,
1466
+ * 0.05610054885262125,
1467
+ * 0.7430227268212117
1468
+ * ],
1469
+ * oldestBlock: 15216343,
1470
+ * reward: [
1471
+ * [ '0x3b9aca00', '0x53724e00', '0x77359400', '0x1d92c03423' ],
1472
+ * [ '0x3b9aca00', '0x3b9aca00', '0x3b9aca00', '0xee6b2800' ],
1473
+ * [ '0x3b9aca00', '0x4f86a721', '0x77d9743a', '0x9502f900' ],
1474
+ * [ '0xcc8ff9e', '0x53724e00', '0x77359400', '0x1ec9771bb3' ]
1475
+ * ]
1476
+ * }
1477
+ * ```
1478
+ */
1479
+ getFeeHistory(blockCount, newestBlock = this.defaultBlock, rewardPercentiles, returnFormat = this.defaultReturnFormat) {
1480
+ return __awaiter(this, void 0, void 0, function* () {
1481
+ return rpcMethodsWrappers.getFeeHistory(this, blockCount, newestBlock, rewardPercentiles, returnFormat);
1482
+ });
1483
+ }
1484
+ /**
1485
+ * This method generates an access list for a transaction.
1486
+ *
1487
+ * @param transaction - A transaction object where all properties are optional except `from`, however it's recommended to include the `to` property.
1488
+ * @param blockNumber ({@link BlockNumberOrTag} defaults to {@link Web3Eth.defaultBlock}) - Specifies what block to use as the current state of the blockchain while processing the transaction.
1489
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) - Specifies how the return data from the createAccessList should be formatted.
1490
+ * @returns The returned data of the createAccessList, e.g. The generated access list for transaction.
1491
+ * @example
1492
+ * ```ts
1493
+ * web3.eth.createAccessList({
1494
+ * from: '0xDe95305a63302C3aa4d3A9B42654659AeA72b694',
1495
+ * data: '0x9a67c8b100000000000000000000000000000000000000000000000000000000000004d0',
1496
+ * gasPrice: '0x3b9aca00',
1497
+ * gas: '0x3d0900',
1498
+ * to: '0x940b25304947ae863568B3804434EC77E2160b87'
1499
+ * })
1500
+ * .then(console.log);
1501
+ *
1502
+ * > {
1503
+ * "accessList": [
1504
+ * {
1505
+ * "address": "0x15859bdf5aff2080a9968f6a410361e9598df62f",
1506
+ * "storageKeys": [
1507
+ * "0x0000000000000000000000000000000000000000000000000000000000000000"
1508
+ * ]
1509
+ * }
1510
+ * ],
1511
+ * "gasUsed": "0x7671"
1512
+ * }
1513
+ * ```
1514
+ */
1515
+ createAccessList(transaction, blockNumber = this.defaultBlock, returnFormat = this.defaultReturnFormat) {
1516
+ return __awaiter(this, void 0, void 0, function* () {
1517
+ return rpcMethodsWrappers.createAccessList(this, transaction, blockNumber, returnFormat);
1518
+ });
1519
+ }
1520
+ /**
1521
+ * This method sends EIP-712 typed data to the RPC provider to be signed.
1522
+ *
1523
+ * @param address The address that corresponds with the private key used to sign the typed data.
1524
+ * @param typedData The EIP-712 typed data object.
1525
+ * @param useLegacy A boolean flag determining whether the RPC call uses the legacy method `eth_signTypedData` or the newer method `eth_signTypedData_v4`
1526
+ * @param returnFormat ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) - Specifies how the signed typed data should be formatted.
1527
+ * @returns The signed typed data.
1528
+ */
1529
+ signTypedData(address, typedData, useLegacy, returnFormat) {
1530
+ var _a;
1531
+ if (useLegacy === void 0) { useLegacy = false; }
1532
+ if (returnFormat === void 0) { returnFormat = ((_a = this.defaultReturnFormat) !== null && _a !== void 0 ? _a : DEFAULT_RETURN_FORMAT); }
1533
+ return __awaiter(this, void 0, void 0, function* () {
1534
+ return rpcMethodsWrappers.signTypedData(this, address, typedData, useLegacy, returnFormat);
1535
+ });
1536
+ }
1537
+ /**
1538
+ * Lets you subscribe to specific events in the blockchain.
1539
+ *
1540
+ * @param name - The subscription you want to subscribe to.
1541
+ * @param args - Optional additional parameters, depending on the subscription type.
1542
+ * @returns A subscription object of type {@link RegisteredSubscription}. The object contains:
1543
+ * - subscription.id: The subscription id, used to identify and unsubscribing the subscription.
1544
+ * - subscription.subscribe(): Can be used to re-subscribe with the same parameters.
1545
+ * - subscription.unsubscribe(): Unsubscribes the subscription and returns TRUE in the callback if successful.
1546
+ * - subscription.args: The subscription arguments, used when re-subscribing.
1547
+ *
1548
+ *
1549
+ * You can use the subscription object to listen on:
1550
+ *
1551
+ * - on("data") - Fires on each incoming log with the log object as argument.
1552
+ * - on("changed") - Fires on each log which was removed from the blockchain. The log will have the additional property "removed: true".
1553
+ * - on("error") - Fires when an error in the subscription occurs.
1554
+ * - on("connected") - Fires once after the subscription successfully connected. Returns the subscription id.
1555
+ *
1556
+ * @example **Subscribe to Smart Contract events**
1557
+ * ```ts
1558
+ * // Subscribe to `logs`
1559
+ * const logSubscription = web3.eth.subscribe('logs', {
1560
+ * address: '0x1234567890123456789012345678901234567890',
1561
+ * topics: ['0x033456732123ffff2342342dd12342434324234234fd234fd23fd4f23d4234']
1562
+ * });
1563
+ * logSubscription.on('data', (data: any) => console.log(data));
1564
+ * logSubscription.on('error', (error: any) => console.log(error));
1565
+ *
1566
+ * ```
1567
+ *
1568
+ * @example **Subscribe to new block headers**
1569
+ * ```ts
1570
+ * // Subscribe to `newBlockHeaders`
1571
+ * const newBlocksSubscription = await web3.eth.subscribe('newBlockHeaders');
1572
+ *
1573
+ * newBlocksSubscription.on('data', async blockhead => {
1574
+ * console.log('New block header: ', blockhead);
1575
+ *
1576
+ * // You do not need the next line, if you like to keep notified for every new block
1577
+ * await newBlocksSubscription.unsubscribe();
1578
+ * console.log('Unsubscribed from new block headers.');
1579
+ * });
1580
+ * newBlocksSubscription.on('error', error =>
1581
+ * console.log('Error when subscribing to New block header: ', error),
1582
+ * );
1583
+ * ```
1584
+ *
1585
+ * ### subscribe('pendingTransactions')
1586
+ *
1587
+ * Subscribes to incoming pending transactions.
1588
+ * You can subscribe to pending transactions by calling web3.eth.subscribe('pendingTransactions').
1589
+ *
1590
+ * ```ts
1591
+ * (await web3.eth.subscribe('pendingTransactions')).on('data', console.log);
1592
+ * ```
1593
+ *
1594
+ * ### subscribe('newHeads')
1595
+ * ( same as subscribe('newBlockHeaders'))
1596
+ * Subscribes to incoming block headers. This can be used as timer to check for changes on the blockchain.
1597
+ *
1598
+ * The structure of a returned block header is {@link BlockHeaderOutput}:
1599
+ *
1600
+ * ```ts
1601
+ * (await web3.eth.subscribe('newHeads')).on( // 'newBlockHeaders' would work as well
1602
+ * 'data',
1603
+ * console.log
1604
+ * );
1605
+ * >{
1606
+ * parentHash: '0x9e746a1d906b299def98c75b06f714d62dacadd567c7515d76eeaa8c8074c738',
1607
+ * sha3Uncles: '0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347',
1608
+ * miner: '0x0000000000000000000000000000000000000000',
1609
+ * stateRoot: '0xe0f04b04861ecfa95e82a9310d6a7ef7aef8d7417f5209c182582bfb98a8e307',
1610
+ * transactionsRoot: '0x31ab4ea571a9e10d3a19aaed07d190595b1dfa34e03960c04293fec565dea536',
1611
+ * logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
1612
+ * difficulty: 2n,
1613
+ * number: 21n,
1614
+ * gasLimit: 11738125n,
1615
+ * gasUsed: 830006n,
1616
+ * timestamp: 1678797237n,
1617
+ * extraData: '0xd883010b02846765746888676f312e32302e31856c696e757800000000000000e0a6e93cf40e2e71a72e493272210c3f43738ccc7e7d7b14ffd51833797d896c09117e8dc4fbcbc969bd21b42e5af3e276a911524038c001b2109b63b8e0352601',
1618
+ * nonce: 0n
1619
+ * }
1620
+ * ```
1621
+ *
1622
+ * ### subscribe('syncing')
1623
+ * Subscribe to syncing events. This will return `true` when the node is syncing and when it’s finished syncing will return `false`, for the `changed` event.
1624
+ *
1625
+ * ```ts
1626
+ * (await web3.eth.subscribe('syncing')).on('changed', console.log);
1627
+ * > `true` // when syncing
1628
+ *
1629
+ * (await web3.eth.subscribe('syncing')).on('data', console.log);
1630
+ * > {
1631
+ * startingBlock: 0,
1632
+ * currentBlock: 0,
1633
+ * highestBlock: 0,
1634
+ * pulledStates: 0,
1635
+ * knownStates: 0
1636
+ * }
1637
+ * ```
1638
+ *
1639
+ * ### subscribe('logs', options)
1640
+ * Subscribes to incoming logs, filtered by the given options. If a valid numerical fromBlock options property is set, web3.js will retrieve logs beginning from this point, backfilling the response as necessary.
1641
+ *
1642
+ * options: You can subscribe to logs matching a given filter object, which can take the following parameters:
1643
+ * - `fromBlock`: (optional, default: 'latest') Integer block number, or `'latest'` for the last mined block or `'pending'`, `'earliest'` for not yet mined transactions.
1644
+ * - `address`: (optional) Contract address or a list of addresses from which logs should originate.
1645
+ * - `topics`: (optional) Array of 32 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with `or` options.
1646
+ *
1647
+ * ```ts
1648
+ * (await web3.eth.subscribe('logs', {
1649
+ * address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
1650
+ * })).on('data', console.log);
1651
+ *
1652
+ * > {
1653
+ * removed: false,
1654
+ * logIndex: 119n,
1655
+ * transactionIndex: 58n,
1656
+ * transactionHash: '0x61533efa77937360215069d5d6cb0be09a22af9721e6dc3df59d957833ed8870',
1657
+ * blockHash: '0xe32bb97084479d32247f66f8b46d00af2fbc3c2db2bc6e5843fe2e4d1ca9b099',
1658
+ * blockNumber: 18771966n,
1659
+ * address: '0xdac17f958d2ee523a2206206994597c13d831ec7',
1660
+ * data: '0x00000000000000000000000000000000000000000000000000000000d88b2e40',
1661
+ * topics: [
1662
+ * '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
1663
+ * '0x0000000000000000000000002fb2457f6ec1865dc0d4e7300c696b69c2a1b989',
1664
+ * '0x00000000000000000000000027fd43babfbe83a81d14665b1a6fb8030a60c9b4'
1665
+ * ]
1666
+ * }
1667
+ *```
1668
+ */
1669
+ subscribe(name, args, returnFormat) {
1670
+ var _a, _b;
1671
+ if (returnFormat === void 0) { returnFormat = ((_a = this.defaultReturnFormat) !== null && _a !== void 0 ? _a : DEFAULT_RETURN_FORMAT); }
1672
+ return __awaiter(this, void 0, void 0, function* () {
1673
+ const subscription = yield ((_b = this.subscriptionManager) === null || _b === void 0 ? void 0 : _b.subscribe(name, args, returnFormat));
1674
+ if (subscription instanceof LogsSubscription &&
1675
+ name === 'logs' &&
1676
+ typeof args === 'object' &&
1677
+ !isNullish(args.fromBlock) &&
1678
+ Number.isFinite(Number(args.fromBlock))) {
1679
+ setImmediate(() => {
1680
+ this.getPastLogs(args)
1681
+ .then(logs => {
1682
+ for (const log of logs) {
1683
+ subscription._processSubscriptionResult(log);
1684
+ }
1685
+ })
1686
+ .catch(e => {
1687
+ subscription._processSubscriptionError(e);
1688
+ });
1689
+ });
1690
+ }
1691
+ return subscription;
1692
+ });
1693
+ }
1694
+ static shouldClearSubscription({ sub }) {
1695
+ return !(sub instanceof SyncingSubscription);
1696
+ }
1697
+ /**
1698
+ * Resets subscriptions.
1699
+ *
1700
+ * @param notClearSyncing If `true` it keeps the `syncing` subscription.
1701
+ * @returns A promise to an array of subscription ids that were cleared.
1702
+ *
1703
+ * ```ts
1704
+ * web3.eth.clearSubscriptions().then(console.log);
1705
+ * > [...] An array of subscription ids that were cleared
1706
+ * ```
1707
+ */
1708
+ clearSubscriptions(notClearSyncing = false) {
1709
+ var _a;
1710
+ return (_a = this.subscriptionManager) === null || _a === void 0 ? void 0 : _a.unsubscribe(
1711
+ // eslint-disable-next-line
1712
+ notClearSyncing ? Web3Eth.shouldClearSubscription : undefined);
1713
+ }
1714
+ }
1715
+ //# sourceMappingURL=web3_eth.js.map