Cardano-cli ScriptDataBytes object

Hi all,

Does anyone know and able to explain to me how the ScriptDataBytes value is encoded as part of a query of an address as part of a cardano-cli call return?

i.e. ReferenceTxInsScriptsInlineDatumsInBabbageEra is returned with the datum encoded.

but there are elements such as \NUL and \ETB.

What I’m failing to understand how these related to the CBOR/CDDL structures?

i.e. is there a mapping standard if this is for human readable values? or is this following a standard encode/decode specification I’m not aware of?

If I get the datum from dbsync, all is well. I’m just wondering if the datum should be decodable from cardano-cli?

Thanks and kind regards

Carl (Vegas pool)

P.S. maybe an example would help:

                           TxHash                                 TxIx        Amount

--------------------------------------------------------------------------------------

921c4884dc46e155a2b5e8ce4c24656e49b29a4661d1e42a5f2f35c611935635     0        3749700 lovelace + 1 279f842c33eed9054b9e3c70cd6a3b32298259c24b78b895cb41d91a.6c6f72642074756e61 + TxOutDatumInline ReferenceTxInsScriptsInlineDatumsInBabbageEra (ScriptDataConstructor 0 [ScriptDataNumber 4635,ScriptDataBytes "\NUL\NUL\NUL\148\206\239r\145\147\165\199\137\EMe\153&\EMA\189\171\f9\150\&1\211k\245\DC4G\173\ETB\166",ScriptDataNumber 6,ScriptDataNumber 65532,ScriptDataNumber 21159000,ScriptDataNumber 1693303667000,ScriptDataBytes "AlL HaIl tUnA",ScriptDataList [ScriptDataBytes "\NUL\NUL\NUL\"\219\249TB`\129\&0\227or\252\180\255\190\200iW\143\&4\251\217\235\240\225\214<\223\214",ScriptDataBytes "\NUL\NUL\NUL\"\219\249TB`\129\&0\227or\252\180\255\190\200iW\143\&4\251\217\235\240\225\214<\223\214",ScriptDataBytes "\NUL\NUL\NUL\SO\236+}n\179\213\255O\223\ni\255?\STX\ETB\EM\180\202<\240\187J\227\130\GSty\153",ScriptDataBytes "\NUL\NUL\NUL\SO\236+}n\179\213\255O\223\ni\255?\STX\ETB\EM\180\202<\240\187J\227\130\GSty\153",ScriptDataBytes "\NUL\NUL\NUL\a\154\174\DC3\173,T\ENQ\221\174mL\130\228\STX\246\FSpr\222\186\135 \140Z\141A\209\239",ScriptDataBytes "\NUL\NUL\NUL\NUL\132o|R\185c\241\225\233\204L\184\&1\237E`\195\207?\237\a\176\181\144\ACKw\188\133",ScriptDataBytes "\NUL\NUL\NUL\NUL\132o|R\185c\241\225\233\204L\184\&1\237E`\195\207?\237\a\176\181\144\ACKw\188\133",ScriptDataBytes "\NUL\NUL\NUL\NUL\132o|R\185c\241\225\233\204L\184\&1\237E`\195\207?\237\a\176\181\144\ACKw\188\133",ScriptDataBytes "\NUL\NUL\NUL\NUL\"\200\132BkTW\178!\229\FS\FS\141\157e\NAK\v\215\166\216\NAK\\\250G\244y\231\135",ScriptDataBytes "\NUL\NUL\NUL\NUL\"\200\132BkTW\178!\229\FS\FS\141\157e\NAK\v\215\166\216\NAK\\\250G\244y\231\135",ScriptDataBytes "\NUL\NUL\NUL\NUL\ETXC\USbf\227\254'H\222\150\224K\147\203\224vf\138\DC2\248BSQ\131b\253b",ScriptDataBytes "\NUL\NUL\NUL\NUL\ETXC\USbf\227\254'H\222\150\224K\147\203\224vf\138\DC2\248BSQ\131b\253b",ScriptDataBytes "\NUL\NUL\NUL\NUL\ETXC\USbf\227\254'H\222\150\224K\147\203\224vf\138\DC2\248BSQ\131b\253b",ScriptDataBytes "\NUL\NUL\NUL\NUL\ETXC\USbf\227\254'H\222\150\224K\147\203\224vf\138\DC2\248BSQ\131b\253b",ScriptDataBytes "\NUL\NUL\NUL\NUL\ETXC\USbf\227\254'H\222\150\224K\147\203\224vf\138\DC2\248BSQ\131b\253b",ScriptDataBytes "\NUL\NUL\NUL\NUL\ETXC\USbf\227\254'H\222\150\224K\147\203\224vf\138\DC2\248BSQ\131b\253b"]])

