Options
All
  • Public
  • Public/Protected
  • All
Menu

Module @taquito/utils

Taquito Utils package

Our current implementation of the Michelson parser is a prototype. The current implementation is naïve. We are likely going to switch to using the Nomadic Michelson encoder in the future, as per Issue https://gitlab.com/tezos/tezos/issues/581

Index

References

Prefix

Re-exports Prefix

ValidationResult

Re-exports ValidationResult

isValidPrefix

Re-exports isValidPrefix

prefix

Re-exports prefix

prefixLength

Re-exports prefixLength

validateAddress

Re-exports validateAddress

validateChain

Re-exports validateChain

validateContractAddress

Re-exports validateContractAddress

validateKeyHash

Re-exports validateKeyHash

validatePublicKey

Re-exports validatePublicKey

validateSignature

Re-exports validateSignature

Functions

Const b58cdecode

  • b58cdecode(enc: string, prefixArg: Uint8Array): Uint8Array

b58cencode

  • b58cencode(value: string | Uint8Array, prefix: Uint8Array): any
  • description

    Base58 encode a string or a Uint8Array and append a prefix to it

    Parameters

    • value: string | Uint8Array

      Value to base58 encode

    • prefix: Uint8Array

      prefix to append to the encoded string

    Returns any

b58decode

  • b58decode(payload: string): string

Const buf2hex

  • buf2hex(buffer: Buffer): string

encodeExpr

  • encodeExpr(value: string): any
  • description

    Hash a string using the BLAKE2b algorithm, base58 encode the hash obtained and appends the prefix 'expr' to it

    Parameters

    • value: string

      Value in hex

    Returns any

encodeKey

  • encodeKey(value: string): any

encodeKeyHash

  • encodeKeyHash(value: string): any

encodePubKey

  • encodePubKey(value: string): any

Const hex2buf

  • hex2buf(hex: string): Uint8Array

isValidPrefix

  • isValidPrefix(value: any): value is Prefix

Const mergebuf

  • mergebuf(b1: Uint8Array, b2: Uint8Array): Uint8Array

Const mic2arr

  • mic2arr(s: any): any

validateAddress

  • description

    Used to check if an address or a contract address is valid.

    example
    import { validateAddress } from '@taquito/utils';
    const pkh = 'tz1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
    const validation = validateAddress(pkh)
    console.log(validation)
    // This example return 3 which correspond to VALID

    Parameters

    • value: any

    Returns ValidationResult

    0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).

validateChain

  • description

    Used to check if a chain id is valid.

    example
    import { validateChain } from '@taquito/utils';
    const chainId = 'NetXdQprcVkpaWU'
    const validation = validateChain(chainId)
    console.log(validation)
    // This example return 3 which correspond to VALID

    Parameters

    • value: any

    Returns ValidationResult

    0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).

validateContractAddress

  • description

    Used to check if a contract address is valid.

    example
    import { validateContractAddress } from '@taquito/utils';
    const contractAddress = 'KT1JVErLYTgtY8uGGZ4mso2npTSxqVLDRVbC'
    const validation = validateContractAddress(contractAddress)
    console.log(validation)
    // This example return 3 which correspond to VALID

    Parameters

    • value: any

    Returns ValidationResult

    0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).

validateKeyHash

  • description

    Used to check if a key hash is valid.

    example
    import { validateKeyHash } from '@taquito/utils';
    const keyHashWithoutPrefix = '1L9r8mWmRPndRhuvMCWESLGSVeFzQ9NAWx'
    const validation = validateKeyHash(keyHashWithoutPrefix)
    console.log(validation)
    // This example return 0 which correspond to NO_PREFIX_MATCHED

    Parameters

    • value: any

    Returns ValidationResult

    0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).

validatePublicKey

  • description

    Used to check if a signature is valid.

    example
    import { validatePublicKey } from '@taquito/utils';
    const publicKey = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
    const validation = validatePublicKey(publicKey)
    console.log(validation)
    // This example return 3 which correspond to VALID

    Parameters

    • value: any

    Returns ValidationResult

    0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).

validateSignature

  • description

    Used to check if a signature is valid.

    example
    import { validateSignature } from '@taquito/utils';
    const signature = 'edsigtkpiSSschcaCt9pUVrpNPf7TTcgvgDEDD6NCEHMy8NNQJCGnMfLZzYoQj74yLjo9wx6MPVV29CvVzgi7qEcEUok3k7AuMg'
    const validation = validateSignature(signature)
    console.log(validation)
    // This example return 3 which correspond to VALID

    Parameters

    • value: any

    Returns ValidationResult

    0 (NO_PREFIX_MATCHED), 1 (INVALID_CHECKSUM), 2 (INVALID_LENGTH) or 3 (VALID).

Object literals

Const prefix

prefix: object

