@xylabs/eth-address
v5.1.2
Published
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Readme
@xylabs/eth-address
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Install
Using npm:
npm install {{name}}Using yarn:
yarn add {{name}}Using pnpm:
pnpm add {{name}}Using bun:
bun add {{name}}License
See the LICENSE file for license rights and limitations (LGPL-3.0-only).
Reference
packages
eth-address
### .temp-typedoc
### classes
### <a id="EthAddressWrapper"></a>EthAddressWrapperWrapper around an Ethereum address providing parsing, formatting, validation, and checksum support.
Constructors
Constructor
protected new EthAddressWrapper(address): EthAddressWrapper;Parameters
address
bigint
Returns
EthAddressWrapper
Methods
fromString()
static fromString(value?, base?): EthAddressWrapper | undefined;Parameters
value?
string
base?
number = 16
Returns
EthAddressWrapper | undefined
parse()
static parse(value, base?): EthAddressWrapper | undefined;Parameters
value
unknown
base?
number
Returns
EthAddressWrapper | undefined
validate()
static validate(address): boolean;Parameters
address
string
Returns
boolean
equals()
equals(address?): boolean;Parameters
address?
string | EthAddressWrapper | null
Returns
boolean
toBigNumber()
toBigNumber(): bigint;Returns
bigint
toHex()
toHex(): string;Returns
string
toJSON()
toJSON(): string;Returns
string
toLowerCaseString()
toLowerCaseString(): string;Returns
string
toShortString()
toShortString(length?): string;Parameters
length?
number = 2
Returns
string
toString()
toString(checksum?, chainId?): string;Parameters
checksum?
boolean
chainId?
string
Returns
string
validate()
validate(): boolean;Returns
boolean
### functions
### <a id="ellipsize"></a>ellipsizefunction ellipsize(value, length?): string;Truncates a string to show the first and last length characters separated by an ellipsis.
Parameters
value
string
The string to ellipsize
length?
number = 2
Number of characters to keep at each end (default 2)
Returns
string
The ellipsized string
### <a id="isEthAddressWrapper"></a>isEthAddressWrapperfunction isEthAddressWrapper(obj): obj is { type: string } & EthAddressWrapper;Type guard that checks if the given object is an instance of EthAddressWrapper.
Parameters
obj
type
string
Returns
obj is { type: string } & EthAddressWrapper
### <a id="padHex"></a>padHexfunction padHex(hex, byteCount?): string;Parameters
hex
string
byteCount?
number = 0
Returns
string
