Helios API/ API Reference/ Classes/

Address

Wrapper for Cardano address bytes. An Address consists of three parts internally:

  • Header (1 byte, see CIP 19)
  • Witness hash (28 bytes that represent the PubKeyHash or ValidatorHash)
  • Optional staking credential (0 or 28 bytes)

Hierarchy

Index

Constructors

constructor

new Address(bytesOrBech32String)

Parameters

NameType
bytesOrBech32Stringstring | number[]

Overrides

HeliosData.constructor

Accessors

bytes

get bytes(): number[]

Returns

number[]

hex

get hex(): string

Converts a Address into its hexadecimal representation.

Returns

string

pubKeyHash

get pubKeyHash(): null | PubKeyHash

Returns the underlying PubKeyHash of a simple payment address, or null for a script address.

Returns

null | PubKeyHash

stakingHash

get stakingHash(): null | PubKeyHash | StakingValidatorHash

Returns the underlying PubKeyHash or StakingValidatorHash, or null for non-staked addresses.

Returns

null | PubKeyHash | StakingValidatorHash

validatorHash

get validatorHash(): null | ValidatorHash

Returns the underlying ValidatorHash of a script address, or null for a regular payment address.

Returns

null | ValidatorHash

Methods

dump

dump(): any

Returns

any

eq

eq(other): boolean

Parameters

NameType
otherAddress

Returns

boolean

toBech32

toBech32(): string

Converts an Address into its Bech32 representation.

Returns

string

toCbor

toCbor(): number[]

Returns

number[]

Inherited from

HeliosData.toCbor

toCborHex

toCborHex(): string

Returns

string

Inherited from

HeliosData.toCborHex

toHex

toHex(): string

Converts a Address into its hexadecimal representation.

Returns

string

toSchemaJson

toSchemaJson(): string

Returns

string

Inherited from

HeliosData.toSchemaJson

dummy

Static dummy(): Address

Returns a dummy address (based on a PubKeyHash with all null bytes)

Returns

Address

fromBech32

Static fromBech32(str): Address

Converts a Bech32 string into an Address.

Parameters

NameType
strstring

Returns

Address

fromCbor

Static fromCbor(bytes): Address

Deserializes bytes into an Address.

Parameters

NameType
bytesnumber[]

Returns

Address

fromHash

Static fromHash(hash, isTestnet?): Address

Constructs an Address using either a PubKeyHash (i.e. simple payment address) or ValidatorHash (i.e. script address), without a staking hash.

Parameters

NameTypeDescription
hashPubKeyHash | ValidatorHash
isTestnet?booleanDefaults to config.IS_TESTNET

Returns

Address

fromHashes

Static fromHashes(hash, stakingHash?, isTestnet?): Address

Constructs an Address using either a PubKeyHash (i.e. simple payment address) or ValidatorHash (i.e. script address), in combination with an optional staking hash (PubKeyHash or StakingValidatorHash).

Parameters

NameTypeDescription
hashPubKeyHash | ValidatorHash
stakingHash?null | PubKeyHash | StakingValidatorHash
isTestnet?booleanDefaults to config.IS_TESTNET

Returns

Address

fromHex

Static fromHex(hex): Address

Constructs an Address using a hexadecimal string representation of the address bytes. Doesn't check validity.

Parameters

NameType
hexstring

Returns

Address

fromProps

Static fromProps(props): Address

Parameters

NameType
propsAddress | AddressProps

Returns

Address

fromUplcData

Static fromUplcData(data, isTestnet?): Address

Parameters

NameType
dataUplcData
isTestnet?boolean

Returns

Address

isForTestnet

Static isForTestnet(address): boolean

Returns true if the given Address is a testnet address.

Parameters

NameType
addressAddress

Returns

boolean