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)

Constructor

new helios.Address(bytes: []number)

Static methods

fromBech32

Converts a Bech32 string into an Address:

helios.Address.fromBech32(str: string): helios.Address

fromCbor

Deserializes bytes into an Address.

helios.Address.fromCbor(bytes: []number): helios.Address

fromHex

Constructs an Address using a hexadecimal string representation of the address bytes.

helios.Address.fromHex(hex: string): helios.Address

fromHashes

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 (StakeKeyHash or StakingValidatorHash).

Testnet addresses have different header bytes. IS_TESTNET is a library-scope variable that can be set globally.

helios.Address.fromPubKeyHash(
    pkh: helios.PubKeyHash | helios.ValidatorHash,
    sh: ?(helios.StakeKeyHash | helios.StakingValidatorHash) = null,
    isTestnet: boolean = IS_TESTNET
): helios.Address

isForTestnet

Returns true if the given Address is a testnet address.

helios.Address.isForTestnet(
    address: helios.Address
): boolean

Getters

pubKeyHash

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

address.pubKeyHash: ?helios.PubKeyHash

validatorHash

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

address.validatorHash: ?helios.ValidatorHash

stakingHash

Returns the underlying [StakeKeyHash](./stakekeyhash.md) or [StakingValidatorHash](./stakingvalidatorhash.md), or null` for non-staked addresses.

address.stakingHash: ?(helios.StakeKeyHash | helios.StakingValidatorHash)

Methods

toBech32

Turns an Address into its Bech32 representation.

address.toBech32(): string

toCbor

Turns an Address into its CBOR representation.

address.toCbor(): number[]

toHex

Turns a Address into its hexadecimal representation.

address.toHex(): string