The following code allows me to query a Datum from the blockchain using Lucid and Blockfrost:

import { Blockfrost, Lucid } from "https://deno.land/x/[email protected]/mod.ts";

const lucid = await Lucid.new(
  new Blockfrost(

const nft = "b7e0e70f653f23abc39d16f6f6be16fd72e3fe3030db9b16cecccf68524549545f5354415445";  // example

const utxo = await lucid.utxoByUnit(nft);
const datum = utxo.datum

The output to the console, for this example, is:


My question now is, what command in Lucid allows me to deserialize this output? I don't even know what kind of encoding I am dealing with (I suspect it is CBOR).

By the way, I know that the desired deserialization, for this example, should be:

   constructor: 0,
   fields: [
         int: 1000
         int: 63500
         int: 1000
         int: 1000

1 Answer 1


I figured out that the Lucid command that does the trick is Data.from. First, in the original code, I need to add Data in the list of imports:

import { Blockfrost, Lucid, Data, } from "https://deno.land/x/[email protected]/mod.ts";

Then simply add:

const solution = Data.from(datum);

at the end of the original code.

  • Still it would be nice to know if it is indeed CBOR the encoding from which Data.from deserializes.
    – a_juggler
    Commented Sep 16, 2023 at 17:57

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.