wb-eth3 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 wb-eth3 might be problematic. Click here for more details.

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