How to make cbor-encoded string for datum with key and value?

Hello, how are you?
I have a datum which is object type (key-value pair)
When I make the cbor encoded string for datum using lucid-cardano library, it actually generate the hex string without the keys, and just keep them in order.

Is there a way to generate the cbor hex string while keeping the key as hex string in cbor-encoded?

Thank you.

1 Like

Hello, I am currently facing the same issue. May I ask how do you try to generate the cbor encoded string?

import { Data } from "https://deno.land/x/lucid@0.10.7/mod.ts";

// declare types

const MyDatumSchema = Data.Map(Data.Bytes(), Data.Integer());

type MyDatum = Data.Static<typeof MyDatumSchema>;

const map1 = new Map<string, bigint>();

map1.set("abc", 1234n);

const temp = Data.to<MyDatum>(map1, MyDatumSchema);

This is what I have tried.
But I got error.