I have a question , While packing the string, "KT1FRoFxDhnKXGPggejHPAnMs27j6rcVfwzV", the output is 0501000000244b543146526f467844686e4b5847506767656a4850416e4d7332376a3672635666777a56 this can be easily decoded back to the input string,

but whenever I pack sp.address("KT1FRoFxDhnKXGPggejHPAnMs27j6rcVfwzV"), the output is , 050a00000016014b168ccb96310249aade4ce010e4e2ec8dd4602900 I know this can be decoded using sp.unpack but there should be other way too right? to decode this and get back the input address outside the chain using some decoder ?

2 Answers 2


You can use TzGo if Golang is part of your toolbox:

package main

import (

func main() {
    if err := run(); err != nil {
        fmt.Println("Error", err)

func run() error {
    // decode the hex string to binary
    buf, err := hex.DecodeString("050a00000016014b168ccb96310249aade4ce010e4e2ec8dd4602900")
    if err != nil {
        return err

    // wrap the byte buffer into a Micheline primitive and unpack it
    // this creates a new primitive with contents unpacked (there is
    // also a prim.UnpackAll() which works recursive on complex structs
    prim, err := micheline.NewBytes(buf).Unpack()
    if err != nil {
        return err
    // output the decoded value as string 
    // Note: prim.String is only set for binary encoded addresses
    // and UTF8 strings, any other byte sequence is at prim.Bytes)

    // output the JSON form of the primitive
    return nil

Outside the chain the simplest is usually to not pack your address in the first place because outside the chain addresses are strings.

If for some reason the contract only gives you a packed version, you can unpack it using a library or calling the Octez client:

$ octezt-client normalize data "$(octez-client unpack michelson data 0x050a00000016014b168ccb96310249aade4ce010e4e2ec8dd4602900)" of type address
  • it should work when i base58 decode the 050a00000016014b168ccb96310249aade4ce010e4e2ec8dd4602900 or it won't work ?
    – lee brune
    Apr 5 at 6:15
  • 1
    No it is more complex than this: - the first 05 byte means that this results from PACK - the second 0a byte means that this is a string - the next 4 bytes 00000016 are the lenght of the string - the remaining is the actual address But to obtain something that starts with "KT1" another prefix is prepended and there is also a checksum at the end. Apr 5 at 12:41

Your Answer

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

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