To pack an address with the /pack_data we pass the following:

const packedData = await axios.post(
        data: { string: "tz1SaUEpoM8ME55RdMbNifypEqETodYKyNBD" },
        type: { prim: 'address' },
        gas: '800000'
        headers: {
          'Content-Type': 'application/json'

What about packing a map, for example:

const myMap = {
      fieldOne: 2,
      fieldTwo: "tz1SaUEpoM8ME55RdMbNifypEqETodYKyNBD"

Thank you.

  • 1
    Hi, what is the source language you're using? The example you give, myMap is not a map in the Michelson sense, as the types of the bindings are different (fieldOne is an integer, and fieldTwo is an address). I would rather call this type of structure a record, which has no direct equivalent in Michelson. However, it could be encoded as a pair: pair int address where each component corresponds to each field.
    – arvidj
    May 25, 2020 at 9:54

1 Answer 1


This RPC expects to receive a Michelson data value and type in its JSON representation. I'm unsure what source language you are using, but you can cheat a little bit and find out the JSON representation of a Michelson value and type by using the tezos-client hash data command. By adding the -l flag, you also see the RPC calls made by the client.

For instance, if your record is encoded as a pair:

$ tezos-client -l hash data '(Pair 2 "tz1SaUEpoM8ME55RdMbNifypEqETodYKyNBD")' of type 'pair int address'


>>>>3: http://localhost:18731/chains/main/blocks/head/helpers/scripts/pack_data
  { "data":
      { "prim": "Pair",
          [ { "int": "2" },
            { "string": "tz1SaUEpoM8ME55RdMbNifypEqETodYKyNBD" } ] },
      { "prim": "pair",
        "args": [ { "prim": "int" }, { "prim": "address" } ] },
    "gas": "1040000" }
  • Thak you!! That's very helpful! Can you please tell me how to pack a map that contains the same type in values: {key1: "wordOne", key2: "wordTwo"}?
    – Daly
    May 25, 2020 at 10:10
  • 1
    It's: tezos-client -l hash data '{Elt "aaaa" "ddddd"; Elt "mamma" "mammaaaa"}' of type 'map string string' Thank you an other time.
    – Daly
    May 25, 2020 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.