@xylabs/eth-address
v5.0.87
Published
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Readme
@xylabs/eth-address
Base functionality used throughout XY Labs TypeScript/JavaScript libraries
Reference
@xylabs/eth-address
Classes
| Class | Description | | ------ | ------ | | EthAddressWrapper | Wrapper around an Ethereum address providing parsing, formatting, validation, and checksum support. |
Functions
| Function | Description |
| ------ | ------ |
| isEthAddressWrapper | Type guard that checks if the given object is an instance of EthAddressWrapper. |
| ellipsize | Truncates a string to show the first and last length characters separated by an ellipsis. |
| padHex | - |
classes
EthAddressWrapper
Wrapper around an Ethereum address providing parsing, formatting, validation, and checksum support.
Constructors
Constructor
protected new EthAddressWrapper(address: bigint): EthAddressWrapper;Parameters
| Parameter | Type |
| ------ | ------ |
| address | bigint |
Returns
EthAddressWrapper
Methods
fromString()
static fromString(value?: string, base?: number): EthAddressWrapper | undefined;Parameters
| Parameter | Type | Default value |
| ------ | ------ | ------ |
| value? | string | undefined |
| base? | number | 16 |
Returns
EthAddressWrapper | undefined
parse()
static parse(value: unknown, base?: number): EthAddressWrapper | undefined;Parameters
| Parameter | Type |
| ------ | ------ |
| value | unknown |
| base? | number |
Returns
EthAddressWrapper | undefined
validate()
static validate(address: string): boolean;Parameters
| Parameter | Type |
| ------ | ------ |
| address | string |
Returns
boolean
equals()
equals(address?: string | EthAddressWrapper | null): boolean;Parameters
| Parameter | Type |
| ------ | ------ |
| 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?: number): string;Parameters
| Parameter | Type | Default value |
| ------ | ------ | ------ |
| length | number | 2 |
Returns
string
toString()
toString(checksum?: boolean, chainId?: string): string;Parameters
| Parameter | Type |
| ------ | ------ |
| checksum? | boolean |
| chainId? | string |
Returns
string
validate()
validate(): boolean;Returns
boolean
functions
ellipsize
function ellipsize(value: string, length?: number): string;Truncates a string to show the first and last length characters separated by an ellipsis.
Parameters
| Parameter | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| value | string | undefined | The string to ellipsize |
| length | number | 2 | Number of characters to keep at each end (default 2) |
Returns
string
The ellipsized string
isEthAddressWrapper
function isEthAddressWrapper(obj: {
type: string;
}): obj is { type: string } & EthAddressWrapper;Type guard that checks if the given object is an instance of EthAddressWrapper.
Parameters
| Parameter | Type |
| ------ | ------ |
| obj | { type: string; } |
| obj.type | string |
Returns
obj is { type: string } & EthAddressWrapper
padHex
function padHex(hex: string, byteCount?: number): string;Parameters
| Parameter | Type | Default value |
| ------ | ------ | ------ |
| hex | string | undefined |
| byteCount | number | 0 |
Returns
string
Part of sdk-js
Maintainers
License
See the LICENSE file for license details
