I’m trying to find a way to use the policy ID and script generated by CLI with cardano-serialization-lib. To my understanding, cardano-serialization-lib works in a different way than the CLI.
In Cardano CLI, I used to generate policy sKey and vKey using cardano-cli address key-gen and then use the vKey to generate keyHash with cardano-cli address key-hash and finally the policy script which looks something like this:-
The answers seem quite useful to me. The last one even contains the complete example code.
The policy ID is a hash of the policy – actually not of the JSON file, but of the CBOR generated from the JSON file (the thing you see at policyScript in your CSL example).
Since both of your example policies contain different key hashes, the policy IDs cannot be the same. You have to import the exact same key (or its hash) to Javascript to get the same policy ID or – the other way round – export a key generated by CSL or its hash to the command line to get the same result there.
@HeptaSean You are the man. It worked like a silver bullet.
Actually, I checked the GitHub thread yesterday and while writing this topic today, I just copied the link from my bookmark, didn’t even check that there was a new response at the bottom. Silly me.
Thanks for the sample code and your time. You have been very good to the Cardano community.
Modified it again a bit. It still contained some unneccessary conversions. (The thing you get from allScript.hash() already is a CSL.ScriptHash object. No need to go another round.)