Open Scitz0 opened 3 months ago
Hi @Scitz0 ! If I understand you correctly you need to have original plutus script bytes of inlined script, right ?
To do it you can call output.script_ref().plutus_script()
, if it is a plutus script
@lisicky incorrect :)
We need to pass along bytes (in hex) including the "type" plutus vs native that I assume the first two bytes represent.
If I decode above cbor through https://cbor.nemo157.com/ and look at reference script section it looks like this:
If I call output.script_ref().plutus_script().to_bytes()
I'm missing the first two bytes 8202
that I assume describe that its a plutus script and not a native script. But if I call output.script_ref().to_bytes()
I get too much, ie like I described also the tag(24) and byte count.
Okay here script_ref CDDL and you need just CBOR of script part of it ?
Correct, so bytes of entire script
thing. This is what Ledger and Trezor expect that we pass along in the request.
@Scitz0 if it is not urgent I guess we can add it in next two weeks
You can also decode cbor via https://cardananium.github.io/cquisitor/ , it is more user friendly in some cases
Its not urgent no, just good to have option to get bytes this way in a future version. For now we solved it by utilizing another cbor lib to extract the bytes.
Sorry @Scitz0 for delay. ScriptRef
now has to_unwrapped_bytes
function, in the latest 12.0.0 beta release. Could you check it ?
Ok great, I will leave on a two week vacation shortly so bad timing. Though I'm sure its working properly.
When creating the json request to pass along to Ledger and Trezor hardware wallets we use CSL to deserialize the transaction cbor. For reference scripts in outputs, we noticed that when calling
output.script_ref().to_bytes()
it included the tag 24 cbor wrapper (not sure of proper nomenclature), ied8 18
(tag(24)) +59 04db
(bytes(1243)) as in below example cbor. I didn't find a way to access the actual bytes of the value (82025904d...
) for the reference script using CSL.In comparison with inline datum in same example, defined as
[ 0, $hash32 // 1, data ]
wheredata = #6.24(bytes .cbor plutus_data)
in CDDL.When we access the inline datum using
output.plutus_data().to_bytes()
we only get the actual value d87980, not the additional tag(24) and byte count.Privously I have noticed that there was two functions available,
to_bytes()
andas_bytes()
with the latter returning wrapping code and former didn't (could be misremembering). For reference script, I can only see the to_bytes() function while for inline datum both are present. Could the same behavior be replicated for reference script as for inline datum?Example cbor:
Using CSL 12 alpha 22