# Decoding CBOR values

**URL:** <https://forum.flow.com/t/decoding-cbor-values/2651>\
**Category:** ⚙️ Flow SDKs\
**Created:** [December 14, 2021, 3:57pm UTC](https://forum.flow.com/t/decoding-cbor-values/2651 "2021-12-14T15:57:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/daniel/32/77_2.png) [@daniel](https://forum.flow.com/u/daniel)\
**Post date:** [December 14, 2021, 3:57pm UTC](https://forum.flow.com/t/decoding-cbor-values/2651/1 "2021-12-14T15:57:05Z")

</div>

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

How to decode data from a `storableNode` ?

```auto
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`

```

---

<div class="post-metadata">

**Author:** ![unlocked](https://avatars.discourse-cdn.com/v4/letter/u/3be4f8/32.png) [@unlocked](https://forum.flow.com/u/unlocked)\
**Post date:** [December 14, 2021, 8:40pm UTC](https://forum.flow.com/t/decoding-cbor-values/2651/2 "2021-12-14T20:40:44Z")

</div>

tagging @bastian

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/daniel/32/77_2.png) [@daniel](https://forum.flow.com/u/daniel)\
**Post date:** [December 15, 2021, 10:54am UTC](https://forum.flow.com/t/decoding-cbor-values/2651/3 "2021-12-15T10:54:00Z")

</div>

@bastian I’m trying to decode the data from the latest checkpoint file.  
I saw there’s a utility file here: [https://github.com/onflow/cadence/blob/v0.20.2/runtime/cmd/decode-state-values/main.go](https://github.com/onflow/cadence/blob/v0.20.2/runtime/cmd/decode-state-values/main.go)  
but it looks like it expects a different file format.

---

<div class="post-metadata">

**Author:** ![bastian](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.flow.com/bastian/32/183_2.png) [@bastian](https://forum.flow.com/u/bastian)\
**Post date:** [January 12, 2022, 6:05pm UTC](https://forum.flow.com/t/decoding-cbor-values/2651/4 "2022-01-12T18:05:58Z")

</div>

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 [https://github.com/onflow/flow-go/blob/master/cmd/util/cmd/export-json-execution-state/cmd.go](https://github.com/onflow/flow-go/blob/master/cmd/util/cmd/export-json-execution-state/cmd.go).

If you want to read in the execution state and operate on the payloads, you can look at the state reporting/migration tool at [https://github.com/onflow/flow-go/blob/master/cmd/util/cmd/execution-state-extract/execution\_state\_extract.go](https://github.com/onflow/flow-go/blob/master/cmd/util/cmd/execution-state-extract/execution_state_extract.go). For example, you can find some of the reporters here: [https://github.com/onflow/flow-go/tree/master/cmd/util/ledger/reporters](https://github.com/onflow/flow-go/tree/master/cmd/util/ledger/reporters).
