Skip to content

Class: Address

@fuel-ts/address.Address

Address provides a type safe wrapper for converting between different address formats ands comparing them for equality.

Hierarchy

Constructors

constructor

new Address(address): Address

Parameters

NameTypeDescription
address`fuel${string}`A Bech32 address

Returns

Address

Overrides

AbstractAddress.constructor

Defined in

address.ts:33

Properties

bech32Address

Readonly bech32Address: `fuel${string}`

Defined in

address.ts:27

Methods

equals

equals(other): boolean

Compares this the bech32Address property to another for direct equality

Parameters

NameTypeDescription
otherAddressAnother address to compare against

Returns

boolean

The equality of the comparison

Overrides

AbstractAddress.equals

Defined in

address.ts:138


toAddress

toAddress(): `fuel${string}`

Returns the bech32Address property

Returns

`fuel${string}`

The bech32Address property

Overrides

AbstractAddress.toAddress

Defined in

address.ts:50


toAssetId

toAssetId(): AssetId

Wraps the bech32Address property and returns as an AssetId.

Returns

AssetId

The bech32Address property as an AssetId

Defined in

address.ts:117


toB256

toB256(): string

Converts and returns the bech32Address property to a 256 bit hash string

Returns

string

The bech32Address property as a 256 bit hash string

Overrides

AbstractAddress.toB256

Defined in

address.ts:59


toBytes

toBytes(): Uint8Array

Converts and returns the bech32Address property to a byte array

Returns

Uint8Array

The bech32Address property as a byte array

Overrides

AbstractAddress.toBytes

Defined in

address.ts:68


toEvmAddress

toEvmAddress(): EvmAddress

Clears the first 12 bytes of the bech32Address property and returns it as a EvmAddress

Returns

EvmAddress

The bech32Address property as an EvmAddress

Defined in

address.ts:104


toHexString

toHexString(): string

Converts

Returns

string

The bech32Address property as a 256 bit hash string

Overrides

AbstractAddress.toHexString

Defined in

address.ts:77


toJSON

toJSON(): string

Converts and returns the bech32Address property as a string

Returns

string

The bech32Address property as a string

Overrides

AbstractAddress.toJSON

Defined in

address.ts:95


toString

toString(): string

Converts and returns the bech32Address property as a string

Returns

string

The bech32Address property as a string

Overrides

AbstractAddress.toString

Defined in

address.ts:86


valueOf

valueOf(): string

Returns the value of the bech32Address property

Returns

string

The value of bech32Address property

Defined in

address.ts:128


fromAddressOrString

fromAddressOrString(address): AbstractAddress

Takes an ambiguous string or address and creates an Address

Parameters

NameType
addressstring | AbstractAddress

Returns

AbstractAddress

a new Address instance

Defined in

address.ts:198


fromB256

fromB256(b256Address): Address

Takes a B256 Address and creates an Address

Parameters

NameTypeDescription
b256AddressstringA b256 hash

Returns

Address

A new Address instance

Defined in

address.ts:163


fromDynamicInput

fromDynamicInput(address): Address

Takes a dynamic string or AbstractAddress and creates an Address

Throws

Error - Unknown address if the format is not recognised

Parameters

NameType
addressstring | AbstractAddress

Returns

Address

A new Address instance

Defined in

address.ts:209


fromEvmAddress

fromEvmAddress(evmAddress): Address

Takes an Evm Address and returns back an Address

Parameters

NameType
evmAddressstring

Returns

Address

A new Address instance

Defined in

address.ts:243


fromPublicKey

fromPublicKey(publicKey): Address

Takes a Public Key, hashes it, and creates an Address

Parameters

NameTypeDescription
publicKeystringA wallets public key

Returns

Address

A new Address instance

Defined in

address.ts:148


fromRandom

fromRandom(): Address

Creates an Address with a randomized bech32Address property

Returns

Address

A new Address instance

Defined in

address.ts:179


fromString

fromString(address): Address

Takes an ambiguous string and attempts to create an Address

Parameters

NameTypeDescription
addressstringAn ambiguous string

Returns

Address

A new Address instance

Defined in

address.ts:189