Decoding CBOR values

In the version v0.20 of Cadence the storage format was updated.

How to decode data from a storableNode ?

var bufReader io.Reader = bufio.NewReader(r)
storableNode,_ := flattener.ReadStorableNode(bufReader)
payload, err := encoding.DecodePayload(storableNode.EncPayload)

address := common.BytesToAddress(payload.Key.KeyParts[0].Value)
fmt.Println(address)   // decoded ok

decoder := interpreter.CBORDecMode.NewByteStreamDecoder(payload.Value)
storable,_ := interpreter.DecodeStorable(decoder, atree.StorageIDUndefined)

/// further decode storable into `Value`

tagging @turbolent

@turbolent I’m trying to decode the data from the latest checkpoint file.
I saw there’s a utility file here:
but it looks like it expects a different file format.

In the new storage format, individual payloads don’t store the full data anymore. Instead, large values like arrays, are split into multiple payloads (registers in the ledger). Do you really want to decode the low-level data in each payload/register as low-level CBOR structures? Or do you rather want to decode the high-level Cadence values?

The decode-state-values tool accepts a state dump in JSONL format, and is only used for testing/debugging purposes. I think you can generate it from a checkpoint file using

If you want to read in the execution state and operate on the payloads, you can look at the state reporting/migration tool at For example, you can find some of the reporters here:

1 Like