[Prefix.B]

[Prefix.B]: Uint8Array = new Uint8Array([1, 52])

[Prefix.CO]

[Prefix.CO]: Uint8Array = new Uint8Array([79, 179])

[Prefix.EDESK]

[Prefix.EDESK]: Uint8Array = new Uint8Array([7, 90, 60, 179, 41])

[Prefix.EDPK]

[Prefix.EDPK]: Uint8Array = new Uint8Array([13, 15, 37, 217])

[Prefix.EDSIG]

[Prefix.EDSIG]: Uint8Array = new Uint8Array([9, 245, 205, 134, 18])

[Prefix.EDSK2]

[Prefix.EDSK2]: Uint8Array = new Uint8Array([13, 15, 58, 7])

[Prefix.EDSK]

[Prefix.EDSK]: Uint8Array = new Uint8Array([43, 246, 78, 7])

[Prefix.EXPR]

[Prefix.EXPR]: Uint8Array = new Uint8Array([13, 44, 64, 27])

[Prefix.ID]

[Prefix.ID]: Uint8Array = new Uint8Array([153, 103])

[Prefix.KT1]

[Prefix.KT1]: Uint8Array = new Uint8Array([2, 90, 121])

[Prefix.KT]

[Prefix.KT]: Uint8Array = new Uint8Array([2, 90, 121])

[Prefix.LLO]

[Prefix.LLO]: Uint8Array = new Uint8Array([29, 159, 109])

[Prefix.LO]

[Prefix.LO]: Uint8Array = new Uint8Array([133, 233])

[Prefix.NCE]

[Prefix.NCE]: Uint8Array = new Uint8Array([69, 220, 169])

[Prefix.NET]

[Prefix.NET]: Uint8Array = new Uint8Array([87, 82, 0])

[Prefix.O]

[Prefix.O]: Uint8Array = new Uint8Array([5, 116])

[Prefix.P2ESK]

[Prefix.P2ESK]: Uint8Array = new Uint8Array([0x09, 0x30, 0x39, 0x73, 0xab])

[Prefix.P2PK]

[Prefix.P2PK]: Uint8Array = new Uint8Array([3, 178, 139, 127])

[Prefix.P2SIG]

[Prefix.P2SIG]: Uint8Array = new Uint8Array([54, 240, 44, 52])

[Prefix.P2SK]

[Prefix.P2SK]: Uint8Array = new Uint8Array([16, 81, 238, 189])

[Prefix.P]

[Prefix.P]: Uint8Array = new Uint8Array([2, 170])

[Prefix.SIG]

[Prefix.SIG]: Uint8Array = new Uint8Array([4, 130, 43])

[Prefix.SPESK]

[Prefix.SPESK]: Uint8Array = new Uint8Array([0x09, 0xed, 0xf1, 0xae, 0x96])

[Prefix.SPPK]

[Prefix.SPPK]: Uint8Array = new Uint8Array([3, 254, 226, 86])

[Prefix.SPSIG]

[Prefix.SPSIG]: Uint8Array = new Uint8Array([13, 115, 101, 19, 63])

[Prefix.SPSK]

[Prefix.SPSK]: Uint8Array = new Uint8Array([17, 162, 224, 201])

[Prefix.TZ1]

[Prefix.TZ1]: Uint8Array = new Uint8Array([6, 161, 159])

[Prefix.TZ2]

[Prefix.TZ2]: Uint8Array = new Uint8Array([6, 161, 161])

[Prefix.TZ3]

[Prefix.TZ3]: Uint8Array = new Uint8Array([6, 161, 164])

[Prefix.TZ]

[Prefix.TZ]: Uint8Array = new Uint8Array([2, 90, 121])

Const prefixLength

prefixLength: object

[Prefix.B]

[Prefix.B]: number = 32

[Prefix.EDPK]

[Prefix.EDPK]: number = 32

[Prefix.EDSIG]

[Prefix.EDSIG]: number = 64

[Prefix.KT1]

[Prefix.KT1]: number = 20

[Prefix.KT]

[Prefix.KT]: number = 20

[Prefix.NET]

[Prefix.NET]: number = 4

[Prefix.P2PK]

[Prefix.P2PK]: number = 33

[Prefix.P2SIG]

[Prefix.P2SIG]: number = 64

[Prefix.P]

[Prefix.P]: number = 32

[Prefix.SIG]

[Prefix.SIG]: number = 64

[Prefix.SPPK]

[Prefix.SPPK]: number = 33

[Prefix.SPSIG]

[Prefix.SPSIG]: number = 64

[Prefix.TZ1]

[Prefix.TZ1]: number = 20

[Prefix.TZ2]

[Prefix.TZ2]: number = 20

[Prefix.TZ3]

[Prefix.TZ3]: number = 20

Generated using TypeDoc