Evolution SDK

core/Address.ts

Address overview

Added in v1.0.0


Table of contents


Arbitrary

arbitrary

FastCheck arbitrary generator for testing

Signature

export declare const arbitrary: FastCheck.Arbitrary<Address>

Added in v1.0.0

Functions

fromBech32

Sync functions using Schema utilities

Signature

export declare const fromBech32: (i: string, overrideOptions?: ParseOptions) => Address

Added in v1.0.0

Model

AddressDetails (interface)

Address details with both structured and serialized formats

Signature

export interface AddressDetails {
  readonly type: "Base" | "Enterprise"
  readonly networkId: NetworkId.NetworkId
  readonly address: {
    readonly bech32: string
    readonly hex: string
  }
  readonly paymentCredential: Credential.Credential
  readonly stakingCredential?: Credential.Credential
}

Added in v1.0.0

Schema

Address (class)

Signature

export declare class Address

Added in v1.0.0

toJSON (method)

Signature

toJSON()

toString (method)

Signature

toString(): string

[Inspectable.NodeInspectSymbol] (method)

Signature

[Inspectable.NodeInspectSymbol](): unknown

[Equal.symbol] (method)

Signature

[Equal.symbol](that: unknown): boolean

[Hash.symbol] (method)

Signature

[Hash.symbol](): number

Transformations

FromBech32

Transform from Bech32 string to AddressStructure

Signature

export declare const FromBech32: Schema.transformOrFail<
  typeof Schema.String,
  Schema.SchemaClass<Address, Address, never>,
  never
>

Added in v1.0.0

FromBytes

Transform from bytes to AddressStructure Handles both BaseAddress (57 bytes) and EnterpriseAddress (29 bytes)

Signature

export declare const FromBytes: Schema.transformOrFail<
  Schema.Union<[Schema.SchemaClass<Uint8Array, Uint8Array, never>, Schema.SchemaClass<Uint8Array, Uint8Array, never>]>,
  Schema.SchemaClass<Address, Address, never>,
  never
>

Added in v1.0.0

FromHex

Transform from hex string to AddressStructure

Signature

export declare const FromHex: Schema.transform<
  Schema.Schema<Uint8Array, string, never>,
  Schema.transformOrFail<
    Schema.Union<
      [Schema.SchemaClass<Uint8Array, Uint8Array, never>, Schema.SchemaClass<Uint8Array, Uint8Array, never>]
    >,
    Schema.SchemaClass<Address, Address, never>,
    never
  >
>

Added in v1.0.0

Utils

getAddressDetails

Parse address from bech32 or hex string and extract all details Returns undefined if the address cannot be parsed

Supports:

  • Base addresses (payment + staking credentials)
  • Enterprise addresses (payment credential only)

Signature

export declare const getAddressDetails: (address: string) => AddressDetails | undefined

Example

import * as Address from "@evolution-sdk/evolution/core/Address"

const details = Address.getAddressDetails("addr_test1qp...")
if (details) {
  console.log(details.type) // "Base" | "Enterprise"
  console.log(details.networkId) // 0 | 1
  console.log(details.paymentCredential)
  console.log(details.stakingCredential) // present for Base addresses
}

Added in v1.0.0

getNetworkId

Get network ID from AddressStructure

Signature

export declare const getNetworkId: (address: Address) => NetworkId.NetworkId

Added in v1.0.0

getPaymentCredential

Extract payment credential from address string Returns undefined if the address cannot be parsed

Signature

export declare const getPaymentCredential: (address: string) => Credential.Credential | undefined

Added in v1.0.0

getStakingCredential

Extract staking credential from address string Returns undefined if the address has no staking credential or cannot be parsed

Signature

export declare const getStakingCredential: (address: string) => Credential.Credential | undefined

Added in v1.0.0

hasStakingCredential

Check if AddressStructure has staking credential (BaseAddress-like)

Signature

export declare const hasStakingCredential: (address: Address) => boolean

Added in v1.0.0

isEnterprise

Check if AddressStructure is enterprise-like (no staking credential)

Signature

export declare const isEnterprise: (address: Address) => boolean

Added in v1.0.0

utils

fromBytes

Signature

export declare const fromBytes: (i: Uint8Array, overrideOptions?: ParseOptions) => Address

fromHex

Signature

export declare const fromHex: (i: string, overrideOptions?: ParseOptions) => Address

toBech32

Signature

export declare const toBech32: (a: Address, overrideOptions?: ParseOptions) => string

toBytes

Signature

export declare const toBytes: (a: Address, overrideOptions?: ParseOptions) => Uint8Array

toHex

Signature

export declare const toHex: (a: Address, overrideOptions?: ParseOptions) => string