Credential.ts
Credential overview
Table of contents
encoding
toCBORBytes
Convert a Credential to CBOR bytes.
Signature
export declare const toCBORBytes: (credential: Credential, options?: CBOR.CodecOptions) => Uint8ArrayAdded in v2.0.0
toCBORHex
Convert a Credential to CBOR hex string.
Signature
export declare const toCBORHex: (credential: Credential, options?: CBOR.CodecOptions) => stringAdded in v2.0.0
model
Credential (type alias)
Type representing a credential that can be either a key hash or script hash Used in various address formats to identify ownership
Signature
export type Credential = typeof Credential.TypeAdded in v2.0.0
parsing
fromCBORBytes
Parse a Credential from CBOR bytes.
Signature
export declare const fromCBORBytes: (bytes: Uint8Array, options?: CBOR.CodecOptions) => CredentialAdded in v2.0.0
fromCBORHex
Parse a Credential from CBOR hex string.
Signature
export declare const fromCBORHex: (hex: string, options?: CBOR.CodecOptions) => CredentialAdded in v2.0.0
predicates
is
Check if the given value is a valid Credential
Signature
export declare const is: (
u: unknown,
overrideOptions?: ParseOptions | number
) => u is KeyHash.KeyHash | ScriptHash.ScriptHashAdded in v2.0.0
schemas
Credential
Credential schema representing either a key hash or script hash credential = [0, addr_keyhash // 1, script_hash] Used to identify ownership of addresses or stake rights
Signature
export declare const Credential: Schema.Union<[typeof KeyHash.KeyHash, typeof ScriptHash.ScriptHash]>Added in v2.0.0
FromCDDL
CDDL schema for Credential as defined in the specification: credential = [0, addr_keyhash // 1, script_hash]
Signature
export declare const FromCDDL: Schema.transformOrFail<
Schema.Tuple2<Schema.Literal<[0n, 1n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.SchemaClass<KeyHash.KeyHash | ScriptHash.ScriptHash, KeyHash.KeyHash | ScriptHash.ScriptHash, never>,
never
>Added in v2.0.0
testing
arbitrary
FastCheck arbitrary for generating random Credential instances. Randomly selects between generating a KeyHash or ScriptHash credential.
Signature
export declare const arbitrary: FastCheck.Arbitrary<KeyHash.KeyHash | ScriptHash.ScriptHash>Added in v2.0.0
utils
CDDLSchema
Signature
export declare const CDDLSchema: Schema.Tuple2<Schema.Literal<[0n, 1n]>, typeof Schema.Uint8ArrayFromSelf>CredentialEncoded (type alias)
Signature
export type CredentialEncoded = typeof Credential.EncodedFromCBORBytes
Signature
export declare const FromCBORBytes: (
options?: CBOR.CodecOptions
) => Schema.transform<
Schema.transformOrFail<
typeof Schema.Uint8ArrayFromSelf,
Schema.declare<CBOR.CBOR, CBOR.CBOR, readonly [], never>,
never
>,
Schema.transformOrFail<
Schema.Tuple2<Schema.Literal<[0n, 1n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.SchemaClass<KeyHash.KeyHash | ScriptHash.ScriptHash, KeyHash.KeyHash | ScriptHash.ScriptHash, never>,
never
>
>FromCBORHex
Signature
export declare const FromCBORHex: (
options?: CBOR.CodecOptions
) => Schema.transform<
Schema.Schema<Uint8Array, string, never>,
Schema.transform<
Schema.transformOrFail<
typeof Schema.Uint8ArrayFromSelf,
Schema.declare<CBOR.CBOR, CBOR.CBOR, readonly [], never>,
never
>,
Schema.transformOrFail<
Schema.Tuple2<Schema.Literal<[0n, 1n]>, typeof Schema.Uint8ArrayFromSelf>,
Schema.SchemaClass<KeyHash.KeyHash | ScriptHash.ScriptHash, KeyHash.KeyHash | ScriptHash.ScriptHash, never>,
never
>
>
>makeKeyHash
Signature
export declare const makeKeyHash: (hash: Uint8Array) => CredentialmakeScriptHash
Signature
export declare const makeScriptHash: (hash: Uint8Array) => Credential