Taquito TypeDocs
    Preparing search index...

    Function packData

    • Serializes any value of packable type to its optimized binary representation identical to the one used by PACK and UNPACK Michelson instructions. Without a type definition (not recommended) the data will be encoded as a binary form of a generic Michelson expression. Type definition allows some types like timestamp and address and other base58 representable types to be encoded to corresponding optimized binary forms borrowed from the Tezos protocol

      const data: MichelsonData = {
      string: "KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2%main"
      };

      const typ: MichelsonType = {
      prim: "address"
      };

      const packed = packData(data, typ);

      // 050a0000001a0167ea84b1082efb9619d6ce04e033633906636e1d006d61696e

      Without a type definition the base58 encoded address will be treated as a string

      const data: MichelsonData = {
      string: "KT1J4E79F1qL6kGBSQ3yXBdXmuq5j4FNThK2%main"
      };

      const packed = packData(data);

      // 0501000000294b54314a344537394631714c366b474253513379584264586d7571356a34464e54684b32256d61696e

      Parameters

      Returns number[]

      Binary representation as numeric array