StricaHQ / typhonjs

Pure javascript Cardano wallet library
Apache License 2.0
61 stars 12 forks source link

[Help] Issues with transforming signedTX to be accepted by submit-api endpoint #18

Closed Aervue closed 2 years ago

Aervue commented 2 years ago
const finalTx = {
  "type": "Tx AlonzoEra",
  "description": "",
  "cborHex": txFinal.payload
}

const apiAddress = "https://cardano-mainnet.blockfrost.io/api/v0/tx/submit"

async function postTx() {
  try {
    const response = await axios.post(apiAddress, finalTx), {
      headers: {
        'Content-Type': 'application/cbor',
        'project_id': 'myApiKey'
      }
    });
    console.log(response);
  } catch (error) {
    console.error(error);
  }
}

postTx()

If I save finalTx contents to tx.signed on cardano-node server, I can succesfully send it via cardano-cli, but sending it via HTTP/S requires me to transform it. I would like to not add another dependency so I was hoping you could share how to transform it using your packages? Tried a bunch of stuff before posting.

Thanks

ashisherc commented 2 years ago

As per the code above, the finalTx format is an API specific requirement, and is not required by the node itself. So please check with the API. Only thing that is imp is the final cbor hex of the tx.

Aervue commented 2 years ago

As per the code above, the finalTx format is an API specific requirement, and is not required by the node itself. So please check with the API. Only thing that is imp is the final cbor hex of the tx.

Blockfrost and Koios have the same submit-api requirements as cardano-submit-api. If I save the contents of finalTx in cardano-node I can submit it using cardano-cli. I tried submitting only the cbor hex, tried getting the buffer from it, did the same on finalTx among other stuff I’ve been trying.

“ Assuming ${data} is a raw binary serialized transaction on the file-system.

If using a CLI-generated tx file, please ensure to deserialise (using xxd -p -r <<< $(jq .cborHex ${tx.signed}) > ${data}) first before submitting.”

This is what the Koios api requires.

ashisherc commented 2 years ago

this is unrelated to the lib, you can join this tg for dev related queries and also find the IOG Discord invite in that tg to connect with more devs. https://t.me/CardanoDevelopersOfficial