52 lines
34 KiB
HTML
52 lines
34 KiB
HTML
<html><head><title>Byte Manipulation</title><link rel="stylesheet" type="text/css" href="/static/style.css"></head><body><div class="sidebar"><div class="header"><div class="logo"><a href="/"><div class="image"></div><div class="name">ethers</div><div class="version">v5.0-beta</div></a></div></div><div class="toc"><div><div class="link title"><a href="/">Documentation</a></div><div class="base show link depth-1"><a href="/getting-started/">Getting Started</a></div><div class="hide link depth-2"><a href="/getting-started/#installing">Installing</a></div><div class="hide link depth-2"><a href="/getting-started/#importing">Importing</a></div><div class="base show link depth-1"><a href="/concepts/">Concepts</a></div><div class="hide link depth-2"><a href="/concepts/events/">Events</a></div><div class="hide link depth-3"><a href="/concepts/events/#solidity-topics">Solidity Topics</a></div><div class="hide link depth-2"><a href="/concepts/gas/">Gas</a></div><div class="hide link depth-3"><a href="/concepts/gas/#gas-price">Gas Price</a></div><div class="hide link depth-3"><a href="/concepts/gas/#gas-limit">Gas Limit</a></div><div class="base ancestor show link depth-1"><a href="/api/">Application Programming Interface</a></div><div class="show link depth-2"><a href="/api/contract/">Contracts</a></div><div class="hide link depth-3"><a href="/api/contract/#buckets">Buckets</a></div><div class="show link depth-2"><a href="/api/signer/">Signers</a></div><div class="hide link depth-3"><a href="/api/signer/#signer">Signer</a></div><div class="hide link depth-3"><a href="/api/signer/#wallet">Wallet</a></div><div class="hide link depth-3"><a href="/api/signer/#voidsigner">VoidSigner</a></div><div class="hide link depth-3"><a href="/api/signer/#externallyownedaccount">ExternallyOwnedAccount</a></div><div class="show link depth-2"><a href="/api/providers/">Providers</a></div><div class="hide link depth-3"><a href="/api/providers/provider/">Provider</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#accounts-methods">Accounts Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#blocks-methods">Blocks Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#ethereum-naming-service-(ens)-methods">Ethereum Naming Service (ENS) Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#logs-methods">Logs Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#network-status-methods">Network Status Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#transactions-methods">Transactions Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#event-emitter-methods">Event Emitter Methods</a></div><div class="hide link depth-4"><a href="/api/providers/provider/#inspection-methods">Inspection Methods</a></div><div class="hide link depth-3"><a href="/api/providers/jsonrpc-provider/">JsonRpcProvider</a></div><div class="hide link depth-4"><a href="/api/providers/jsonrpc-provider/#jsonrpcsigner">JsonRpcSigner</a></div><div class="hide link depth-4"><a href="/api/providers/jsonrpc-provider/#jsonrpcuncheckedsigner">JsonRpcUncheckedSigner</a></div><div class="hide link depth-3"><a href="/api/providers/api-providers/">API Providers</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#etherscanprovider">EtherscanProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#infuraprovider">InfuraProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#alchemyprovider">AlchemyProvider</a></div><div class="hide link depth-4"><a href="/api/providers/api-providers/#cloudfrontprovider">CloudfrontProvider</a></div><div class="hide link depth-3"><a href="/api/providers/other/">Other Providers</a></div><div class="hide link depth-4"><a href="/api/providers/other/#fallbackprovider">FallbackProvider</a></div><div class="hide link depth-4"><a href="/api/providers/other/#ipcprovider">IpcProvider</a></div><div class="hide link depth-4"><a href="/api/providers/other/#urljsonrpcprovider">UrlJsonRpcProvider</a></div><div class="hide link depth-4"><a href="/api/providers/other/#web3provider">Web3Provider</a></div><div class="hide link depth-3"><a href="/api/providers/types/">Types</a></div><div class="hide link depth-4"><a href="/api/providers/types/#network">Network</a></div><div class="hide link depth-4"><a href="/api/providers/types/#block">Block</a></div><div class="hide link depth-4"><a href="/api/providers/types/#events-and-logs">Events and Logs</a></div><div class="hide link depth-4"><a href="/api/providers/types/#transactions">Transactions</a></div><div class="ancestor show link depth-2"><a href="/api/utils/">Utilities</a></div><div class="show link depth-3"><a href="/api/utils/abi/">Application Binary Interface</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#formats">Formats</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#interface">Interface</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#fragment">Fragment</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#constructorfragment">ConstructorFragment</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#eventfragment">EventFragment</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#functionfragment">FunctionFragment</a></div><div class="hide link depth-4"><a href="/api/utils/abi/#paramtype">ParamType</a></div><div class="show link depth-3"><a href="/api/utils/address/">Addresses</a></div><div class="hide link depth-4"><a href="/api/utils/address/#address-formats">Address Formats</a></div><div class="hide link depth-4"><a href="/api/utils/address/#functions">Functions</a></div><div class="show link depth-3"><a href="/api/utils/bignumber/">BigNumber</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#types">Types</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#creating-instances">Creating Instances</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#methods">Methods</a></div><div class="hide link depth-4"><a href="/api/utils/bignumber/#notes">Notes</a></div><div class="myself ancestor ancestor show link depth-3"><a href="/api/utils/bytes/">Byte Manipulation</a></div><div class="child link depth-4"><a href="/api/utils/bytes/#types">Types</a></div><div class="child link depth-4"><a href="/api/utils/bytes/#inspection">Inspection</a></div><div class="child link depth-4"><a href="/api/utils/bytes/#converting-between-arrays-and-hexstrings">Converting between Arrays and Hexstrings</a></div><div class="child link depth-4"><a href="/api/utils/bytes/#array-manipulation">Array Manipulation</a></div><div class="child link depth-4"><a href="/api/utils/bytes/#hexstring-manipulation">Hexstring Manipulation</a></div><div class="child link depth-4"><a href="/api/utils/bytes/#signature-conversion">Signature Conversion</a></div><div class="child link depth-4"><a href="/api/utils/bytes/#random-bytes">Random Bytes</a></div><div class="show link depth-3"><a href="/api/utils/constants/">Constants</a></div><div class="hide link depth-4"><a href="/api/utils/constants/#bytes">Bytes</a></div><div class="hide link depth-4"><a href="/api/utils/constants/#strings">Strings</a></div><div class="hide link depth-4"><a href="/api/utils/constants/#bignumber">BigNumber</a></div><div class="show link depth-3"><a href="/api/utils/display-logic/">Display Logic and Input</a></div><div class="hide link depth-4"><a href="/api/utils/display-logic/#units">Units</a></div><div class="hide link depth-4"><a href="/api/utils/display-logic/#functions">Functions</a></div><div class="show link depth-3"><a href="/api/utils/encoding/">Encoding Utilities</a></div><div class="hide link depth-4"><a href="/api/utils/encoding/#base58">Base58</a></div><div class="hide link depth-4"><a href="/api/utils/encoding/#base64">Base64</a></div><div class="hide link depth-4"><a href="/api/utils/encoding/#recursive-length-prefix">Recursive-Length Prefix</a></div><div class="show link depth-3"><a href="/api/utils/fixednumber/">FixedNumber</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#creating-instances">Creating Instances</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#properties">Properties</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#methods">Methods</a></div><div class="hide link depth-4"><a href="/api/utils/fixednumber/#fixedformat">FixedFormat</a></div><div class="show link depth-3"><a href="/api/utils/hashing/">Hashing Algorithms</a></div><div class="hide link depth-4"><a href="/api/utils/hashing/#cryptographic-hashing">Cryptographic Hashing</a></div><div class="hide link depth-4"><a href="/api/utils/hashing/#common-hashing-helpers">Common Hashing Helpers</a></div><div class="hide link depth-4"><a href="/api/utils/hashing/#solidity-hashing-algorithms">Solidity Hashing Algorithms</a></div><div class="show link depth-3"><a href="/api/utils/hdnode/">HD Wallet</a></div><div class="hide link depth-4"><a href="/api/utils/hdnode/#types">Types</a></div><div class="hide link depth-4"><a href="/api/utils/hdnode/#hdnode">HDNode</a></div><div class="hide link depth-4"><a href="/api/utils/hdnode/#other-functions">Other Functions</a></div><div class="show link depth-3"><a href="/api/utils/logger/">Logger</a></div><div class="hide link depth-4"><a href="/api/utils/logger/#errors">Errors</a></div><div class="hide link depth-4"><a href="/api/utils/logger/#creating-instances">Creating instances</a></div><div class="show link depth-3"><a href="/api/utils/properties/">Property Utilities</a></div><div class="show link depth-3"><a href="/api/utils/signing-key/">Signing Key</a></div><div class="hide link depth-4"><a href="/api/utils/signing-key/#other-functions">Other Functions</a></div><div class="show link depth-3"><a href="/api/utils/strings/">Strings</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#bytes32string">Bytes32String</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#utf-8-strings">UTF-8 Strings</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#unicodenormalizationform">UnicodeNormalizationForm</a></div><div class="hide link depth-4"><a href="/api/utils/strings/#custom-utf-8-error-handling">Custom UTF-8 Error Handling</a></div><div class="show link depth-3"><a href="/api/utils/transactions/">Transactions</a></div><div class="hide link depth-4"><a href="/api/utils/transactions/#types">Types</a></div><div class="hide link depth-4"><a href="/api/utils/transactions/#functions">Functions</a></div><div class="show link depth-3"><a href="/api/utils/web/">Web Utilities</a></div><div class="show link depth-3"><a href="/api/utils/wordlists/">Wordlists</a></div><div class="hide link depth-4"><a href="/api/utils/wordlists/#wordlist">Wordlist</a></div><div class="hide link depth-4"><a href="/api/utils/wordlists/#languages">Languages</a></div><div class="show link depth-2"><a href="/api/other/">Other Libraries</a></div><div class="hide link depth-3"><a href="/api/other/assembly/">Assembly</a></div><div class="hide link depth-4"><a href="/api/other/assembly/dialect/">Ethers ASM Dialect</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#opcodes">Opcodes</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#labels">Labels</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#literals">Literals</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#comments">Comments</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#scopes">Scopes</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#data-segment">Data Segment</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#links">Links</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#stack-placeholders">Stack Placeholders</a></div><div class="hide link depth-5"><a href="/api/other/assembly/dialect/#evaluation-and-excution">Evaluation and Excution</a></div><div class="hide link depth-4"><a href="/api/other/assembly/api/">Utilities</a></div><div class="hide link depth-5"><a href="/api/other/assembly/api/#assembler">Assembler</a></div><div class="hide link depth-5"><a href="/api/other/assembly/api/#disassembler">Disassembler</a></div><div class="hide link depth-5"><a href="/api/other/assembly/api/#opcode">Opcode</a></div><div class="hide link depth-4"><a href="/api/other/assembly/ast/">Abstract Syntax Tree</a></div><div class="hide link depth-5"><a href="/api/other/assembly/ast/#types">Types</a></div><div class="hide link depth-5"><a href="/api/other/assembly/ast/#nodes">Nodes</a></div><div class="hide link depth-3"><a href="/api/other/hardware/">Hardware Wallets</a></div><div class="hide link depth-4"><a href="/api/other/hardware/#ledgersigner">LedgerSigner</a></div><div class="base show link depth-1"><a href="/cli/">Command Line Interfaces</a></div><div class="hide link depth-2"><a href="/cli/ethers/">Sandbox Utility</a></div><div class="hide link depth-3"><a href="/cli/ethers/#help">Help</a></div><div class="hide link depth-3"><a href="/cli/ethers/#examples">Examples</a></div><div class="hide link depth-2"><a href="/cli/asm/">Assembler</a></div><div class="hide link depth-3"><a href="/cli/asm/#help">Help</a></div><div class="hide link depth-3"><a href="/cli/asm/#example-input-files">Example Input Files</a></div><div class="hide link depth-3"><a href="/cli/asm/#assembler-examples">Assembler Examples</a></div><div class="hide link depth-3"><a href="/cli/asm/#disassembler-examples">Disassembler Examples</a></div><div class="hide link depth-2"><a href="/cli/ens/">ENS</a></div><div class="hide link depth-3"><a href="/cli/ens/#help">Help</a></div><div class="hide link depth-3"><a href="/cli/ens/#examples">Examples</a></div><div class="hide link depth-2"><a href="/cli/typescript/">TypeScript</a></div><div class="hide link depth-3"><a href="/cli/typescript/#help">Help</a></div><div class="hide link depth-3"><a href="/cli/typescript/#examples">Examples</a></div><div class="hide link depth-2"><a href="/cli/plugin/">Making Your Own</a></div><div class="hide link depth-3"><a href="/cli/plugin/#cli">CLI</a></div><div class="hide link depth-3"><a href="/cli/plugin/#plugin">Plugin</a></div><div class="hide link depth-3"><a href="/cli/plugin/#argparser">ArgParser</a></div><div class="base show link depth-1"><a href="/cookbook/">Cookbook</a></div><div class="base show link depth-1"><a href="/migration/">Migration Guide</a></div><div class="hide link depth-2"><a href="/migration/web3/">Migration: From Web3.js</a></div><div class="hide link depth-3"><a href="/migration/web3/#contracts">Contracts</a></div><div class="hide link depth-3"><a href="/migration/web3/#providers">Providers</a></div><div class="hide link depth-3"><a href="/migration/web3/#numbers">Numbers</a></div><div class="hide link depth-3"><a href="/migration/web3/#utilities">Utilities</a></div><div class="hide link depth-2"><a href="/migration/ethers-v4/">Migration: From Ethers v4</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#bignumber">BigNumber</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#contracts">Contracts</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#errors">Errors</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#interface">Interface</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#utilities">Utilities</a></div><div class="hide link depth-3"><a href="/migration/ethers-v4/#wallet">Wallet</a></div><div class="base show link depth-1"><a href="/testing/">Testing</a></div><div class="base show link depth-1"><a href="/contributing/">Contributing and Hacking</a></div><div class="hide link depth-2"><a href="/contributing/#building">Building</a></div><div class="base show link depth-1"><a href="/documentation/">Flatworm Docs</a></div><div class="hide link depth-2"><a href="/documentation/#fragments">Fragments</a></div><div class="hide link depth-2"><a href="/documentation/#markdown">Markdown</a></div><div class="hide link depth-2"><a href="/documentation/#configuration">Configuration</a></div><div class="hide link depth-2"><a href="/documentation/#extended-directive-functions">Extended Directive Functions</a></div><div class="base show link depth-1"><a href="/license/">License and Copyright</a></div></div></div></div><div class="content"><div class="breadcrumbs"><a href="/">Documentation</a> » <a href="/api/">Application Programming Interface</a> » <a href="/api/utils/">Utilities</a> » <span class="current">Byte Manipulation</span></div>
|
|
<a name="byte-manipulation"></a><h1 class="show-anchors"><div>Byte Manipulation<div class="anchors"><a class="self" href="#byte-manipulation"></a></div></div></h1>
|
|
<p>Tra la la...</p>
|
|
<a name="types"></a><h2 class="show-anchors"><div>Types<div class="anchors"><a class="self" href="#types"></a></div></div></h2>
|
|
|
|
<a name="bytes"></a><a name="bytes"></a><h3 class="show-anchors"><div>Bytes<div class="anchors"><a class="self" href="#bytes"></a></div></div></h3>
|
|
<p>A <b>Bytes</b> is any object which is an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array">Array</a> or <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray">TypedArray</a> with each value in the valid byte range (i.e. between 0 and 255 inclusive), or is an Object with a <code class="inline">length</code> property where each indexed property is in the valid byte range.</p>
|
|
<a name="byteslike"></a><a name="byteslike"></a><h3 class="show-anchors"><div>BytesLike<div class="anchors"><a class="self" href="#byteslike"></a></div></div></h3>
|
|
<p>A <b>BytesLike</b> can be either a <a href="/api/utils/bytes/#bytes">Bytes</a> or a <a href="/api/utils/bytes/#datahexstring">DataHexstring</a>.</p>
|
|
<a name="datahexstring"></a><a name="datahexstring"></a><h3 class="show-anchors"><div>DataHexstring<div class="anchors"><a class="self" href="#datahexstring"></a></div></div></h3>
|
|
<p>A <b>DataHexstring</b> is identical to a <a href="/api/utils/bytes/#hexstring">Hexstring</a> except that it has an even number of nibbles, and therefore is a valid representation of binary data as a string.</p>
|
|
<a name="hexstring"></a><a name="hexstring"></a><h3 class="show-anchors"><div>Hexstring<div class="anchors"><a class="self" href="#hexstring"></a></div></div></h3>
|
|
<p>A <b>Hexstring</b> is a string which has a <code class="inline">0x</code> prefix followed by any number of nibbles (i.e. case-insensitive hexidecumal characters, <code class="inline">0-9</code> and <code class="inline">a-f</code>).</p>
|
|
<a name="signature"></a><a name="signature"></a><h3 class="show-anchors"><div>Signature<div class="anchors"><a class="self" href="#signature"></a></div></div></h3>
|
|
<ul><li><b>r</b> and <b>s</b> — The x co-ordinate of <b>r</b> and the <b>s</b> value of the signature</li><li><b>v</b> — The parity of the y co-ordinate of <b>r</b></li><li><b>_vs</b> — The <a href="https://eips.ethereum.org/EIPS/eip-2098">compact representation</a> of the <b>s</b> and <b>v</b></li><li><b>recoveryParam</b> — The normalized (i.e. 0 or 1) value of <b>v</b></li></ul>
|
|
<a name="signature-flat"></a><a name="flat-format-signature"></a><h3 class="show-anchors"><div>Flat-Format Signature<div class="anchors"><a class="self" href="#signature-flat"></a></div></div></h3>
|
|
<p>A <b>Flat-Format Signature</b> is a common Signature format where the r, s and v are concanenated into a 65 byte (130 nibble) <a href="/api/utils/bytes/#datahexstring">DataHexstring</a>.</p>
|
|
<a name="signaturelike"></a><a name="signaturelike"></a><h3 class="show-anchors"><div>SignatureLike<div class="anchors"><a class="self" href="#signaturelike"></a></div></div></h3>
|
|
<p>A <b>SignatureLike</b> is similar to a <a href="/api/utils/bytes/#signature">Signature</a>, except redundant properties may be omitted or it may be a <a href="/api/utils/bytes/#signature-flat">Flat-Format Signature</a>.</p><p>For example, if <b>_vs</b> is specified, <b>s</b> and <b>v</b> may be omitted. Likewise, if <b>recoveryParam</b> is provided, <b>v</b> may be omitted (as in these cases the missing values can be computed).</p>
|
|
<a name="inspection"></a><h2 class="show-anchors"><div>Inspection<div class="anchors"><a class="self" href="#inspection"></a></div></div></h2>
|
|
|
|
<a name="utils-isbytes"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">isBytes</span> ( <span class="param">object</span> ) <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="self" href="#utils-isbytes"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L73">source</a></div></div><div class="body"><p>Returns true if and only if <i>object</i> is a valid <a href="/api/utils/bytes/#bytes">Bytes</a>.</p></div></div>
|
|
<a name="utils-isbyteslike"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">isBytesLike</span> ( <span class="param">object</span> ) <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="self" href="#utils-isbyteslike"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L69">source</a></div></div><div class="body"><p>Returns true if and only if <i>object</i> is a <a href="/api/utils/bytes/#bytes">Bytes</a> or <a href="/api/utils/bytes/#datahexstring">DataHexstring</a>.</p></div></div>
|
|
<a name="utils-ishexstring"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">isHexString</span> ( <span class="param">object</span> , [ <span class="param">length</span> ] ) <span class="arrow">⇒</span> <span class="returns">boolean</span><div class="anchors"><a class="self" href="#utils-ishexstring"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L184">source</a></div></div><div class="body"><p>Returns true if and only if <i>object</i> is a valid hex string. If <i>length</i> is specified and <i>object</i> is not a valid <a href="/api/utils/bytes/#datahexstring">DataHexstring</a> of <i>length</i> bytes, an InvalidArgument error is thrown.</p></div></div>
|
|
<a name="converting-between-arrays-and-hexstrings"></a><h2 class="show-anchors"><div>Converting between Arrays and Hexstrings<div class="anchors"><a class="self" href="#converting-between-arrays-and-hexstrings"></a></div></div></h2>
|
|
|
|
<a name="utils-arrayify"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">arrayify</span> ( <span class="param">datahexstringOrArrayish</span> [ , <span class="param">options</span> ] ) <span class="arrow">⇒</span> <span class="returns">Uint8Array</span><div class="anchors"><a class="self" href="#utils-arrayify"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L91">source</a></div></div><div class="body"><p>Converts <i>datahexstringOrArrayish</i> to a Uint8Array.</p></div></div>
|
|
<a name="utils-hexlify"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">hexlify</span> ( <span class="param">hexstringOrArrayish</span> ) <span class="arrow">⇒</span> <span class="returns">string< <a href="/api/utils/bytes/#datahexstring">DataHexstring</a> ></span><div class="anchors"><a class="self" href="#utils-hexlify"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L194">source</a></div></div><div class="body"><p>Converts <i>hexstringOrArrayish</i> to a <a href="/api/utils/bytes/#datahexstring">DataHexstring</a>.</p></div></div>
|
|
<a name="utils-hexvalue"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">hexValue</span> ( <span class="param">aBigNumberish</span> ) <span class="arrow">⇒</span> <span class="returns">string< <a href="/api/utils/bytes/#hexstring">Hexstring</a> ></span><div class="anchors"><a class="self" href="#utils-hexvalue"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L287">source</a></div></div><div class="body"><p>Converts <i>aBigNumberish</i> to a <a href="/api/utils/bytes/#hexstring">Hexstring</a>, with no <u>unnecessary</u> leading zeros.</p></div></div>
|
|
<a name="examples"></a><h3 class="show-anchors"><div>Examples<div class="anchors"><a class="self" href="#examples"></a></div></div></h3>
|
|
|
|
<div class="code">Skipping JavaScript Evaluation.</div>
|
|
|
|
<a name="array-manipulation"></a><h2 class="show-anchors"><div>Array Manipulation<div class="anchors"><a class="self" href="#array-manipulation"></a></div></div></h2>
|
|
|
|
<a name="utils-concat"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">concat</span> ( <span class="param">arrayOfBytesLike</span> ) <span class="arrow">⇒</span> <span class="returns">Uint8Array</span><div class="anchors"><a class="self" href="#utils-concat"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L140">source</a></div></div><div class="body"><p>Concatenates all the <a href="/api/utils/bytes/#byteslike">BytesLike</a> in <i>arrayOfBytesLike</i> into a single Uint8Array.</p></div></div>
|
|
<a name="utils-stripzeros"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">stripZeros</span> ( <span class="param">aBytesLike</span> ) <span class="arrow">⇒</span> <span class="returns">Uint8Array</span><div class="anchors"><a class="self" href="#utils-stripzeros"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L154">source</a></div></div><div class="body"><p>Returns a Uint8Array with all leading <code class="inline">0</code> bytes of <i>aBtyesLike</i> removed.</p></div></div>
|
|
<a name="utils-zeropad"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">zeroPad</span> ( <span class="param">aBytesLike</span> , <span class="param">length</span> ) <span class="arrow">⇒</span> <span class="returns">Uint8Array</span><div class="anchors"><a class="self" href="#utils-zeropad"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L171">source</a></div></div><div class="body"><p>Retutns a Uint8Array of the data in <i>aBytesLike</i> with <code class="inline">0</code> bytes prepended to <i>length</i> bytes long.</p><p>If <i>aBytesLike</i> is already longer than <i>length</i> bytes long, an InvalidArgument error will be thrown.</p></div></div>
|
|
<a name="hexstring-manipulation"></a><h2 class="show-anchors"><div>Hexstring Manipulation<div class="anchors"><a class="self" href="#hexstring-manipulation"></a></div></div></h2>
|
|
|
|
<a name="utils-hexconcat"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">hexConcat</span> ( <span class="param">arrayOfBytesLike</span> ) <span class="arrow">⇒</span> <span class="returns">string< <a href="/api/utils/bytes/#datahexstring">DataHexstring</a> ></span><div class="anchors"><a class="self" href="#utils-hexconcat"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L279">source</a></div></div><div class="body"><p>Concatenates all the <a href="/api/utils/bytes/#byteslike">BytesLike</a> in <i>arrayOfBytesLike</i> into a single <a href="/api/utils/bytes/#datahexstring">DataHexstring</a></p></div></div>
|
|
<a name="utils-hexdatalength"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">hexDataLength</span> ( <span class="param">aBytesLike</span> ) <span class="arrow">⇒</span> <span class="returns">string< <a href="/api/utils/bytes/#datahexstring">DataHexstring</a> ></span><div class="anchors"><a class="self" href="#utils-hexdatalength"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L253">source</a></div></div><div class="body"><p>Returns the length (in bytes) of <i>aBytesLike</i>.</p></div></div>
|
|
<a name="utils-hexdataslice"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">hexDataSlice</span> ( <span class="param">aBytesLike</span> , <span class="param">offset</span> [ , <span class="param">endOffset</span> ] ) <span class="arrow">⇒</span> <span class="returns">string< <a href="/api/utils/bytes/#datahexstring">DataHexstring</a> ></span><div class="anchors"><a class="self" href="#utils-hexdataslice"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L263">source</a></div></div><div class="body"><p>Returns a <a href="/api/utils/bytes/#datahexstring">DataHexstring</a> representation of a slice of <i>aBytesLike</i>, from <i>offset</i> (in bytes) to <i>endOffset</i> (in bytes). If <i>endOffset</i> is omitted, the length of <i>aBytesLike</i> is used.</p></div></div>
|
|
<a name="utils-hexstripzeros"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">hexStripZeros</span> ( <span class="param">aBytesLike</span> ) <span class="arrow">⇒</span> <span class="returns">string< <a href="/api/utils/bytes/#hexstring">Hexstring</a> ></span><div class="anchors"><a class="self" href="#utils-hexstripzeros"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L293">source</a></div></div><div class="body"><p>Returns a <a href="/api/utils/bytes/#hexstring">Hexstring</a> representation of <i>aBytesLike</i> with all leading zeros removed.</p></div></div>
|
|
<a name="utils-hexzeropad"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">hexZeroPad</span> ( <span class="param">aBytesLike</span> , <span class="param">length</span> ) <span class="arrow">⇒</span> <span class="returns">string< <a href="/api/utils/bytes/#datahexstring">DataHexstring</a> ></span><div class="anchors"><a class="self" href="#utils-hexzeropad"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L305">source</a></div></div><div class="body"><p>Returns a <a href="/api/utils/bytes/#datahexstring">DataHexstring</a> representation of <i>aBytesLike</i> padded to <i>length</i> bytes.</p><p>If <i>aBytesLike</i> is already longer than <i>length</i> bytes long, an InvalidArgument error will be thrown.</p></div></div>
|
|
<a name="signature-conversion"></a><h2 class="show-anchors"><div>Signature Conversion<div class="anchors"><a class="self" href="#signature-conversion"></a></div></div></h2>
|
|
|
|
<a name="utils-joinsignature"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">joinSignature</span> ( <span class="param">aSignatureLike</span> ) <span class="arrow">⇒</span> <span class="returns">string< <a href="/api/utils/bytes/#signature-flat">FlatSignature</a> ></span><div class="anchors"><a class="self" href="#utils-joinsignature"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L442">source</a></div></div><div class="body"><p>Return the flat-format of <i>aSignaturelike</i>, which is 65 bytes (130 nibbles) long, concatenating the <b>r</b>, <b>s</b> and (normalized) <b>v</b> of a Signature.</p></div></div>
|
|
<a name="utils-splitsignature"></a><div class="property show-anchors"><div class="signature"><span class="path">utils</span> . <span class="method">splitSignature</span> ( <span class="param">aSignatureLikeOrBytesLike</span> ) <span class="arrow">⇒</span> <span class="returns"><a href="/api/utils/bytes/#signature">Signature</a></span><div class="anchors"><a class="self" href="#utils-splitsignature"></a><a class="source" href="https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/bytes/src.ts/index.ts#L323">source</a></div></div><div class="body"><p>Return the full expanded-format of <i>aSignaturelike</i> or a flat-format <a href="/api/utils/bytes/#datahexstring">DataHexstring</a>. Any missing properties will be computed.</p></div></div>
|
|
<a name="random-bytes"></a><h2 class="show-anchors"><div>Random Bytes<div class="anchors"><a class="self" href="#random-bytes"></a></div></div></h2>
|
|
|
|
<div class="property show-anchors"><div class="signature"><span class="path">ethers</span> . <span class="path">utils</span> . <span class="method">randomBytes</span> ( <span class="param">length</span> ) <span class="arrow">⇒</span> <span class="returns">Uint8Array</span><div class="anchors"></div></div><div class="body"><p>Return a new Uint8Array of <i>length</i> random bytes.</p></div></div><div class="footer"><div class="nav previous"><a href="/api/utils/bignumber/"><span class="arrow">←</span>BigNumber</a></div> <div class="nav next"><a href="/api/utils/constants/">Constants<span class="arrow">→</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 Attribution 4.0 International License</a>.</div></div><script src="/script.js" type="text/javascript"></script></body></html><!-- ContentHash:41882a2bd89dad9b58819ecf614d21d4e52eb11c50f1fba0ebbe3446a71ca069 --> |