Looking at the fortuna datum as a good example. From this, I know ScriptDataBytes of


> Blockquote

""\NUL\NUL\NUL\148\206\239r\145\147\165\199\137\EMe\153&\EMA\189\171\f9\150\&1\211k\245\DC4G\173\ETB\166"" 

is actually:

0000006E802627BFFD40C348833778923813FDE7341214DBE986EDCA80A545B3

and should map to CBOR/CDDL of:


> Blockquote
b"\u0000\u0000\u0000n\x80&'\xBF\xFD@\xC3H\x837x\x928\u0013\xFD\xE74\u0012\u0014\xDB\xE9\x86\xEDʀ\xA5E\xB3"

However, I don’t get how cardano-cli is encoding this?!

If you’re using cardano-cli to query utxos, you can use --out-file /dev/stdout.. This command will return a result in JSON format.

# cardano-cli

cardano-cli query utxo --address addr_test1wpzewuy339m9l8ax7gz8g08q2j9478lgntzv9qhmwvy3hwg0cwsaf  --testnet-magic 1 --socket-path /ipc/node.socket --out-file /dev/stdout
# Result
{
    "ff561227cdf77a50aae5a9ae8d2b8cd7e2ff781a025e83a151cd9486d79e7daa#0": {
        "address": "addr_test1wpzewuy339m9l8ax7gz8g08q2j9478lgntzv9qhmwvy3hwg0cwsaf",
        "datum": null,
        "datumhash": "923918e403bf43c34b4ef6b48eb2ee04babed17320d8d1b9ff9ad086e86f44ec",
        "inlineDatum": null,
        "referenceScript": {
            "script": {
                "cborHex": "590514590511010000333232323232323232323232323232323232323232323232323232223232223232323253355335533357346042660166018a00200e03026464666ae68cdc419806980728019980b9999aa999ab9a3370e90030008990911118020029aba1302400215333573466e1d20040011321222230020053574260480042a666ae68c08c0044c848888c004014d5d098120010a999ab9a30220011321222230030053574260480040424c40024c4c016900100a80d98120009baa3500201d01813357389213d4d75737420636f6e73756d65204e4654206f7220746f6b656e2070726576696f75736c79206d696e746564207573696e67207468697320706f6c6963790001301415335738920103505435001613253335734604060460022646464646464646464646464646464646464646464642466666666666600202e02a02602201e01a01601200e00a0060046ae84d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d118118011aba1302200101f37546a002036a666ae68c078c0840084c8c848cc00400c008d5d09aba2302100335742604000403aa666ae68c074c080dd500180880e1baa00153335734603260380022646601e6ae84004d5d09aba2001301b00101837540044464646603a4466a0029000111a801112999ab9a3375e0040102660464466a0029000111a801112999ab9a3375e00401a20022600c0060022600c0060086a00402a6a0020264666aa6020026660144466aa601c02a46a002446601e00466aa602203046a0024466024004666a0026e012000700466e0000520000013355300e015235001223300f00233350012335530120192350012233013002300e0010012233300a0090020012335530120192350012233013002301000100133300500400200100e232333008200133008200175a6aa666ae68c05cc0680044c8c8c8c8c8c848cccc00401c01400c008d5d09aba2002357420026ae88008d5d08009aba2301a00235742603200202c44440066ea8d400404ccc06488cccd55cf800900891919809a999ab9a3019301c001132321233001003002357426ae88c070008d5d0980d80080c18021aba200337546ae84008054dd61a80091111111111100611199ab9a3375e00400201c010444666aa601602601e66aa601802646a002446601a0046010002666aa6016026446a00444a66a666aa602802e6601c4466601402e004002601002c46a002446601400400a00c200626602600800601c00266aa601802646a002446601a0046603844a66a002260180064426a00444a66a6601800401022444660040140082600c00600800446600244a66a004018200200a4244460060084446602c446666aae7c00480388c8cc040cc02cc01cc064004c018c060004c010d5d10019aba1002012375600242444600200820142014442466002006004601c4422444a66a00220044426600a004666aa600e01e00a008002601a442244a66a00200a44266012600800466aa600c01a00800220022006442446600200800660124422444a66a00226a00600e442666a00a0106008004666aa600e01400a0080024400444002240022a66ae71241035054310016370e90001b874800955cf2ab9d2323001001223300330020020014c12ed8799f581cf2a60961aa3ff239ee90f8d4de2ef3f24791522212e83ec504d053fe4b4344505f43524541544f52ff004c0104434344500001",
                "description": "",
                "type": "PlutusScriptV2"
            },
            "scriptLanguage": "PlutusScriptLanguage PlutusScriptV2"
        },
        "value": {
            "lovelace": 6667570
        }
    },
    "ff98ec61e0c74fab143b86566b48cc40823382854a42da1f8a26f8d8b63923ff#0": {
        "address": "addr_test1wpzewuy339m9l8ax7gz8g08q2j9478lgntzv9qhmwvy3hwg0cwsaf",
        "datum": null,
        "datumhash": "923918e403bf43c34b4ef6b48eb2ee04babed17320d8d1b9ff9ad086e86f44ec",
        "inlineDatum": null,
        "referenceScript": {
            "script": {
                "cborHex": "590513590510010000333232323232323232323232323232323232323232323232323232223232223232323253355335533357346042660166018a00200e03026464666ae68cdc419806980728019980b9999aa999ab9a3370e90030008990911118020029aba1302400215333573466e1d20040011321222230020053574260480042a666ae68c08c0044c848888c004014d5d098120010a999ab9a30220011321222230030053574260480040424c40024c4c016900100a80d98120009baa3500201d01813357389213d4d75737420636f6e73756d65204e4654206f7220746f6b656e2070726576696f75736c79206d696e746564207573696e67207468697320706f6c6963790001301415335738920103505435001613253335734604060460022646464646464646464646464646464646464646464642466666666666600202e02a02602201e01a01601200e00a0060046ae84d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d10011aba1001357440046ae84004d5d118118011aba1302200101f37546a002036a666ae68c078c0840084c8c848cc00400c008d5d09aba2302100335742604000403aa666ae68c074c080dd500180880e1baa00153335734603260380022646601e6ae84004d5d09aba2001301b00101837540044464646603a4466a0029000111a801112999ab9a3375e0040102660464466a0029000111a801112999ab9a3375e00401a20022600c0060022600c0060086a00402a6a0020264666aa6020026660144466aa601c02a46a002446601e00466aa602203046a0024466024004666a0026e012000700466e0000520000013355300e015235001223300f00233350012335530120192350012233013002300e0010012233300a0090020012335530120192350012233013002301000100133300500400200100e232333008200133008200175a6aa666ae68c05cc0680044c8c8c8c8c8c848cccc00401c01400c008d5d09aba2002357420026ae88008d5d08009aba2301a00235742603200202c44440066ea8d400404ccc06488cccd55cf800900891919809a999ab9a3019301c001132321233001003002357426ae88c070008d5d0980d80080c18021aba200337546ae84008054dd61a80091111111111100611199ab9a3375e00400201c010444666aa601602601e66aa601802646a002446601a0046010002666aa6016026446a00444a66a666aa602802e6601c4466601402e004002601002c46a002446601400400a00c200626602600800601c00266aa601802646a002446601a0046603844a66a002260180064426a00444a66a6601800401022444660040140082600c00600800446600244a66a004018200200a4244460060084446602c446666aae7c00480388c8cc040cc02cc01cc064004c018c060004c010d5d10019aba1002012375600242444600200820142014442466002006004601c4422444a66a00220044426600a004666aa600e01e00a008002601a442244a66a00200a44266012600800466aa600c01a00800220022006442446600200800660124422444a66a00226a00600e442666a00a0106008004666aa600e01400a0080024400444002240022a66ae71241035054310016370e90001b874800955cf2ab9d2323001001223300330020020014c12ad8799f581c7121a58565e5c31887e827e0da8d2ec0fe27c76f212e9d1ee98c54334755504752414445ff004c0107464941535345540001",
                "description": "",
                "type": "PlutusScriptV2"
            },
            "scriptLanguage": "PlutusScriptLanguage PlutusScriptV2"
        },
        "value": {
            "lovelace": 6663260
        }
    }
}
1 Like