ModulesAssets
Assets/Label.ts
Label overview
Table of contents
conversions
fromLabel
Parse a CIP-67 label format back to a number. Returns undefined if the label format is invalid or checksum doesn't match.
Reference: https://cips.cardano.org/cip/CIP-67
Signature
export declare const fromLabel: (label: string) => number | undefinedExample
import * as Label from "@evolution-sdk/evolution/Assets/Label"
const num = Label.fromLabel("000de140")
// => 222
const invalid = Label.fromLabel("00000000")
// => undefinedAdded in v2.0.0
toLabel
Convert a number to a CIP-67 label format. Creates an 8-character hex string with format: 0[4-digit-hex][2-digit-checksum]0
Reference: https://cips.cardano.org/cip/CIP-67
Signature
export declare const toLabel: (num: number) => stringExample
import * as Label from "@evolution-sdk/evolution/Assets/Label"
const label = Label.toLabel(222)
// => "000de140"Added in v2.0.0
schemas
LabelFromHex
Schema for validating and parsing CIP-67 labels. Decodes hex string labels to numbers and encodes numbers to label format.
Signature
export declare const LabelFromHex: Schema.transformOrFail<
Schema.filter<typeof Schema.String>,
Schema.filter<typeof Schema.Int>,
never
>Example
import * as Label from "@evolution-sdk/evolution/Assets/Label"
import { Schema } from "effect"
const decoded = Schema.decodeSync(Label.LabelFromHex)("000de140")
// => 222
const encoded = Schema.encodeSync(Label.LabelFromHex)(222)
// => "000de140"Added in v2.0.0