0

I want to get cborHex from cardano-cli transaction build output and use it with cardano-serialization-lib to recreate the transaction body. I tried the following:

cborHex = '86a80081825820b9f5091d866b60db8ea3548d987fc237e5d89c8159aa6ddcee28fcf98b93860e000d80018282583900c19efef37292ee5b59ec5683ed52b537f43b1763f48469760affda73d6587eb03872ccf2ea313c55a5e6cfee9a409541dfa9b61fe35dfb921a3ab510f983581d70d5fa699784d82763328fbaee27412967a95f3371dfd69df3ceece8e71a004c4b405820851fe9c7b4b2e760c8b5f77a10963ea75a989f9285dcf988f637b814fd89946b021a0002c699031a03162a4508000e80075820f02f7b2a5ec946db2417a9afd42e27528763d39c3bf758fff7e9871230212c8e9fff8080f5d90103a100a1190cffa365646174756da26b636f6e7374727563746f7200666669656c647382a165627974657378386331396566656633373239326565356235396563353638336564353262353337663433623137363366343834363937363061666664613733a163696e741b000000075140a9da6b7573657241646472657373827840616464725f746573743171727165616c686e77326677756b366561337467386d326a6b356d6c67776368763036676736746b70746c613575376b74706c747177782c726a656e657735766675326b6a37646e6c776e6671663273776c34786d706c6336616c7766716e78306466326c77616e746564416d6f756e741b00000007b3d84700'
bytes = Buffer.from(cborHex, 'hex')
CardanoWasm.TransactionBody.from_bytes(bytes)

I am getting error

Uncaught Deserialization failed in TransactionBody because: Invalid cbor: not the right type, expected `Map' byte received `Array'

Is it possible to do this, and if yes what I am doing wrong?

1 Answer 1

0

In the new version of cardano-cli which is shipped with cardano-node 1.34 there is a new flag for transaction build --cddl-format which creates the same cbor like it is used in ledger https://github.com/input-output-hk/cardano-node/pull/3505. With this flag results cborHex is compatible with cardano-serialization-lib.

  const txBytes = Buffer.from(cborHex, 'hex')
  const tx = S.Transaction.from_bytes(txBytes)
  const txBody = tx.body()
  const txAuxilaryData = tx.auxiliary_data()
  const txHash = S.hash_transaction(txBody)

  const witnesses = S.TransactionWitnessSet.new()
  const vkeyWitnesses = S.Vkeywitnesses.new()
  vkeyWitnesses.add(S.make_vkey_witness(txHash, signKey))
  witnesses.set_vkeys(vkeyWitnesses)

  const transaction = S.Transaction.new(txBody, witnesses, txAuxilaryData)
  const cborSignedHex = Buffer.from(transaction.to_bytes()).toString('hex')

This solves the problem in the topic but I have currently another problem that auxilary_data is not the same and I got an error on submit ConflictingMetadataHash. Looks like an issue with cardano-serialization-lib https://github.com/Emurgo/cardano-serialization-lib/issues/396

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.