ethers.js/docs/v5/api/utils/logger/index.html
2021-02-08 15:26:10 -05:00

164 lines
37 KiB
HTML

<!DOCTYPE html>
<html class="paged">
<head>
<title>Logging</title>
<link rel="stylesheet" type="text/css" href="/v5/static/style.css">
<meta property="og:title" content="Logging"/>
<meta property="og:description" content="Documentation for ethers, a complete, tiny and simple Ethereum library."/>
<meta property="og:image" content="/v5/static/social.jpg"/>
</head>
<body>
<div class="sidebar">
<div class="header">
<div class="logo"><a href="/v5/"><div class="image"></div><div class="name">ethers</div><div class="version">v5.0</div></a></div>
<div class="search"><form action="/v5/search/" method="GET"><input name="search" id="search" /></form><span class="search-icon">&#9906;</span></div>
</div>
<div class="toc"><div>
<div class="link title"><a href="/v5/">Documentation</a></div><div class="base show link depth-1"><a href="/v5/getting-started/">Getting Started</a></div><div class="base show link depth-1"><a href="/v5/concepts/">Ethereum Basics</a></div><div class="hide link depth-2"><a href="/v5/concepts/events/">Events</a></div><div class="hide link depth-2"><a href="/v5/concepts/gas/">Gas</a></div><div class="hide link depth-2"><a href="/v5/concepts/security/">Security</a></div><div class="hide link depth-2"><a href="/v5/concepts/best-practices/">Best Practices</a></div><div class="base show link depth-1"><a href="/v5/api-keys/">Provider API Keys</a></div><div class="base ancestor show link depth-1"><a href="/v5/api/">Application Programming Interface</a></div><div class="show link depth-2"><a href="/v5/api/providers/">Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/provider/">Provider</a></div><div class="hide link depth-3"><a href="/v5/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><div class="hide link depth-3"><a href="/v5/api/providers/api-providers/">API Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/other/">Other Providers</a></div><div class="hide link depth-3"><a href="/v5/api/providers/types/">Types</a></div><div class="show link depth-2"><a href="/v5/api/signer/">Signers</a></div><div class="show link depth-2"><a href="/v5/api/contract/">Contract Interaction</a></div><div class="hide link depth-3"><a href="/v5/api/contract/contract/">Contract</a></div><div class="hide link depth-3"><a href="/v5/api/contract/contract-factory/">ContractFactory</a></div><div class="hide link depth-3"><a href="/v5/api/contract/example/">Example: ERC-20 Contract</a></div><div class="ancestor show link depth-2"><a href="/v5/api/utils/">Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/abi/">Application Binary Interface</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/coder/">AbiCoder</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/formats/">ABI Formats</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/fragments/">Fragments</a></div><div class="hide link depth-4"><a href="/v5/api/utils/abi/interface/">Interface</a></div><div class="show link depth-3"><a href="/v5/api/utils/address/">Addresses</a></div><div class="show link depth-3"><a href="/v5/api/utils/bignumber/">BigNumber</a></div><div class="show link depth-3"><a href="/v5/api/utils/bytes/">Byte Manipulation</a></div><div class="show link depth-3"><a href="/v5/api/utils/constants/">Constants</a></div><div class="show link depth-3"><a href="/v5/api/utils/display-logic/">Display Logic and Input</a></div><div class="show link depth-3"><a href="/v5/api/utils/encoding/">Encoding Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/fixednumber/">FixedNumber</a></div><div class="show link depth-3"><a href="/v5/api/utils/hashing/">Hashing Algorithms</a></div><div class="show link depth-3"><a href="/v5/api/utils/hdnode/">HD Wallet</a></div><div class="myself ancestor ancestor show link depth-3"><a href="/v5/api/utils/logger/">Logging</a></div><div class="link show child depth-4"><a href="#Logger">Logger</a></div><div class="link show child depth-4"><a href="#errors">Errors</a></div><div class="link show child depth-4"><a href="#Logger-levels">Log Levels</a></div><div class="show link depth-3"><a href="/v5/api/utils/properties/">Property Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/signing-key/">Signing Key</a></div><div class="show link depth-3"><a href="/v5/api/utils/strings/">Strings</a></div><div class="show link depth-3"><a href="/v5/api/utils/transactions/">Transactions</a></div><div class="show link depth-3"><a href="/v5/api/utils/web/">Web Utilities</a></div><div class="show link depth-3"><a href="/v5/api/utils/wordlists/">Wordlists</a></div><div class="show link depth-2"><a href="/v5/api/other/">Other Libraries</a></div><div class="hide link depth-3"><a href="/v5/api/other/assembly/">Assembly</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/api/">Utilities</a></div><div class="hide link depth-4"><a href="/v5/api/other/assembly/ast/">Abstract Syntax Tree</a></div><div class="hide link depth-3"><a href="/v5/api/other/hardware/">Hardware Wallets</a></div><div class="show link depth-2"><a href="/v5/api/experimental/">Experimental</a></div><div class="base show link depth-1"><a href="/v5/cli/">Command Line Interfaces</a></div><div class="hide link depth-2"><a href="/v5/cli/ethers/">Sandbox Utility</a></div><div class="hide link depth-2"><a href="/v5/cli/asm/">Assembler</a></div><div class="hide link depth-2"><a href="/v5/cli/ens/">Ethereum Naming Service</a></div><div class="hide link depth-2"><a href="/v5/cli/typescript/">TypeScript</a></div><div class="hide link depth-2"><a href="/v5/cli/plugin/">Making Your Own</a></div><div class="base show link depth-1"><a href="/v5/cookbook/">Cookbook</a></div><div class="hide link depth-2"><a href="/v5/cookbook/react-native/">React Native (and ilk)</a></div><div class="base show link depth-1"><a href="/v5/migration/">Migration Guide</a></div><div class="hide link depth-2"><a href="/v5/migration/web3/">Migration: From Web3.js</a></div><div class="hide link depth-2"><a href="/v5/migration/ethers-v4/">Migration: From Ethers v4</a></div><div class="base show link depth-1"><a href="/v5/testing/">Testing</a></div><div class="base show link depth-1"><a href="/v5/contributing/">Contributing and Hacking</a></div><div class="base show link depth-1"><a href="/v5/other-resources/">Other Resources</a></div><div class="base show link depth-1"><a href="/v5/documentation/">Flatworm Docs</a></div><div class="base show link depth-1"><a href="/v5/license/">License and Copyright</a></div>
</div></div>
<div class="footer">
<a href="/v5/single-page/">Single Page</a>
</div>
</div>
<div class="content">
<div class="breadcrumbs"><a href="/v5/">Documentation</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<a href="/v5/api/">API</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<a href="/v5/api/utils/">Utilities</a>&nbsp;&nbsp;&raquo;&nbsp;&nbsp;<span class="current">Logging</span></div>
<a name="logging"></a><a name="logging"></a><h1 class="show-anchors"><div>Logging<div class="anchors"><a class="self" href="/v5/api/utils/logger/#logging"></a></div></div></h1><p>These are just a few simple logging utilities provided to simplify and standardize the error facilities across the Ethers library.</p>
<p>The <a href="/v5/api/utils/logger/#Logger">Logger</a> library has zero dependencies and is intentionally very light so it can be easily included in each library.</p>
<p>The <a href="/v5/api/utils/logger/#Logger--censorship">Censorship</a> functionality relies on one instance of the Ethers library being included. In large bundled packages or when <code class="inline">npm link</code> is used, this may not be the case. If you require this functionality, ensure that your bundling is configured properly.</p>
<a name="Logger"></a><a name="logging--Logger"></a><h2 class="show-anchors"><div>Logger<div class="anchors"><a class="self" href="/v5/api/utils/logger/#Logger"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L143">source</a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="modifier">new </span><span class="path">ethers</span><span class="symbol">.</span><span class="path">utils</span><span class="symbol">.</span><span class="method">Logger</span><span class="symbol">(</span> <span class="param">version</span> <span class="symbol">)</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L150">source</a></div></div><div class="body"><p>Create a new logger which will include <i>version</i> in all errors thrown.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="method">globalLogger</span><span class="symbol">(</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns"><a href="/v5/api/utils/logger/#Logger">Logger</a></span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L308">source</a></div></div><div class="body"><p>Returns the singleton global logger.</p>
</div></div><a name="logging--Logger--logging-output"></a><h3 class="show-anchors"><div>Logging Output<div class="anchors"><a class="self" href="/v5/api/utils/logger/#logging--Logger--logging-output"></a></div></div></h3>
<div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">debug</span><span class="symbol">(</span> ...<span class="param">args</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">void</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L167">source</a></div></div><div class="body"><p>Log debugging information.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">info</span><span class="symbol">(</span> ...<span class="param">args</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">void</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L171">source</a></div></div><div class="body"><p>Log generic information.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">warn</span><span class="symbol">(</span> ...<span class="param">args</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">void</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L175">source</a></div></div><div class="body"><p>Log warnings.</p>
</div></div><a name="logging--Logger--errors"></a><h3 class="show-anchors"><div>Errors<div class="anchors"><a class="self" href="/v5/api/utils/logger/#logging--Logger--errors"></a></div></div></h3><p>These functions honor the current <a href="/v5/api/utils/logger/#Logger--censorship">Censorship</a> and help create a standard error model for detecting and processing errors within Ethers.</p>
<div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">makeError</span><span class="symbol">(</span> <span class="param">message</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">code</span> = <span class="param">UNKNOWN_ERROR</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">params</span> <span class="symbol">]</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">Error</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L179">source</a></div></div><div class="body"><p>Create an Error object with <i>message</i> and an optional <i>code</i> and additional <i>params</i> set. This is useful when an error is needed to be rejected instead of thrown.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">throwError</span><span class="symbol">(</span> <span class="param">message</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">code</span> = <span class="param">UNKNOWN_ERROR</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">params</span> <span class="symbol">]</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">never</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L216">source</a></div></div><div class="body"><p>Throw an Error with <i>message</i> and an optional <i>code</i> and additional <i>params</i> set.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">throwArgumentError</span><span class="symbol">(</span> <span class="param">message</span> <span class="symbol">,</span> <span class="param">name</span> <span class="symbol">,</span> <span class="param">value</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">never</span><div class="anchors"><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L220">source</a></div></div><div class="body"><p>Throw an <a href="/v5/api/utils/logger/#errors--invalid-argument">INVALID_ARGUMENT</a> Error with <i>name</i> and <i>value</i>.</p>
</div></div><a name="logging--Logger--usage-validation"></a><h3 class="show-anchors"><div>Usage Validation<div class="anchors"><a class="self" href="/v5/api/utils/logger/#logging--Logger--usage-validation"></a></div></div></h3><p>There can be used to ensure various properties and actions are safe.</p>
<a name="Logger-checkAbstract"></a><div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">checkAbstract</span><span class="symbol">(</span> <span class="param">target</span> <span class="symbol">,</span> <span class="param">kind</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">void</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#Logger-checkAbstract"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L296">source</a></div></div><div class="body"><p>If <i>target</i> is <i>kind</i>, throws a <a href="/v5/api/utils/logger/#errors--unsupported-operation">UNSUPPORTED_OPERATION</a> error otherwise performs the same operations as <a href="/v5/api/utils/logger/#Logger-checkNew">checkNew</a>.</p>
<p>This is useful for ensuring abstract classes are not being instantiated.</p>
</div></div><a name="Logger-checkArgumentCount"></a><div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">checkArgumentCount</span><span class="symbol">(</span> <span class="param">count</span> <span class="symbol">,</span> <span class="param">expectedCount</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">message</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">void</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#Logger-checkArgumentCount"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L268">source</a></div></div><div class="body"><p>If <i>count</i> is not equal to <i>expectedCount</i>, throws a <a href="/v5/api/utils/logger/#errors--missing-argument">MISSING_ARGUMENT</a> or <a href="/v5/api/utils/logger/#errors--unexpected-argument">UNEXPECTED_ARGUMENT</a> error.</p>
</div></div><a name="Logger-checkNew"></a><div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">checkNew</span><span class="symbol">(</span> <span class="param">target</span> <span class="symbol">,</span> <span class="param">kind</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">void</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#Logger-checkNew"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L290">source</a></div></div><div class="body"><p>If <i>target</i> is not a valid <code class="inline">this</code> or <code class="inline">target</code> value, throw a <a href="/v5/api/utils/logger/#errors--missing-new">MISSING_NEW</a> error. This is useful to ensure callers of a Class are using <code class="inline">new</code>.</p>
</div></div><a name="Logger-checkNoralize"></a><div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">checkNormalize</span><span class="symbol">(</span> <span class="param">message</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">void</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#Logger-checkNoralize"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L237">source</a></div></div><div class="body"><p>Check that the environment has a correctly functioning <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize">String.normalize</a>. If not, a <a href="/v5/api/utils/logger/#errors--unsupported-operation">UNSUPPORTED_OPERATION</a> error is thrown.</p>
</div></div><a name="Logger-checkSafeUint53"></a><div class="property show-anchors"><div class="signature"><span class="path">logger</span><span class="symbol">.</span><span class="method">checkSafeUint53</span><span class="symbol">(</span> <span class="param">value</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">message</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">void</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#Logger-checkSafeUint53"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L246">source</a></div></div><div class="body"><p>If <i>value</i> is not safe as a <a href="https://en.wikipedia.org/wiki/Double-precision_floating-point_format">JavaScript number</a>, throws a <a href="/v5/api/utils/logger/#errors--numeric-fault">NUMERIC_FAULT</a> error.</p>
</div></div><a name="Logger--censorship"></a><a name="logging--Logger--Logger--censorship"></a><h3 class="show-anchors"><div>Censorship<div class="anchors"><a class="self" href="/v5/api/utils/logger/#Logger--censorship"></a></div></div></h3>
<a name="Logger-setCensorship"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="method">setCensorship</span><span class="symbol">(</span> <span class="param">censor</span> <span class="symbol">[</span> <span class="symbol">,</span> <span class="param">permanent</span> = <span class="param">false</span> <span class="symbol">]</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">void</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#Logger-setCensorship"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L313">source</a></div></div><div class="body"><p>Set error censorship, optionally preventing errors from being uncensored.</p>
<p>In production applications, this prevents any error from leaking information by masking the message and values of errors.</p>
<p>This can impact debugging, making it substantially more difficult.</p>
</div></div><a name="Logger-setLogLevel"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="method">setLogLevel</span><span class="symbol">(</span> <span class="param">logLevel</span> <span class="symbol">)</span> <span class="arrow">&rArr;</span> <span class="returns">void</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#Logger-setLogLevel"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/master/packages/logger/src.ts/index.ts#L331">source</a></div></div><div class="body"><p>Set the log level, to suppress logging output below a <a href="/v5/api/utils/logger/#Logger-levels">particular log level</a>.</p>
</div></div><a name="errors"></a><a name="logging--errors"></a><h2 class="show-anchors"><div>Errors<div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors"></a></div></div></h2><p>Every error in Ethers has a <code class="inline">code</code> value, which is a string that will match one of the following error codes.</p>
<a name="errors-generic"></a><a name="logging--errors--errors-generic"></a><h3 class="show-anchors"><div>Generic Error Codes<div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors-generic"></a></div></div></h3>
<a name="errors--not-implemented"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">NOT_IMPLEMENTED</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--not-implemented"></a></div></div><div class="body"><p>The operation is not implemented. This may occur when calling a method on a sub-class that has not fully implemented its abstract superclass.</p>
</div></div><a name="errors--server-error"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">SERVER_ERROR</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--server-error"></a></div></div><div class="body"><p>There was an error communicating with a server.</p>
<p>This may occur for a number of reasons, for example:</p>
<p><ul><li>a <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS">CORS</a> issue; this is quite often the problem and also the hardest to diagnose and fix, so it is very beneficial to familiarize yourself with CORS; some backends allow you configure your CORS, such as the geth command-line or conifguration files or the INFURA and Alchemy dashboards by specifing allowed Origins, methods, etc. </li><li>an SSL issue; for example, if you are trying to connect to a local node via HTTP but are serving the content from a secure HTTPS website </li><li>a link issue; a firewall is preventing the traffic from reaching the server </li><li>a server issue; the server is down, or is returning 500 error codes </li><li>a backend DDoS mitigation proxy; for example, Etherscan operates behind a Cloudflare proxy, which will block traffic if the request is sent via specific User Agents or the client fingerprint is detected as a bot in some cases </li></ul></p>
</div></div><a name="errors--timeout"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">TIMEOUT</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--timeout"></a></div></div><div class="body"><p>A timeout occurred.</p>
</div></div><a name="errors--unknown-error"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">UNKNOWN_ERROR</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--unknown-error"></a></div></div><div class="body"><p>A generic unknown error.</p>
</div></div><a name="errors--unsupported-operation"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">UNSUPPORTED_OPERATION</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--unsupported-operation"></a></div></div><div class="body"><p>The operation is not supported.</p>
<p>This can happen for a variety reasons, for example:</p>
<p><ul><li>Some backends do not support certain operations; such as passing a blockTag to an <a href="/v5/api/providers/api-providers/#EtherscanProvider">EtherscanProvider</a> for <a href="/v5/api/providers/provider/#Provider-call">call</a> </li><li>A <a href="/v5/api/contract/contract/">Contract</a> object connected to <a href="/v5/api/providers/provider/">Provider</a> (instead of a <a href="/v5/api/signer/#Signer">Signer</a>) cannot <a href="/v5/api/signer/#Signer-signTransaction">sign</a> or <a href="/v5/api/signer/#Signer-sendTransaction">send</a> transactions </li><li>a <a href="/v5/api/contract/contract/">Contract</a> connected to a <a href="/v5/api/signer/#Signer">Signer</a> without a <a href="/v5/api/providers/provider/">Provider</a> is write-only and cannot estimate gas or execute static calls </li></ul></p>
</div></div><a name="errors-safety"></a><a name="logging--errors--errors-safety"></a><h3 class="show-anchors"><div>Safety Error Codes<div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors-safety"></a></div></div></h3>
<a name="errors--buffer-overrun"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">BUFFER_OVERRUN</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--buffer-overrun"></a></div></div><div class="body"><p>The amount of data needed is more than the amount of data required, which would cause the data buffer to read past its end.</p>
<p>This can occur if a contract erroneously returns invalid ABI-encoded data or RLP data is malformed.</p>
</div></div><a name="errors--numeric-fault"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">NUMERIC_FAULT</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--numeric-fault"></a></div></div><div class="body"><p>There was an invalid operation done on numeric values.</p>
<p>Common cases of this occur when there is <a href="https://en.wikipedia.org/wiki/Integer_overflow">overflow</a>, <a href="https://en.wikipedia.org/wiki/Arithmetic_underflow">arithmetic underflow</a> in fixed numeric types or division by zero.</p>
</div></div><a name="errors-usage"></a><a name="logging--errors--errors-usage"></a><h3 class="show-anchors"><div>Usage Error Codes<div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors-usage"></a></div></div></h3>
<a name="errors--invalid-argument"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">INVALID_ARGUMENT</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--invalid-argument"></a></div></div><div class="body"><p>The type or value of an argument is invalid. This will generally also include the <code class="inline">name</code> and <code class="inline">value</code> of the argument. Any function which accepts sensitive data (such as a private key) will include the string <code class="inline">"[[REDACTED]]"</code> instead of the value passed in.</p>
</div></div><a name="errors--missing-argument"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">MISSING_ARGUMENT</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--missing-argument"></a></div></div><div class="body"><p>An expected parameter was not specified.</p>
</div></div><a name="errors--missing-new"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">MISSING_NEW</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--missing-new"></a></div></div><div class="body"><p>An object is a Class, but is not being called with <code class="inline">new</code>.</p>
</div></div><a name="errors--unexpected-argument"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">UNEXPECTED_ARGUMENT</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--unexpected-argument"></a></div></div><div class="body"><p>Too many parameters we passed into a function.</p>
</div></div><a name="errors-ethereum"></a><a name="logging--errors--errors-ethereum"></a><h3 class="show-anchors"><div>Ethereum Error Codes<div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors-ethereum"></a></div></div></h3>
<a name="errors--call-exception"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">CALL_EXCEPTION</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--call-exception"></a></div></div><div class="body"><p>An attempt to call a blockchain contract (getter) resulted in a revert or other error, such as insufficient gas (out-of-gas) or an invalid opcode. This can also occur during gas estimation or if waiting for a <a href="/v5/api/providers/types/#providers-TransactionReceipt">TransactionReceipt</a> which failed during execution.</p>
<p>Consult the contract to determine the cause, such as a failed condition in a <code class="inline">require</code> statement. The <code class="inline">reason</code> property may provide more context for the cause of this error.</p>
</div></div><a name="errors--insufficient-funds"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">INSUFFICIENT_FUNDS</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--insufficient-funds"></a></div></div><div class="body"><p>The account is attempting to make a transaction which costs more than is available.</p>
<p>A sending account must have enough ether to pay for the value, the gas limit (at the gas price) as well as the intrinsic cost of data. The intrinsic cost of data is 4 gas for each zero byte and 68 gas for each non-zero byte, as well as 35000 gas if a transaction contains no <code class="inline">to</code> property and is therefore expected to create a new account.</p>
</div></div><a name="errors--network"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">NETWORK_ERROR</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--network"></a></div></div><div class="body"><p>An Ethereum network validation error, such as an invalid chain ID.</p>
</div></div><a name="errors--nonce-expired"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">NONCE_EXPIRED</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--nonce-expired"></a></div></div><div class="body"><p>The nonce being specified has already been used in a mined transaction.</p>
</div></div><a name="errors--replacement-underpriced"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">REPLACEMENT_UNDERPRICED</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--replacement-underpriced"></a></div></div><div class="body"><p>When replacing a transaction, by using a nonce which has already been sent to the network, but which has not been mined yet the new transaction must specify a higher gas price.</p>
<p>This error occurs when the gas price is insufficient to <i>bribe</i> the transaction pool to prefer the new transaction over the old one. Generally, the new gas price should be about 50% + 1 wei more, so if a gas price of 10 gwei was used, the replacement should be 15.000000001 gwei. This is not enforced by the protocol, as it deals with unmined transactions, and can be configured by each node, however to ensure a transaction is propagated to a miner it is best practice to follow the defaults most nodes have enabled.</p>
</div></div><a name="errors--unpredicatable-gas-limit"></a><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">errors</span><span class="symbol">.</span><span class="method">UNPREDICTABLE_GAS_LIMIT</span><div class="anchors"><a class="self" href="/v5/api/utils/logger/#errors--unpredicatable-gas-limit"></a></div></div><div class="body"><p>When estimating the required amount of gas for a transaction, a node is queried for its best guess.</p>
<p>If a node is unable (or unwilling) to predict the cost, this error occurs.</p>
<p>The best remedy for this situation is to specify a gas limit in the transaction manually.</p>
<p>This error can also indicate that the transaction is expected to fail regardless, if for example an account with no tokens is attempting to send a token.</p>
</div></div><a name="Logger-levels"></a><a name="logging--Logger-levels"></a><h2 class="show-anchors"><div>Log Levels<div class="anchors"><a class="self" href="/v5/api/utils/logger/#Logger-levels"></a></div></div></h2>
<div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">levels</span><span class="symbol">.</span><span class="method">DEBUG</span><div class="anchors"></div></div><div class="body"><p>Log all output, including debugging information.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">levels</span><span class="symbol">.</span><span class="method">INFO</span><div class="anchors"></div></div><div class="body"><p>Only log output for informational, warnings and errors.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">levels</span><span class="symbol">.</span><span class="method">WARNING</span><div class="anchors"></div></div><div class="body"><p>Only log output for warnings and errors.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">levels</span><span class="symbol">.</span><span class="method">ERROR</span><div class="anchors"></div></div><div class="body"><p>Only log output for errors.</p>
</div></div><div class="property show-anchors"><div class="signature"><span class="path">Logger</span><span class="symbol">.</span><span class="path">levels</span><span class="symbol">.</span><span class="method">OFF</span><div class="anchors"></div></div><div class="body"><p>Do not output any logs.</p>
</div></div>
<div class="footer">
<div class="nav previous"><a href="/v5/api/utils/hdnode/"><span class="arrow">&larr;</span>HD Wallet</a></div>
<div class="nav next"><a href="/v5/api/utils/properties/">Property Utilities<span class="arrow">&rarr;</span></a></div>
</div>
<div class="copyright">The content of this site is licensed under the <a href="https://choosealicense.com/licenses/cc-by-4.0/">Creative Commons License</a>. Generated on February 8, 2021, 3:25pm.</div>
</div>
<script src="/v5/static/script.js" type="text/javascript"></script>
<!--EXTRASCRIPT-->
</body>
</html>