@@ -48,47 +48,46 @@ Throw an Error with //message// and an optional //code// and
48
48
additional //params// set.
49
49
50
50
_property: logger.throwArgumentError(message, name, value) => never @SRC<logger>
51
- Throw an [INVALID_ARGUMENT](errors-InvalidArgument) Error with //name// and //value//.
52
-
51
+ Throw an [INVALID_ARGUMENT](errors--invalid-argument) Error with //name// and //value//.
53
52
54
53
_heading: Usage Validation
55
54
56
55
There can be used to ensure various properties and actions are safe.
57
56
58
- _property: logger.checkAbstract(target, kind) => void @SRC<logger>
59
- Checks that //target// is not //kind// and performs the same operations
60
- as ``checkNew``. This is useful for ensuring abstract classes are not
61
- being instantiated.
57
+ _property: logger.checkAbstract(target, kind) => void @<Logger-checkAbstract> @SRC<logger>
58
+ If //target// is //kind//, throws a [UNSUPPORTED_OPERATION](errors--unsupported-operation) error
59
+ otherwise performs the same operations as [checkNew](Logger-checkNew).
60
+
61
+ This is useful for ensuring abstract classes are not being instantiated.
62
62
63
- _property: logger.checkArgumentCount(count, expectedCount [ , message) => void @SRC<logger>
64
- If //count// is not equal to //expectedCount//, throws a [MISSING_ARGUMENT](errors-MissingArgument )
65
- or [UNEXPECTED_ARGUMENT](errors-UnexpectedArgument ) error.
63
+ _property: logger.checkArgumentCount(count, expectedCount [ , message) => void @<Logger-checkArgumentCount> @ SRC<logger>
64
+ If //count// is not equal to //expectedCount//, throws a [MISSING_ARGUMENT](errors--missing-argument )
65
+ or [UNEXPECTED_ARGUMENT](errors--unexpected-argument ) error.
66
66
67
- _property: logger.checkNew(target, kind) => void @SRC<logger>
67
+ _property: logger.checkNew(target, kind) => void @<Logger-checkNew> @ SRC<logger>
68
68
If //target// is not a valid ``this`` or ``target`` value, throw a
69
- [MISSING_NEW](errors-MissingNew ) error. This is useful to ensure
69
+ [MISSING_NEW](errors--missing-new ) error. This is useful to ensure
70
70
callers of a Class are using ``new``.
71
71
72
- _property: logger.checkNormalize(message) => void @SRC<logger>
72
+ _property: logger.checkNormalize(message) => void @<Logger-checkNoralize> @ SRC<logger>
73
73
Check that the environment has a correctly functioning [[link-js-normalize]]. If not, a
74
- [UNSUPPORTED_OPERATION](errors-UnsupportedOperation ) error is thrown.
74
+ [UNSUPPORTED_OPERATION](errors--unsupported-operation ) error is thrown.
75
75
76
- _property: logger.checkSafeUint53(value [, message ]) => void @SRC<logger>
76
+ _property: logger.checkSafeUint53(value [, message ]) => void @<Logger-checkSafeUint53> @ SRC<logger>
77
77
If //value// is not safe as a [JavaScript number](link-wiki-ieee754), throws a
78
- [NUMERIC_FAULT](errors-NumericFault) error.
79
-
78
+ [NUMERIC_FAULT](errors--numeric-fault) error.
80
79
81
80
_heading: Censorship @<Logger--censorship>
82
81
83
- _property: Logger.setCensorship(censor [ , permanent = false ]) => void @SRC<logger>
82
+ _property: Logger.setCensorship(censor [ , permanent = false ]) => void @<Logger-setCensorship> @ SRC<logger>
84
83
Set error censorship, optionally preventing errors from being uncensored.
85
84
86
85
In production applications, this prevents any error from leaking information
87
86
by masking the message and values of errors.
88
87
89
88
This can impact debugging, making it substantially more difficult.
90
89
91
- _property: Logger.setLogLevel(logLevel) => void @SRC<logger>
90
+ _property: Logger.setLogLevel(logLevel) => void @<Logger-setLogLevel> @ SRC<logger>
92
91
Set the log level, to suppress logging output below a [particular log level](Logger-levels).
93
92
94
93
@@ -98,86 +97,126 @@ Every error in Ethers has a ``code`` value, which is a string that will
98
97
match one of the following error codes.
99
98
100
99
101
- _heading: Generic Error Codes
100
+ _heading: Generic Error Codes @<errors-generic>
102
101
103
- _property: Logger.errors.NOT_IMPLEMENTED
104
- The operation is not implemented.
102
+ _property: Logger.errors.NOT_IMPLEMENTED @<errors--not-implemented>
103
+ The operation is not implemented. This may occur when calling a method
104
+ on a sub-class that has not fully implemented its abstract superclass.
105
105
106
- _property: Logger.errors.SERVER_ERROR
106
+ _property: Logger.errors.SERVER_ERROR @<errors--server-error>
107
107
There was an error communicating with a server.
108
108
109
- _property: Logger.errors.TIMEOUT @<errors-Timeout>
109
+ This may occur for a number of reasons, for example:
110
+
111
+ - a [CORS](link-cors) issue; this is quite often the problem and also the
112
+ hardest to diagnose and fix, so it is very beneficial to familiarize
113
+ yourself with CORS; some backends allow you configure your CORS, such as
114
+ the geth command-line or conifguration files or the INFURA and Alchemy
115
+ dashboards by specifing allowed Origins, methods, etc.
116
+ - an SSL issue; for example, if you are trying to connect to a local node via
117
+ HTTP but are serving the content from a secure HTTPS website
118
+ - a link issue; a firewall is preventing the traffic from reaching the server
119
+ - a server issue; the server is down, or is returning 500 error codes
120
+ - a backend DDoS mitigation proxy; for example, Etherscan operates behind a
121
+ Cloudflare proxy, which will block traffic if the request is sent via
122
+ specific User Agents or the client fingerprint is detected as a bot in some
123
+ cases
124
+
125
+ _property: Logger.errors.TIMEOUT @<errors--timeout>
110
126
A timeout occurred.
111
127
112
- _property: Logger.errors.UNKNOWN_ERROR @<errors-UnknownError >
128
+ _property: Logger.errors.UNKNOWN_ERROR @<errors--unknown-error >
113
129
A generic unknown error.
114
130
115
- _property: Logger.errors.UNSUPPORTED_OPERATION @<errors-UnsupportedOperation >
131
+ _property: Logger.errors.UNSUPPORTED_OPERATION @<errors--unsupported-operation >
116
132
The operation is not supported.
117
133
134
+ This can happen for a variety reasons, for example:
135
+
136
+ - Some backends do not support certain operations; such as passing a blockTag
137
+ to an [[EtherscanProvider]] for [call](Provider-call)
138
+ - A [[Contract]] object connected to [[Provider]] (instead of a [[Signer]]) cannot
139
+ [sign](Signer-signTransaction) or [send](Signer-sendTransaction) transactions
140
+ - a [[Contract]] connected to a [[Signer]] without a [[Provider]] is write-only
141
+ and cannot estimate gas or execute static calls
118
142
119
- _heading: Safety Error Codes
120
143
121
- _property: Logger.errors.BUFFER_OVERRUN
144
+ _heading: Safety Error Codes @<errors-safety>
145
+
146
+ _property: Logger.errors.BUFFER_OVERRUN @<errors--buffer-overrun>
122
147
The amount of data needed is more than the amount of data required,
123
148
which would cause the data buffer to read past its end.
124
149
125
- _property: Logger.errors.NUMERIC_FAULT @<errors-NumericFault>
150
+ This can occur if a contract erroneously returns invalid ABI-encoded
151
+ data or RLP data is malformed.
152
+
153
+ _property: Logger.errors.NUMERIC_FAULT @<errors--numeric-fault>
126
154
There was an invalid operation done on numeric values.
127
155
128
156
Common cases of this occur when there is [[link-wiki-overflow]],
129
157
[[link-wiki-underflow]] in fixed numeric types or division by zero.
130
158
131
159
132
- _heading: Usage Error Codes
160
+ _heading: Usage Error Codes @<errors-usage>
133
161
134
- _property: Logger.errors.INVALID_ARGUMENT @<errors-InvalidArgument >
162
+ _property: Logger.errors.INVALID_ARGUMENT @<errors--invalid-argument >
135
163
The type or value of an argument is invalid. This will generally also
136
164
include the ``name`` and ``value`` of the argument. Any function which
137
165
accepts sensitive data (such as a private key) will include the string
138
- ``[\[REDACTED]\]`` instead of the value passed in.
166
+ ``" [\[REDACTED]\]" `` instead of the value passed in.
139
167
140
- _property: Logger.errors.MISSING_ARGUMENT @<errors-MissingArgument >
168
+ _property: Logger.errors.MISSING_ARGUMENT @<errors--missing-argument >
141
169
An expected parameter was not specified.
142
170
143
- _property: Logger.errors.MISSING_NEW @<errors-MissingNew >
144
- An object is a Class, but is now being called with ``new``.
171
+ _property: Logger.errors.MISSING_NEW @<errors--missing-new >
172
+ An object is a Class, but is not being called with ``new``.
145
173
146
- _property: Logger.errors.UNEXPECTED_ARGUMENT @<errors-UnexpectedArgument >
174
+ _property: Logger.errors.UNEXPECTED_ARGUMENT @<errors--unexpected-argument >
147
175
Too many parameters we passed into a function.
148
176
149
177
150
- _heading: Ethereum Error Codes
178
+ _heading: Ethereum Error Codes @<errors-ethereum>
151
179
152
- _property: Logger.errors.CALL_EXCEPTION
180
+ _property: Logger.errors.CALL_EXCEPTION @<errors--call-exception>
153
181
An attempt to call a blockchain contract (getter) resulted in a
154
- revert or other error.
182
+ revert or other error, such as insufficient gas (out-of-gas) or an
183
+ invalid opcode. This can also occur during gas estimation or if
184
+ waiting for a [[providers-TransactionReceipt]] which failed during execution.
185
+
186
+ Consult the contract to determine the cause, such as a failed condition
187
+ in a ``require`` statement. The ``reason`` property may provide more
188
+ context for the cause of this error.
155
189
156
- _property: Logger.errors.INSUFFICIENT_FUNDS
190
+ _property: Logger.errors.INSUFFICIENT_FUNDS @<errors--insufficient-funds>
157
191
The account is attempting to make a transaction which costs more than is
158
192
available.
159
193
160
194
A sending account must have enough ether to pay for the value, the gas limit
161
195
(at the gas price) as well as the intrinsic cost of data. The intrinsic cost
162
- of data is 4 gas for each zero byte and 68 gas for each non-zero byte.
196
+ of data is 4 gas for each zero byte and 68 gas for each non-zero byte, as well
197
+ as 35000 gas if a transaction contains no ``to`` property and is therefore
198
+ expected to create a new account.
163
199
164
- _property: Logger.errors.NETWORK_ERROR
200
+ _property: Logger.errors.NETWORK_ERROR @<errors--network>
165
201
An Ethereum network validation error, such as an invalid chain ID.
166
202
167
- _property: Logger.errors.NONCE_EXPIRED
203
+ _property: Logger.errors.NONCE_EXPIRED @<errors--nonce-expired>
168
204
The nonce being specified has already been used in a mined transaction.
169
205
170
- _property: Logger.errors.REPLACEMENT_UNDERPRICED
206
+ _property: Logger.errors.REPLACEMENT_UNDERPRICED @<errors--replacement-underpriced>
171
207
When replacing a transaction, by using a nonce which has already been sent to
172
208
the network, but which has not been mined yet the new transaction must specify
173
209
a higher gas price.
174
210
175
211
This error occurs when the gas price is insufficient to //bribe// the transaction
176
212
pool to prefer the new transaction over the old one. Generally, the new gas price
177
213
should be about 50% + 1 wei more, so if a gas price of 10 gwei was used, the
178
- replacement should be 15.000000001 gwei.
214
+ replacement should be 15.000000001 gwei. This is not enforced by the protocol, as
215
+ it deals with unmined transactions, and can be configured by each node, however
216
+ to ensure a transaction is propagated to a miner it is best practice to follow
217
+ the defaults most nodes have enabled.
179
218
180
- _property: Logger.errors.UNPREDICTABLE_GAS_LIMIT
219
+ _property: Logger.errors.UNPREDICTABLE_GAS_LIMIT @<errors--unpredicatable-gas-limit>
181
220
When estimating the required amount of gas for a transaction, a node is queried for
182
221
its best guess.
183
222
0 commit comments