1 | import type { AddressLike, NameResolver } from "../address/index.js";
|
2 | import type { BigNumberish, EventEmitterable } from "../utils/index.js";
|
3 | import type { Signature } from "../crypto/index.js";
|
4 | import type { AccessList, AccessListish, BlobLike, KzgLibrary, TransactionLike } from "../transaction/index.js";
|
5 | import type { ContractRunner } from "./contracts.js";
|
6 | import type { Network } from "./network.js";
|
7 | /**
|
8 | * A **BlockTag** specifies a specific block.
|
9 | *
|
10 | * **numeric value** - specifies the block height, where
|
11 | * the genesis block is block 0; many operations accept a negative
|
12 | * value which indicates the block number should be deducted from
|
13 | * the most recent block. A numeric value may be a ``number``, ``bigint``,
|
14 | * or a decimal of hex string.
|
15 | *
|
16 | * **blockhash** - specifies a specific block by its blockhash; this allows
|
17 | * potentially orphaned blocks to be specifed, without ambiguity, but many
|
18 | * backends do not support this for some operations.
|
19 | */
|
20 | export type BlockTag = BigNumberish | string;
|
21 | import { BlockParams, LogParams, TransactionReceiptParams, TransactionResponseParams } from "./formatting.js";
|
22 | /**
|
23 | * A **FeeData** wraps all the fee-related values associated with
|
24 | * the network.
|
25 | */
|
26 | export declare class FeeData {
|
27 | /**
|
28 | * The gas price for legacy networks.
|
29 | */
|
30 | readonly gasPrice: null | bigint;
|
31 | /**
|
32 | * The maximum fee to pay per gas.
|
33 | *
|
34 | * The base fee per gas is defined by the network and based on
|
35 | * congestion, increasing the cost during times of heavy load
|
36 | * and lowering when less busy.
|
37 | *
|
38 | * The actual fee per gas will be the base fee for the block
|
39 | * and the priority fee, up to the max fee per gas.
|
40 | *
|
41 | * This will be ``null`` on legacy networks (i.e. [pre-EIP-1559](link-eip-1559))
|
42 | */
|
43 | readonly maxFeePerGas: null | bigint;
|
44 | /**
|
45 | * The additional amout to pay per gas to encourage a validator
|
46 | * to include the transaction.
|
47 | *
|
48 | * The purpose of this is to compensate the validator for the
|
49 | * adjusted risk for including a given transaction.
|
50 | *
|
51 | * This will be ``null`` on legacy networks (i.e. [pre-EIP-1559](link-eip-1559))
|
52 | */
|
53 | readonly maxPriorityFeePerGas: null | bigint;
|
54 | /**
|
55 | * Creates a new FeeData for %%gasPrice%%, %%maxFeePerGas%% and
|
56 | * %%maxPriorityFeePerGas%%.
|
57 | */
|
58 | constructor(gasPrice?: null | bigint, maxFeePerGas?: null | bigint, maxPriorityFeePerGas?: null | bigint);
|
59 | /**
|
60 | * Returns a JSON-friendly value.
|
61 | */
|
62 | toJSON(): any;
|
63 | }
|
64 | /**
|
65 | * A **TransactionRequest** is a transactions with potentially various
|
66 | * properties not defined, or with less strict types for its values.
|
67 | *
|
68 | * This is used to pass to various operations, which will internally
|
69 | * coerce any types and populate any necessary values.
|
70 | */
|
71 | export interface TransactionRequest {
|
72 | /**
|
73 | * The transaction type.
|
74 | */
|
75 | type?: null | number;
|
76 | /**
|
77 | * The target of the transaction.
|
78 | */
|
79 | to?: null | AddressLike;
|
80 | /**
|
81 | * The sender of the transaction.
|
82 | */
|
83 | from?: null | AddressLike;
|
84 | /**
|
85 | * The nonce of the transaction, used to prevent replay attacks.
|
86 | */
|
87 | nonce?: null | number;
|
88 | /**
|
89 | * The maximum amount of gas to allow this transaction to consume.
|
90 | */
|
91 | gasLimit?: null | BigNumberish;
|
92 | /**
|
93 | * The gas price to use for legacy transactions or transactions on
|
94 | * legacy networks.
|
95 | *
|
96 | * Most of the time the ``max*FeePerGas`` is preferred.
|
97 | */
|
98 | gasPrice?: null | BigNumberish;
|
99 | /**
|
100 | * The [[link-eip-1559]] maximum priority fee to pay per gas.
|
101 | */
|
102 | maxPriorityFeePerGas?: null | BigNumberish;
|
103 | /**
|
104 | * The [[link-eip-1559]] maximum total fee to pay per gas. The actual
|
105 | * value used is protocol enforced to be the block's base fee.
|
106 | */
|
107 | maxFeePerGas?: null | BigNumberish;
|
108 | /**
|
109 | * The transaction data.
|
110 | */
|
111 | data?: null | string;
|
112 | /**
|
113 | * The transaction value (in wei).
|
114 | */
|
115 | value?: null | BigNumberish;
|
116 | /**
|
117 | * The chain ID for the network this transaction is valid on.
|
118 | */
|
119 | chainId?: null | BigNumberish;
|
120 | /**
|
121 | * The [[link-eip-2930]] access list. Storage slots included in the access
|
122 | * list are //warmed// by pre-loading them, so their initial cost to
|
123 | * fetch is guaranteed, but then each additional access is cheaper.
|
124 | */
|
125 | accessList?: null | AccessListish;
|
126 | /**
|
127 | * A custom object, which can be passed along for network-specific
|
128 | * values.
|
129 | */
|
130 | customData?: any;
|
131 | /**
|
132 | * When using ``call`` or ``estimateGas``, this allows a specific
|
133 | * block to be queried. Many backends do not support this and when
|
134 | * unsupported errors are silently squelched and ``"latest"`` is used.
|
135 | */
|
136 | blockTag?: BlockTag;
|
137 | /**
|
138 | * When using ``call``, this enables CCIP-read, which permits the
|
139 | * provider to be redirected to web-based content during execution,
|
140 | * which is then further validated by the contract.
|
141 | *
|
142 | * There are potential security implications allowing CCIP-read, as
|
143 | * it could be used to expose the IP address or user activity during
|
144 | * the fetch to unexpected parties.
|
145 | */
|
146 | enableCcipRead?: boolean;
|
147 | /**
|
148 | * The blob versioned hashes (see [[link-eip-4844]]).
|
149 | */
|
150 | blobVersionedHashes?: null | Array<string>;
|
151 | /**
|
152 | * The maximum fee per blob gas (see [[link-eip-4844]]).
|
153 | */
|
154 | maxFeePerBlobGas?: null | BigNumberish;
|
155 | /**
|
156 | * Any blobs to include in the transaction (see [[link-eip-4844]]).
|
157 | */
|
158 | blobs?: null | Array<BlobLike>;
|
159 | /**
|
160 | * An external library for computing the KZG commitments and
|
161 | * proofs necessary for EIP-4844 transactions (see [[link-eip-4844]]).
|
162 | *
|
163 | * This is generally ``null``, unless you are creating BLOb
|
164 | * transactions.
|
165 | */
|
166 | kzg?: null | KzgLibrary;
|
167 | }
|
168 | /**
|
169 | * A **PreparedTransactionRequest** is identical to a [[TransactionRequest]]
|
170 | * except all the property types are strictly enforced.
|
171 | */
|
172 | export interface PreparedTransactionRequest {
|
173 | /**
|
174 | * The transaction type.
|
175 | */
|
176 | type?: number;
|
177 | /**
|
178 | * The target of the transaction.
|
179 | */
|
180 | to?: AddressLike;
|
181 | /**
|
182 | * The sender of the transaction.
|
183 | */
|
184 | from?: AddressLike;
|
185 | /**
|
186 | * The nonce of the transaction, used to prevent replay attacks.
|
187 | */
|
188 | nonce?: number;
|
189 | /**
|
190 | * The maximum amount of gas to allow this transaction to consime.
|
191 | */
|
192 | gasLimit?: bigint;
|
193 | /**
|
194 | * The gas price to use for legacy transactions or transactions on
|
195 | * legacy networks.
|
196 | *
|
197 | * Most of the time the ``max*FeePerGas`` is preferred.
|
198 | */
|
199 | gasPrice?: bigint;
|
200 | /**
|
201 | * The [[link-eip-1559]] maximum priority fee to pay per gas.
|
202 | */
|
203 | maxPriorityFeePerGas?: bigint;
|
204 | /**
|
205 | * The [[link-eip-1559]] maximum total fee to pay per gas. The actual
|
206 | * value used is protocol enforced to be the block's base fee.
|
207 | */
|
208 | maxFeePerGas?: bigint;
|
209 | /**
|
210 | * The transaction data.
|
211 | */
|
212 | data?: string;
|
213 | /**
|
214 | * The transaction value (in wei).
|
215 | */
|
216 | value?: bigint;
|
217 | /**
|
218 | * The chain ID for the network this transaction is valid on.
|
219 | */
|
220 | chainId?: bigint;
|
221 | /**
|
222 | * The [[link-eip-2930]] access list. Storage slots included in the access
|
223 | * list are //warmed// by pre-loading them, so their initial cost to
|
224 | * fetch is guaranteed, but then each additional access is cheaper.
|
225 | */
|
226 | accessList?: AccessList;
|
227 | /**
|
228 | * A custom object, which can be passed along for network-specific
|
229 | * values.
|
230 | */
|
231 | customData?: any;
|
232 | /**
|
233 | * When using ``call`` or ``estimateGas``, this allows a specific
|
234 | * block to be queried. Many backends do not support this and when
|
235 | * unsupported errors are silently squelched and ``"latest"`` is used.
|
236 | */
|
237 | blockTag?: BlockTag;
|
238 | /**
|
239 | * When using ``call``, this enables CCIP-read, which permits the
|
240 | * provider to be redirected to web-based content during execution,
|
241 | * which is then further validated by the contract.
|
242 | *
|
243 | * There are potential security implications allowing CCIP-read, as
|
244 | * it could be used to expose the IP address or user activity during
|
245 | * the fetch to unexpected parties.
|
246 | */
|
247 | enableCcipRead?: boolean;
|
248 | }
|
249 | /**
|
250 | * Returns a copy of %%req%% with all properties coerced to their strict
|
251 | * types.
|
252 | */
|
253 | export declare function copyRequest(req: TransactionRequest): PreparedTransactionRequest;
|
254 | /**
|
255 | * An Interface to indicate a [[Block]] has been included in the
|
256 | * blockchain. This asserts a Type Guard that necessary properties
|
257 | * are non-null.
|
258 | *
|
259 | * Before a block is included, it is a //pending// block.
|
260 | */
|
261 | export interface MinedBlock extends Block {
|
262 | /**
|
263 | * The block number also known as the block height.
|
264 | */
|
265 | readonly number: number;
|
266 | /**
|
267 | * The block hash.
|
268 | */
|
269 | readonly hash: string;
|
270 | /**
|
271 | * The block timestamp, in seconds from epoch.
|
272 | */
|
273 | readonly timestamp: number;
|
274 | /**
|
275 | * The block date, created from the [[timestamp]].
|
276 | */
|
277 | readonly date: Date;
|
278 | /**
|
279 | * The miner of the block, also known as the ``author`` or
|
280 | * block ``producer``.
|
281 | */
|
282 | readonly miner: string;
|
283 | }
|
284 | /**
|
285 | * A **Block** represents the data associated with a full block on
|
286 | * Ethereum.
|
287 | */
|
288 | export declare class Block implements BlockParams, Iterable<string> {
|
289 | #private;
|
290 | /**
|
291 | * The provider connected to the block used to fetch additional details
|
292 | * if necessary.
|
293 | */
|
294 | readonly provider: Provider;
|
295 | /**
|
296 | * The block number, sometimes called the block height. This is a
|
297 | * sequential number that is one higher than the parent block.
|
298 | */
|
299 | readonly number: number;
|
300 | /**
|
301 | * The block hash.
|
302 | *
|
303 | * This hash includes all properties, so can be safely used to identify
|
304 | * an exact set of block properties.
|
305 | */
|
306 | readonly hash: null | string;
|
307 | /**
|
308 | * The timestamp for this block, which is the number of seconds since
|
309 | * epoch that this block was included.
|
310 | */
|
311 | readonly timestamp: number;
|
312 | /**
|
313 | * The block hash of the parent block.
|
314 | */
|
315 | readonly parentHash: string;
|
316 | /**
|
317 | * The hash tree root of the parent beacon block for the given
|
318 | * execution block. See [[link-eip-4788]].
|
319 | */
|
320 | parentBeaconBlockRoot: null | string;
|
321 | /**
|
322 | * The nonce.
|
323 | *
|
324 | * On legacy networks, this is the random number inserted which
|
325 | * permitted the difficulty target to be reached.
|
326 | */
|
327 | readonly nonce: string;
|
328 | /**
|
329 | * The difficulty target.
|
330 | *
|
331 | * On legacy networks, this is the proof-of-work target required
|
332 | * for a block to meet the protocol rules to be included.
|
333 | *
|
334 | * On modern networks, this is a random number arrived at using
|
335 | * randao. @TODO: Find links?
|
336 | */
|
337 | readonly difficulty: bigint;
|
338 | /**
|
339 | * The total gas limit for this block.
|
340 | */
|
341 | readonly gasLimit: bigint;
|
342 | /**
|
343 | * The total gas used in this block.
|
344 | */
|
345 | readonly gasUsed: bigint;
|
346 | /**
|
347 | * The root hash for the global state after applying changes
|
348 | * in this block.
|
349 | */
|
350 | readonly stateRoot: null | string;
|
351 | /**
|
352 | * The hash of the transaction receipts trie.
|
353 | */
|
354 | readonly receiptsRoot: null | string;
|
355 | /**
|
356 | * The total amount of blob gas consumed by the transactions
|
357 | * within the block. See [[link-eip-4844]].
|
358 | */
|
359 | readonly blobGasUsed: null | bigint;
|
360 | /**
|
361 | * The running total of blob gas consumed in excess of the
|
362 | * target, prior to the block. See [[link-eip-4844]].
|
363 | */
|
364 | readonly excessBlobGas: null | bigint;
|
365 | /**
|
366 | * The miner coinbase address, wihch receives any subsidies for
|
367 | * including this block.
|
368 | */
|
369 | readonly miner: string;
|
370 | /**
|
371 | * The latest RANDAO mix of the post beacon state of
|
372 | * the previous block.
|
373 | */
|
374 | readonly prevRandao: null | string;
|
375 | /**
|
376 | * Any extra data the validator wished to include.
|
377 | */
|
378 | readonly extraData: string;
|
379 | /**
|
380 | * The base fee per gas that all transactions in this block were
|
381 | * charged.
|
382 | *
|
383 | * This adjusts after each block, depending on how congested the network
|
384 | * is.
|
385 | */
|
386 | readonly baseFeePerGas: null | bigint;
|
387 | /**
|
388 | * Create a new **Block** object.
|
389 | *
|
390 | * This should generally not be necessary as the unless implementing a
|
391 | * low-level library.
|
392 | */
|
393 | constructor(block: BlockParams, provider: Provider);
|
394 | /**
|
395 | * Returns the list of transaction hashes, in the order
|
396 | * they were executed within the block.
|
397 | */
|
398 | get transactions(): ReadonlyArray<string>;
|
399 | /**
|
400 | * Returns the complete transactions, in the order they
|
401 | * were executed within the block.
|
402 | *
|
403 | * This is only available for blocks which prefetched
|
404 | * transactions, by passing ``true`` to %%prefetchTxs%%
|
405 | * into [[Provider-getBlock]].
|
406 | */
|
407 | get prefetchedTransactions(): Array<TransactionResponse>;
|
408 | /**
|
409 | * Returns a JSON-friendly value.
|
410 | */
|
411 | toJSON(): any;
|
412 | [Symbol.iterator](): Iterator<string>;
|
413 | /**
|
414 | * The number of transactions in this block.
|
415 | */
|
416 | get length(): number;
|
417 | /**
|
418 | * The [[link-js-date]] this block was included at.
|
419 | */
|
420 | get date(): null | Date;
|
421 | /**
|
422 | * Get the transaction at %%indexe%% within this block.
|
423 | */
|
424 | getTransaction(indexOrHash: number | string): Promise<TransactionResponse>;
|
425 | /**
|
426 | * If a **Block** was fetched with a request to include the transactions
|
427 | * this will allow synchronous access to those transactions.
|
428 | *
|
429 | * If the transactions were not prefetched, this will throw.
|
430 | */
|
431 | getPrefetchedTransaction(indexOrHash: number | string): TransactionResponse;
|
432 | /**
|
433 | * Returns true if this block been mined. This provides a type guard
|
434 | * for all properties on a [[MinedBlock]].
|
435 | */
|
436 | isMined(): this is MinedBlock;
|
437 | /**
|
438 | * Returns true if this block is an [[link-eip-2930]] block.
|
439 | */
|
440 | isLondon(): this is (Block & {
|
441 | baseFeePerGas: bigint;
|
442 | });
|
443 | /**
|
444 | * @_ignore:
|
445 | */
|
446 | orphanedEvent(): OrphanFilter;
|
447 | }
|
448 | /**
|
449 | * A **Log** in Ethereum represents an event that has been included in a
|
450 | * transaction using the ``LOG*`` opcodes, which are most commonly used by
|
451 | * Solidity's emit for announcing events.
|
452 | */
|
453 | export declare class Log implements LogParams {
|
454 | /**
|
455 | * The provider connected to the log used to fetch additional details
|
456 | * if necessary.
|
457 | */
|
458 | readonly provider: Provider;
|
459 | /**
|
460 | * The transaction hash of the transaction this log occurred in. Use the
|
461 | * [[Log-getTransaction]] to get the [[TransactionResponse]].
|
462 | */
|
463 | readonly transactionHash: string;
|
464 | /**
|
465 | * The block hash of the block this log occurred in. Use the
|
466 | * [[Log-getBlock]] to get the [[Block]].
|
467 | */
|
468 | readonly blockHash: string;
|
469 | /**
|
470 | * The block number of the block this log occurred in. It is preferred
|
471 | * to use the [[Block-hash]] when fetching the related [[Block]],
|
472 | * since in the case of an orphaned block, the block at that height may
|
473 | * have changed.
|
474 | */
|
475 | readonly blockNumber: number;
|
476 | /**
|
477 | * If the **Log** represents a block that was removed due to an orphaned
|
478 | * block, this will be true.
|
479 | *
|
480 | * This can only happen within an orphan event listener.
|
481 | */
|
482 | readonly removed: boolean;
|
483 | /**
|
484 | * The address of the contract that emitted this log.
|
485 | */
|
486 | readonly address: string;
|
487 | /**
|
488 | * The data included in this log when it was emitted.
|
489 | */
|
490 | readonly data: string;
|
491 | /**
|
492 | * The indexed topics included in this log when it was emitted.
|
493 | *
|
494 | * All topics are included in the bloom filters, so they can be
|
495 | * efficiently filtered using the [[Provider-getLogs]] method.
|
496 | */
|
497 | readonly topics: ReadonlyArray<string>;
|
498 | /**
|
499 | * The index within the block this log occurred at. This is generally
|
500 | * not useful to developers, but can be used with the various roots
|
501 | * to proof inclusion within a block.
|
502 | */
|
503 | readonly index: number;
|
504 | /**
|
505 | * The index within the transaction of this log.
|
506 | */
|
507 | readonly transactionIndex: number;
|
508 | /**
|
509 | * @_ignore:
|
510 | */
|
511 | constructor(log: LogParams, provider: Provider);
|
512 | /**
|
513 | * Returns a JSON-compatible object.
|
514 | */
|
515 | toJSON(): any;
|
516 | /**
|
517 | * Returns the block that this log occurred in.
|
518 | */
|
519 | getBlock(): Promise<Block>;
|
520 | /**
|
521 | * Returns the transaction that this log occurred in.
|
522 | */
|
523 | getTransaction(): Promise<TransactionResponse>;
|
524 | /**
|
525 | * Returns the transaction receipt fot the transaction that this
|
526 | * log occurred in.
|
527 | */
|
528 | getTransactionReceipt(): Promise<TransactionReceipt>;
|
529 | /**
|
530 | * @_ignore:
|
531 | */
|
532 | removedEvent(): OrphanFilter;
|
533 | }
|
534 | /**
|
535 | * A **TransactionReceipt** includes additional information about a
|
536 | * transaction that is only available after it has been mined.
|
537 | */
|
538 | export declare class TransactionReceipt implements TransactionReceiptParams, Iterable<Log> {
|
539 | #private;
|
540 | /**
|
541 | * The provider connected to the log used to fetch additional details
|
542 | * if necessary.
|
543 | */
|
544 | readonly provider: Provider;
|
545 | /**
|
546 | * The address the transaction was sent to.
|
547 | */
|
548 | readonly to: null | string;
|
549 | /**
|
550 | * The sender of the transaction.
|
551 | */
|
552 | readonly from: string;
|
553 | /**
|
554 | * The address of the contract if the transaction was directly
|
555 | * responsible for deploying one.
|
556 | *
|
557 | * This is non-null **only** if the ``to`` is empty and the ``data``
|
558 | * was successfully executed as initcode.
|
559 | */
|
560 | readonly contractAddress: null | string;
|
561 | /**
|
562 | * The transaction hash.
|
563 | */
|
564 | readonly hash: string;
|
565 | /**
|
566 | * The index of this transaction within the block transactions.
|
567 | */
|
568 | readonly index: number;
|
569 | /**
|
570 | * The block hash of the [[Block]] this transaction was included in.
|
571 | */
|
572 | readonly blockHash: string;
|
573 | /**
|
574 | * The block number of the [[Block]] this transaction was included in.
|
575 | */
|
576 | readonly blockNumber: number;
|
577 | /**
|
578 | * The bloom filter bytes that represent all logs that occurred within
|
579 | * this transaction. This is generally not useful for most developers,
|
580 | * but can be used to validate the included logs.
|
581 | */
|
582 | readonly logsBloom: string;
|
583 | /**
|
584 | * The actual amount of gas used by this transaction.
|
585 | *
|
586 | * When creating a transaction, the amount of gas that will be used can
|
587 | * only be approximated, but the sender must pay the gas fee for the
|
588 | * entire gas limit. After the transaction, the difference is refunded.
|
589 | */
|
590 | readonly gasUsed: bigint;
|
591 | /**
|
592 | * The gas used for BLObs. See [[link-eip-4844]].
|
593 | */
|
594 | readonly blobGasUsed: null | bigint;
|
595 | /**
|
596 | * The amount of gas used by all transactions within the block for this
|
597 | * and all transactions with a lower ``index``.
|
598 | *
|
599 | * This is generally not useful for developers but can be used to
|
600 | * validate certain aspects of execution.
|
601 | */
|
602 | readonly cumulativeGasUsed: bigint;
|
603 | /**
|
604 | * The actual gas price used during execution.
|
605 | *
|
606 | * Due to the complexity of [[link-eip-1559]] this value can only
|
607 | * be caluclated after the transaction has been mined, snce the base
|
608 | * fee is protocol-enforced.
|
609 | */
|
610 | readonly gasPrice: bigint;
|
611 | /**
|
612 | * The price paid per BLOB in gas. See [[link-eip-4844]].
|
613 | */
|
614 | readonly blobGasPrice: null | bigint;
|
615 | /**
|
616 | * The [[link-eip-2718]] transaction type.
|
617 | */
|
618 | readonly type: number;
|
619 | /**
|
620 | * The status of this transaction, indicating success (i.e. ``1``) or
|
621 | * a revert (i.e. ``0``).
|
622 | *
|
623 | * This is available in post-byzantium blocks, but some backends may
|
624 | * backfill this value.
|
625 | */
|
626 | readonly status: null | number;
|
627 | /**
|
628 | * The root hash of this transaction.
|
629 | *
|
630 | * This is no present and was only included in pre-byzantium blocks, but
|
631 | * could be used to validate certain parts of the receipt.
|
632 | */
|
633 | readonly root: null | string;
|
634 | /**
|
635 | * @_ignore:
|
636 | */
|
637 | constructor(tx: TransactionReceiptParams, provider: Provider);
|
638 | /**
|
639 | * The logs for this transaction.
|
640 | */
|
641 | get logs(): ReadonlyArray<Log>;
|
642 | /**
|
643 | * Returns a JSON-compatible representation.
|
644 | */
|
645 | toJSON(): any;
|
646 | /**
|
647 | * @_ignore:
|
648 | */
|
649 | get length(): number;
|
650 | [Symbol.iterator](): Iterator<Log>;
|
651 | /**
|
652 | * The total fee for this transaction, in wei.
|
653 | */
|
654 | get fee(): bigint;
|
655 | /**
|
656 | * Resolves to the block this transaction occurred in.
|
657 | */
|
658 | getBlock(): Promise<Block>;
|
659 | /**
|
660 | * Resolves to the transaction this transaction occurred in.
|
661 | */
|
662 | getTransaction(): Promise<TransactionResponse>;
|
663 | /**
|
664 | * Resolves to the return value of the execution of this transaction.
|
665 | *
|
666 | * Support for this feature is limited, as it requires an archive node
|
667 | * with the ``debug_`` or ``trace_`` API enabled.
|
668 | */
|
669 | getResult(): Promise<string>;
|
670 | /**
|
671 | * Resolves to the number of confirmations this transaction has.
|
672 | */
|
673 | confirmations(): Promise<number>;
|
674 | /**
|
675 | * @_ignore:
|
676 | */
|
677 | removedEvent(): OrphanFilter;
|
678 | /**
|
679 | * @_ignore:
|
680 | */
|
681 | reorderedEvent(other?: TransactionResponse): OrphanFilter;
|
682 | }
|
683 | /**
|
684 | * A **MinedTransactionResponse** is an interface representing a
|
685 | * transaction which has been mined and allows for a type guard for its
|
686 | * property values being defined.
|
687 | */
|
688 | export interface MinedTransactionResponse extends TransactionResponse {
|
689 | /**
|
690 | * The block number this transaction occurred in.
|
691 | */
|
692 | blockNumber: number;
|
693 | /**
|
694 | * The block hash this transaction occurred in.
|
695 | */
|
696 | blockHash: string;
|
697 | /**
|
698 | * The date this transaction occurred on.
|
699 | */
|
700 | date: Date;
|
701 | }
|
702 | /**
|
703 | * A **TransactionResponse** includes all properties about a transaction
|
704 | * that was sent to the network, which may or may not be included in a
|
705 | * block.
|
706 | *
|
707 | * The [[TransactionResponse-isMined]] can be used to check if the
|
708 | * transaction has been mined as well as type guard that the otherwise
|
709 | * possibly ``null`` properties are defined.
|
710 | */
|
711 | export declare class TransactionResponse implements TransactionLike<string>, TransactionResponseParams {
|
712 | #private;
|
713 | /**
|
714 | * The provider this is connected to, which will influence how its
|
715 | * methods will resolve its async inspection methods.
|
716 | */
|
717 | readonly provider: Provider;
|
718 | /**
|
719 | * The block number of the block that this transaction was included in.
|
720 | *
|
721 | * This is ``null`` for pending transactions.
|
722 | */
|
723 | readonly blockNumber: null | number;
|
724 | /**
|
725 | * The blockHash of the block that this transaction was included in.
|
726 | *
|
727 | * This is ``null`` for pending transactions.
|
728 | */
|
729 | readonly blockHash: null | string;
|
730 | /**
|
731 | * The index within the block that this transaction resides at.
|
732 | */
|
733 | readonly index: number;
|
734 | /**
|
735 | * The transaction hash.
|
736 | */
|
737 | readonly hash: string;
|
738 | /**
|
739 | * The [[link-eip-2718]] transaction envelope type. This is
|
740 | * ``0`` for legacy transactions types.
|
741 | */
|
742 | readonly type: number;
|
743 | /**
|
744 | * The receiver of this transaction.
|
745 | *
|
746 | * If ``null``, then the transaction is an initcode transaction.
|
747 | * This means the result of executing the [[data]] will be deployed
|
748 | * as a new contract on chain (assuming it does not revert) and the
|
749 | * address may be computed using [[getCreateAddress]].
|
750 | */
|
751 | readonly to: null | string;
|
752 | /**
|
753 | * The sender of this transaction. It is implicitly computed
|
754 | * from the transaction pre-image hash (as the digest) and the
|
755 | * [[signature]] using ecrecover.
|
756 | */
|
757 | readonly from: string;
|
758 | /**
|
759 | * The nonce, which is used to prevent replay attacks and offer
|
760 | * a method to ensure transactions from a given sender are explicitly
|
761 | * ordered.
|
762 | *
|
763 | * When sending a transaction, this must be equal to the number of
|
764 | * transactions ever sent by [[from]].
|
765 | */
|
766 | readonly nonce: number;
|
767 | /**
|
768 | * The maximum units of gas this transaction can consume. If execution
|
769 | * exceeds this, the entries transaction is reverted and the sender
|
770 | * is charged for the full amount, despite not state changes being made.
|
771 | */
|
772 | readonly gasLimit: bigint;
|
773 | /**
|
774 | * The gas price can have various values, depending on the network.
|
775 | *
|
776 | * In modern networks, for transactions that are included this is
|
777 | * the //effective gas price// (the fee per gas that was actually
|
778 | * charged), while for transactions that have not been included yet
|
779 | * is the [[maxFeePerGas]].
|
780 | *
|
781 | * For legacy transactions, or transactions on legacy networks, this
|
782 | * is the fee that will be charged per unit of gas the transaction
|
783 | * consumes.
|
784 | */
|
785 | readonly gasPrice: bigint;
|
786 | /**
|
787 | * The maximum priority fee (per unit of gas) to allow a
|
788 | * validator to charge the sender. This is inclusive of the
|
789 | * [[maxFeeFeePerGas]].
|
790 | */
|
791 | readonly maxPriorityFeePerGas: null | bigint;
|
792 | /**
|
793 | * The maximum fee (per unit of gas) to allow this transaction
|
794 | * to charge the sender.
|
795 | */
|
796 | readonly maxFeePerGas: null | bigint;
|
797 | /**
|
798 | * The [[link-eip-4844]] max fee per BLOb gas.
|
799 | */
|
800 | readonly maxFeePerBlobGas: null | bigint;
|
801 | /**
|
802 | * The data.
|
803 | */
|
804 | readonly data: string;
|
805 | /**
|
806 | * The value, in wei. Use [[formatEther]] to format this value
|
807 | * as ether.
|
808 | */
|
809 | readonly value: bigint;
|
810 | /**
|
811 | * The chain ID.
|
812 | */
|
813 | readonly chainId: bigint;
|
814 | /**
|
815 | * The signature.
|
816 | */
|
817 | readonly signature: Signature;
|
818 | /**
|
819 | * The [[link-eip-2930]] access list for transaction types that
|
820 | * support it, otherwise ``null``.
|
821 | */
|
822 | readonly accessList: null | AccessList;
|
823 | /**
|
824 | * The [[link-eip-4844]] BLOb versioned hashes.
|
825 | */
|
826 | readonly blobVersionedHashes: null | Array<string>;
|
827 | /**
|
828 | * @_ignore:
|
829 | */
|
830 | constructor(tx: TransactionResponseParams, provider: Provider);
|
831 | /**
|
832 | * Returns a JSON-compatible representation of this transaction.
|
833 | */
|
834 | toJSON(): any;
|
835 | /**
|
836 | * Resolves to the Block that this transaction was included in.
|
837 | *
|
838 | * This will return null if the transaction has not been included yet.
|
839 | */
|
840 | getBlock(): Promise<null | Block>;
|
841 | /**
|
842 | * Resolves to this transaction being re-requested from the
|
843 | * provider. This can be used if you have an unmined transaction
|
844 | * and wish to get an up-to-date populated instance.
|
845 | */
|
846 | getTransaction(): Promise<null | TransactionResponse>;
|
847 | /**
|
848 | * Resolve to the number of confirmations this transaction has.
|
849 | */
|
850 | confirmations(): Promise<number>;
|
851 | /**
|
852 | * Resolves once this transaction has been mined and has
|
853 | * %%confirms%% blocks including it (default: ``1``) with an
|
854 | * optional %%timeout%%.
|
855 | *
|
856 | * This can resolve to ``null`` only if %%confirms%% is ``0``
|
857 | * and the transaction has not been mined, otherwise this will
|
858 | * wait until enough confirmations have completed.
|
859 | */
|
860 | wait(_confirms?: number, _timeout?: number): Promise<null | TransactionReceipt>;
|
861 | /**
|
862 | * Returns ``true`` if this transaction has been included.
|
863 | *
|
864 | * This is effective only as of the time the TransactionResponse
|
865 | * was instantiated. To get up-to-date information, use
|
866 | * [[getTransaction]].
|
867 | *
|
868 | * This provides a Type Guard that this transaction will have
|
869 | * non-null property values for properties that are null for
|
870 | * unmined transactions.
|
871 | */
|
872 | isMined(): this is MinedTransactionResponse;
|
873 | /**
|
874 | * Returns true if the transaction is a legacy (i.e. ``type == 0``)
|
875 | * transaction.
|
876 | *
|
877 | * This provides a Type Guard that this transaction will have
|
878 | * the ``null``-ness for hardfork-specific properties set correctly.
|
879 | */
|
880 | isLegacy(): this is (TransactionResponse & {
|
881 | accessList: null;
|
882 | maxFeePerGas: null;
|
883 | maxPriorityFeePerGas: null;
|
884 | });
|
885 | /**
|
886 | * Returns true if the transaction is a Berlin (i.e. ``type == 1``)
|
887 | * transaction. See [[link-eip-2070]].
|
888 | *
|
889 | * This provides a Type Guard that this transaction will have
|
890 | * the ``null``-ness for hardfork-specific properties set correctly.
|
891 | */
|
892 | isBerlin(): this is (TransactionResponse & {
|
893 | accessList: AccessList;
|
894 | maxFeePerGas: null;
|
895 | maxPriorityFeePerGas: null;
|
896 | });
|
897 | /**
|
898 | * Returns true if the transaction is a London (i.e. ``type == 2``)
|
899 | * transaction. See [[link-eip-1559]].
|
900 | *
|
901 | * This provides a Type Guard that this transaction will have
|
902 | * the ``null``-ness for hardfork-specific properties set correctly.
|
903 | */
|
904 | isLondon(): this is (TransactionResponse & {
|
905 | accessList: AccessList;
|
906 | maxFeePerGas: bigint;
|
907 | maxPriorityFeePerGas: bigint;
|
908 | });
|
909 | /**
|
910 | * Returns true if hte transaction is a Cancun (i.e. ``type == 3``)
|
911 | * transaction. See [[link-eip-4844]].
|
912 | */
|
913 | isCancun(): this is (TransactionResponse & {
|
914 | accessList: AccessList;
|
915 | maxFeePerGas: bigint;
|
916 | maxPriorityFeePerGas: bigint;
|
917 | maxFeePerBlobGas: bigint;
|
918 | blobVersionedHashes: Array<string>;
|
919 | });
|
920 | /**
|
921 | * Returns a filter which can be used to listen for orphan events
|
922 | * that evict this transaction.
|
923 | */
|
924 | removedEvent(): OrphanFilter;
|
925 | /**
|
926 | * Returns a filter which can be used to listen for orphan events
|
927 | * that re-order this event against %%other%%.
|
928 | */
|
929 | reorderedEvent(other?: TransactionResponse): OrphanFilter;
|
930 | /**
|
931 | * Returns a new TransactionResponse instance which has the ability to
|
932 | * detect (and throw an error) if the transaction is replaced, which
|
933 | * will begin scanning at %%startBlock%%.
|
934 | *
|
935 | * This should generally not be used by developers and is intended
|
936 | * primarily for internal use. Setting an incorrect %%startBlock%% can
|
937 | * have devastating performance consequences if used incorrectly.
|
938 | */
|
939 | replaceableTransaction(startBlock: number): TransactionResponse;
|
940 | }
|
941 | /**
|
942 | * An Orphan Filter allows detecting when an orphan block has
|
943 | * resulted in dropping a block or transaction or has resulted
|
944 | * in transactions changing order.
|
945 | *
|
946 | * Not currently fully supported.
|
947 | */
|
948 | export type OrphanFilter = {
|
949 | orphan: "drop-block";
|
950 | hash: string;
|
951 | number: number;
|
952 | } | {
|
953 | orphan: "drop-transaction";
|
954 | tx: {
|
955 | hash: string;
|
956 | blockHash: string;
|
957 | blockNumber: number;
|
958 | };
|
959 | other?: {
|
960 | hash: string;
|
961 | blockHash: string;
|
962 | blockNumber: number;
|
963 | };
|
964 | } | {
|
965 | orphan: "reorder-transaction";
|
966 | tx: {
|
967 | hash: string;
|
968 | blockHash: string;
|
969 | blockNumber: number;
|
970 | };
|
971 | other?: {
|
972 | hash: string;
|
973 | blockHash: string;
|
974 | blockNumber: number;
|
975 | };
|
976 | } | {
|
977 | orphan: "drop-log";
|
978 | log: {
|
979 | transactionHash: string;
|
980 | blockHash: string;
|
981 | blockNumber: number;
|
982 | address: string;
|
983 | data: string;
|
984 | topics: ReadonlyArray<string>;
|
985 | index: number;
|
986 | };
|
987 | };
|
988 | /**
|
989 | * A **TopicFilter** provides a struture to define bloom-filter
|
990 | * queries.
|
991 | *
|
992 | * Each field that is ``null`` matches **any** value, a field that is
|
993 | * a ``string`` must match exactly that value and ``array`` is
|
994 | * effectively an ``OR``-ed set, where any one of those values must
|
995 | * match.
|
996 | */
|
997 | export type TopicFilter = Array<null | string | Array<string>>;
|
998 | /**
|
999 | * An **EventFilter** allows efficiently filtering logs (also known as
|
1000 | * events) using bloom filters included within blocks.
|
1001 | */
|
1002 | export interface EventFilter {
|
1003 | address?: AddressLike | Array<AddressLike>;
|
1004 | topics?: TopicFilter;
|
1005 | }
|
1006 | /**
|
1007 | * A **Filter** allows searching a specific range of blocks for mathcing
|
1008 | * logs.
|
1009 | */
|
1010 | export interface Filter extends EventFilter {
|
1011 | /**
|
1012 | * The start block for the filter (inclusive).
|
1013 | */
|
1014 | fromBlock?: BlockTag;
|
1015 | /**
|
1016 | * The end block for the filter (inclusive).
|
1017 | */
|
1018 | toBlock?: BlockTag;
|
1019 | }
|
1020 | /**
|
1021 | * A **FilterByBlockHash** allows searching a specific block for mathcing
|
1022 | * logs.
|
1023 | */
|
1024 | export interface FilterByBlockHash extends EventFilter {
|
1025 | /**
|
1026 | * The blockhash of the specific block for the filter.
|
1027 | */
|
1028 | blockHash?: string;
|
1029 | }
|
1030 | /**
|
1031 | * A **ProviderEvent** provides the types of events that can be subscribed
|
1032 | * to on a [[Provider]].
|
1033 | *
|
1034 | * Each provider may include additional possible events it supports, but
|
1035 | * the most commonly supported are:
|
1036 | *
|
1037 | * **``"block"``** - calls the listener with the current block number on each
|
1038 | * new block.
|
1039 | *
|
1040 | * **``"error"``** - calls the listener on each async error that occurs during
|
1041 | * the event loop, with the error.
|
1042 | *
|
1043 | * **``"debug"``** - calls the listener on debug events, which can be used to
|
1044 | * troubleshoot network errors, provider problems, etc.
|
1045 | *
|
1046 | * **``transaction hash``** - calls the listener on each block after the
|
1047 | * transaction has been mined; generally ``.once`` is more appropriate for
|
1048 | * this event.
|
1049 | *
|
1050 | * **``Array``** - calls the listener on each log that matches the filter.
|
1051 | *
|
1052 | * [[EventFilter]] - calls the listener with each matching log
|
1053 | */
|
1054 | export type ProviderEvent = string | Array<string | Array<string>> | EventFilter | OrphanFilter;
|
1055 | /**
|
1056 | * A **Provider** is the primary method to interact with the read-only
|
1057 | * content on Ethereum.
|
1058 | *
|
1059 | * It allows access to details about accounts, blocks and transactions
|
1060 | * and the ability to query event logs and simulate contract execution.
|
1061 | *
|
1062 | * Account data includes the [balance](getBalance),
|
1063 | * [transaction count](getTransactionCount), [code](getCode) and
|
1064 | * [state trie storage](getStorage).
|
1065 | *
|
1066 | * Simulating execution can be used to [call](call),
|
1067 | * [estimate gas](estimateGas) and
|
1068 | * [get transaction results](getTransactionResult).
|
1069 | *
|
1070 | * The [[broadcastTransaction]] is the only method which allows updating
|
1071 | * the blockchain, but it is usually accessed by a [[Signer]], since a
|
1072 | * private key must be used to sign the transaction before it can be
|
1073 | * broadcast.
|
1074 | */
|
1075 | export interface Provider extends ContractRunner, EventEmitterable<ProviderEvent>, NameResolver {
|
1076 | /**
|
1077 | * The provider iteself.
|
1078 | *
|
1079 | * This is part of the necessary API for executing a contract, as
|
1080 | * it provides a common property on any [[ContractRunner]] that
|
1081 | * can be used to access the read-only portion of the runner.
|
1082 | */
|
1083 | provider: this;
|
1084 | /**
|
1085 | * Shutdown any resources this provider is using. No additional
|
1086 | * calls should be made to this provider after calling this.
|
1087 | */
|
1088 | destroy(): void;
|
1089 | /**
|
1090 | * Get the current block number.
|
1091 | */
|
1092 | getBlockNumber(): Promise<number>;
|
1093 | /**
|
1094 | * Get the connected [[Network]].
|
1095 | */
|
1096 | getNetwork(): Promise<Network>;
|
1097 | /**
|
1098 | * Get the best guess at the recommended [[FeeData]].
|
1099 | */
|
1100 | getFeeData(): Promise<FeeData>;
|
1101 | /**
|
1102 | * Get the account balance (in wei) of %%address%%. If %%blockTag%%
|
1103 | * is specified and the node supports archive access for that
|
1104 | * %%blockTag%%, the balance is as of that [[BlockTag]].
|
1105 | *
|
1106 | * @note On nodes without archive access enabled, the %%blockTag%% may be
|
1107 | * **silently ignored** by the node, which may cause issues if relied on.
|
1108 | */
|
1109 | getBalance(address: AddressLike, blockTag?: BlockTag): Promise<bigint>;
|
1110 | /**
|
1111 | * Get the number of transactions ever sent for %%address%%, which
|
1112 | * is used as the ``nonce`` when sending a transaction. If
|
1113 | * %%blockTag%% is specified and the node supports archive access
|
1114 | * for that %%blockTag%%, the transaction count is as of that
|
1115 | * [[BlockTag]].
|
1116 | *
|
1117 | * @note On nodes without archive access enabled, the %%blockTag%% may be
|
1118 | * **silently ignored** by the node, which may cause issues if relied on.
|
1119 | */
|
1120 | getTransactionCount(address: AddressLike, blockTag?: BlockTag): Promise<number>;
|
1121 | /**
|
1122 | * Get the bytecode for %%address%%.
|
1123 | *
|
1124 | * @note On nodes without archive access enabled, the %%blockTag%% may be
|
1125 | * **silently ignored** by the node, which may cause issues if relied on.
|
1126 | */
|
1127 | getCode(address: AddressLike, blockTag?: BlockTag): Promise<string>;
|
1128 | /**
|
1129 | * Get the storage slot value for %%address%% at slot %%position%%.
|
1130 | *
|
1131 | * @note On nodes without archive access enabled, the %%blockTag%% may be
|
1132 | * **silently ignored** by the node, which may cause issues if relied on.
|
1133 | */
|
1134 | getStorage(address: AddressLike, position: BigNumberish, blockTag?: BlockTag): Promise<string>;
|
1135 | /**
|
1136 | * Estimates the amount of gas required to execute %%tx%%.
|
1137 | */
|
1138 | estimateGas(tx: TransactionRequest): Promise<bigint>;
|
1139 | /**
|
1140 | * Simulate the execution of %%tx%%. If the call reverts, it will
|
1141 | * throw a [[CallExceptionError]] which includes the revert data.
|
1142 | */
|
1143 | call(tx: TransactionRequest): Promise<string>;
|
1144 | /**
|
1145 | * Broadcasts the %%signedTx%% to the network, adding it to the
|
1146 | * memory pool of any node for which the transaction meets the
|
1147 | * rebroadcast requirements.
|
1148 | */
|
1149 | broadcastTransaction(signedTx: string): Promise<TransactionResponse>;
|
1150 | /**
|
1151 | * Resolves to the block for %%blockHashOrBlockTag%%.
|
1152 | *
|
1153 | * If %%prefetchTxs%%, and the backend supports including transactions
|
1154 | * with block requests, all transactions will be included and the
|
1155 | * [[Block]] object will not need to make remote calls for getting
|
1156 | * transactions.
|
1157 | */
|
1158 | getBlock(blockHashOrBlockTag: BlockTag | string, prefetchTxs?: boolean): Promise<null | Block>;
|
1159 | /**
|
1160 | * Resolves to the transaction for %%hash%%.
|
1161 | *
|
1162 | * If the transaction is unknown or on pruning nodes which
|
1163 | * discard old transactions this resolves to ``null``.
|
1164 | */
|
1165 | getTransaction(hash: string): Promise<null | TransactionResponse>;
|
1166 | /**
|
1167 | * Resolves to the transaction receipt for %%hash%%, if mined.
|
1168 | *
|
1169 | * If the transaction has not been mined, is unknown or on
|
1170 | * pruning nodes which discard old transactions this resolves to
|
1171 | * ``null``.
|
1172 | */
|
1173 | getTransactionReceipt(hash: string): Promise<null | TransactionReceipt>;
|
1174 | /**
|
1175 | * Resolves to the result returned by the executions of %%hash%%.
|
1176 | *
|
1177 | * This is only supported on nodes with archive access and with
|
1178 | * the necessary debug APIs enabled.
|
1179 | */
|
1180 | getTransactionResult(hash: string): Promise<null | string>;
|
1181 | /**
|
1182 | * Resolves to the list of Logs that match %%filter%%
|
1183 | */
|
1184 | getLogs(filter: Filter | FilterByBlockHash): Promise<Array<Log>>;
|
1185 | /**
|
1186 | * Resolves to the address configured for the %%ensName%% or
|
1187 | * ``null`` if unconfigured.
|
1188 | */
|
1189 | resolveName(ensName: string): Promise<null | string>;
|
1190 | /**
|
1191 | * Resolves to the ENS name associated for the %%address%% or
|
1192 | * ``null`` if the //primary name// is not configured.
|
1193 | *
|
1194 | * Users must perform additional steps to configure a //primary name//,
|
1195 | * which is not currently common.
|
1196 | */
|
1197 | lookupAddress(address: string): Promise<null | string>;
|
1198 | /**
|
1199 | * Waits until the transaction %%hash%% is mined and has %%confirms%%
|
1200 | * confirmations.
|
1201 | */
|
1202 | waitForTransaction(hash: string, confirms?: number, timeout?: number): Promise<null | TransactionReceipt>;
|
1203 | /**
|
1204 | * Resolves to the block at %%blockTag%% once it has been mined.
|
1205 | *
|
1206 | * This can be useful for waiting some number of blocks by using
|
1207 | * the ``currentBlockNumber + N``.
|
1208 | */
|
1209 | waitForBlock(blockTag?: BlockTag): Promise<Block>;
|
1210 | }
|
1211 | //# sourceMappingURL=provider.d.ts.map |
\ | No newline at end of file |