# CBOR plug in or tools?

**URL:** <https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556>\
**Category:** Language Support\
**Created:** [May 30, 2021, 5:00pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556 "2021-05-30T17:00:24Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [May 30, 2021, 5:00pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/1 "2021-05-30T17:00:24Z")

</div>

Has anyone had any progress in decoding the crazy cbor that is sent/returned from canisters when using xhr requests? This seems like a good target for a react tools style plug in that would allow you to ‘pretty print’ the cbor. I guess you need to know the candid interface to decode it? Any suggestions for tools to use? I’m guessing JSON was just too straightforward and widely accepted to be considered cool?😂I’m sure there are performance benefits, but man…what a pain. Let’s fix it! 🛠

---

<div class="post-metadata">

**Author:** ![wang](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/wang/32/446_2.png) [@wang](https://forum.dfinity.org/u/wang)\
**Post date:** [May 30, 2021, 11:50pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/2 "2021-05-30T23:50:25Z")

</div>

Libraries: [CBOR — Concise Binary Object Representation | Implementations](https://cbor.io/impls.html)

Online tool: [http://cbor.me/](http://cbor.me/)

---

<div class="post-metadata">

**Author:** ![toysrtommy](https://avatars.discourse-cdn.com/v4/letter/t/a3d4f5/32.png) [@toysrtommy](https://forum.dfinity.org/u/toysrtommy)\
**Post date:** [May 31, 2021, 4:55am UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/3 "2021-05-31T04:55:02Z")

</div>

Trying to figure out a CBOR-decoded response (to a “request-status” call) below.

From the IC spec document, I understand the sig is a certification of IC state, but what about the actual payload (“tree”), how do I map it the actual state-tree?

{ ‘certificate’: { ‘signature’: 'hexb aa ac 9a 1d 69 6e e3 9b 1a e4 b1 01 7e ’  
'bf 93 19 43 c8 1b b3 fe 68 b5 dd 06 15 77 f1 ’  
'0f f8 dc f7 65 b9 7a 8d 9b 63 30 95 93 76 c7 ’  
‘d9 71 9b 37 89’,  
‘tree’: [ ‘int 1’,  
[‘int 4’, ‘simp 15’],  
[ ‘int 1’,  
[‘int 4’, ‘int 7’],  
[ ‘int 2’,  
‘hexb 74 69 6d 65’,  
[ ‘int 3’,  
‘hexb cc a7 92 de b8 ae 83 c2 16’]]]]}}

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [June 1, 2021, 2:21pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/4 "2021-06-01T14:21:45Z")

</div>

I’ve tried the [cbor.me](http://cbor.me) tool before. I have no idea what to paste where to translate it. Take this response from dscvr.one:

 ![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/5/5eee683c05a4f977b7b22b670c6ffa5e6ec2cf56.png)

Where do I paste that response? If I put it on the left of [cbor.me](http://cbor.me) I get

```
ED # primitive(13)

##### 1 unused byte after the end of the data item:

CA

```

If I put it on the right I get

```
simple(13)

```

What do I need to paste where and what boxes need to be checked to convert this notation to some kind of readable structure?

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [June 1, 2021, 3:18pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/5 "2021-06-01T15:18:19Z")

</div>

If you use nix, you can install some convenience tools with

```auto
$ nix-env -i cbor-diag

```

But I think they don’t do much more than `cbor.me`.

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [June 1, 2021, 3:53pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/6 "2021-06-01T15:53:34Z")

</div>

> [@nomeata](#):
>
> `cbor-diag`

So if I want to convert the response of a query to a canister to json, what arguments do I give? Do I have to convert the text in the response window of chrome inspector to binary? And then pass it to this tool?

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [June 1, 2021, 3:58pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/7 "2021-06-01T15:58:39Z")

</div>

The response to a query is typically a Candid value, not a CBOR values. You only need to worry about CBOR if you are writing your own agent (library interacting with the IC), or are debugging things related to that low level.

But for low-level requests, you can use these CLI tools:

```auto
$ GET https://ic0.app/api/v2/status|file -
/dev/stdin: Concise Binary Object Representation (CBOR) container (array) (map)
$ GET https://ic0.app/api/v2/status|cbor2yaml.rb 
--- !ruby/struct:CBOR::Tagged
tag: 55799
value:
  ic_api_version: 0.17.0
  root_key: !binary |-
    MIGCMB0GDSsGAQQBgtx8BQMBAgEGDCsGAQQBgtx8BQMCAQNhAIFMDm7HH6tYOwi9gTc8JVw8NxsuhIY8mKTx4It0I10U+12cDNVG2WhfkToMCyzFNBWDv0tDkuRn25bWW5u0y3FxEvhHLg1aTRRQX/10hLASkQkcX4e5iINGP5gJGguqrg==
  impl_version: ca35377220efd5efb1f5944e34c4d6caf1aff2df
  impl_hash: ebb16175fd93b21e93a79a35935cc11eb1965d4fe4b8d349a59c394ea555d1a2

```

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [June 1, 2021, 5:18pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/8 "2021-06-01T17:18:53Z")

</div>

Thank you! Very descriptive. If the response to a query is typically a candid value, why can’t I read it? See the image above. How do I convert that garbled text into a candid object?

---

<div class="post-metadata">

**Author:** ![Ori](https://avatars.discourse-cdn.com/v4/letter/o/ecae2f/32.png) [@Ori](https://forum.dfinity.org/u/Ori)\
**Post date:** [June 1, 2021, 9:26pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/9 "2021-06-01T21:26:22Z")

</div>

didc might help you with this: [https://github.com/dfinity/candid/tree/master/tools/didc](https://github.com/dfinity/candid/tree/master/tools/didc)

---

<div class="post-metadata">

**Author:** ![nomeata](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/nomeata/32/733_2.png) [@nomeata](https://forum.dfinity.org/u/nomeata)\
**Post date:** [June 2, 2021, 6:41am UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/10 "2021-06-02T06:41:01Z")

</div>

> [@skilesare](#):
>
> Thank you! Very descriptive. If the response to a query is typically a candid value, why can’t I read it? See the image above. How do I convert that garbled text into a candid object?

Ah, the HTTP response is indeed CBOR, but it carries, in the `arg` field, the response from the canister (which is either a reject message, or a reply, which itself is typically Candid encoded). Different layers of abstraction; a bit like IP/TCP/HTTP/JSON).

So that response _should_ work with `cbor.me`. But the problem you are facing is that current browser developer tools are surprisingly bad at this when the response is binary. I would expect that UI to have a checkbox to show the response in hex (which you could then paste into `cbor.me`).

If I work locally, without HTTPS, I sometimes use wireshark to sniff the HTTP exchange and copy the HTTP payload there.

---

<div class="post-metadata">

**Author:** ![paulyoung](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/paulyoung/32/5251_2.png) [@paulyoung](https://forum.dfinity.org/u/paulyoung)\
**Post date:** [June 5, 2021, 9:59pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/11 "2021-06-05T21:59:45Z")

</div>

People on macOS might prefer [Proxyman](https://proxyman.io/) to Wireshark.

---

<div class="post-metadata">

**Author:** ![jorgenbuilder](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jorgenbuilder/32/22166_2.png) [@jorgenbuilder](https://forum.dfinity.org/u/jorgenbuilder)\
**Post date:** [November 18, 2021, 10:23pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/12 "2021-11-18T22:23:56Z")

</div>

If anyone has a quick overview for how they make a valid CBOR / Candid object from the junk in chrome devtools 👀👀👀

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [November 18, 2021, 10:38pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/13 "2021-11-18T22:38:23Z")

</div>

I’m just still confused why they didn’t use good old-fashioned json. Sometimes it seems like the most obtuse tool was chosen on purpose. How many devs have tried to inspect the messages sent on an IC app and just peace outed? 😆

---

<div class="post-metadata">

**Author:** ![jorgenbuilder](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jorgenbuilder/32/22166_2.png) [@jorgenbuilder](https://forum.dfinity.org/u/jorgenbuilder)\
**Post date:** [November 18, 2021, 10:50pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/14 "2021-11-18T22:50:47Z")

</div>

I guess when you’re replicating stuff a whole bunch of times as you do on a blockchain, the concision of CBOR starts to make more sense as the default message format on the IC??? Not to understate your point… the developer experience is really bad right now. Seems not so hard to add `application/cbor` interpreter to devtools, technically speaking–I have no idea what that process is like. On top of that, it sounds like we need a Candid interpreter in there. 😵

I guess you could also do something like make canisters translate cbor/candid to json for http requests. Honestly not sure which approach is better.

Life would be SO MUCH easier with a fix in place.

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [November 18, 2021, 10:57pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/15 "2021-11-18T22:57:59Z")

</div>

Sounds like a good bounty opportunity. Hmmm…

---

<div class="post-metadata">

**Author:** ![jorgenbuilder](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jorgenbuilder/32/22166_2.png) [@jorgenbuilder](https://forum.dfinity.org/u/jorgenbuilder)\
**Post date:** [November 18, 2021, 10:59pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/16 "2021-11-18T22:59:38Z")

</div>

It’s a killer bounty idea. Get a grant and make it happen. I’m up for a collab.

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [November 18, 2021, 11:04pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/17 "2021-11-18T23:04:02Z")

</div>

I don’t think there’s anything that we can do from the `agent-js` side to clean up the default network tab preview, but it would be really nice if there was. If there’s any requirement to hook into `agent-js` from a devtools extension, I’m happy to accommodate it

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [November 18, 2021, 11:06pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/18 "2021-11-18T23:06:39Z")

</div>

We probably have 20ICP we can put behind it from ICDevs right away. We just need to write up the simplest path forward. I’m guessing it is something along the lines of adding a tab to the dev tools via a plug-in that looks for cbor and decodes it and then further decodes any candid it finds?

---

<div class="post-metadata">

**Author:** ![jorgenbuilder](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jorgenbuilder/32/22166_2.png) [@jorgenbuilder](https://forum.dfinity.org/u/jorgenbuilder)\
**Post date:** [November 18, 2021, 11:09pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/19 "2021-11-18T23:09:23Z")

</div>

> [@skilesare](#):
>
> lines of adding a tab to the dev tools via a plug-in that looks for cbor and decodes it and then further decodes any candid it finds?

That makes a lot of sense. I went straight to patching devtools core 😆. I’ve yet to parse the output even manually, but getting that down then building a little devtools extension seems like the shortest critical path.

---

<div class="post-metadata">

**Author:** ![jorgenbuilder](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jorgenbuilder/32/22166_2.png) [@jorgenbuilder](https://forum.dfinity.org/u/jorgenbuilder)\
**Post date:** [November 19, 2021, 10:55pm UTC](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556/20 "2021-11-19T22:55:23Z")

</div>

Dove into this a bit today. What we’re getting back from a canister is b64 encoded byte array. Getting that to play nicely with [cbor.me](http://cbor.me) was a matter of hex encoding it. Now I just need to throw Candid decoding in there. Am I crazy, or is it only possible encode/decode Candid if you have type data? `agent-js` seems to be providing types as well as args for each encode/decode event. If so, I suppose the extension would have to provide a way to map an interface onto a canister in order to function.

[Next page](https://forum.dfinity.org/t/cbor-plug-in-or-tools/4556.md?page=2)
