I am attempting to send a previously signed transaction from cardano-cli
using the cardano-wallet
endpoint:
https://localhost:8090/v2/proxy/transactions
Here is how the signed transaction appears:
txBody = {
"type": "Tx MaryEra",
"description": "",
"cborHex": "83a400818258202d7928a59fcba5bf71c40fe6428a301ffda4d2fa681e5357051970436462b89400018282583900c0e88694ab569f42453eb950fb4ec14cb50f4d5d26ac83fdec2c505d818bcebf1df51c84239805b8a330d68fdbc3c047c12bb4c3172cb9391a002b335f825839003d2d9ceb1a47bc1b62b7498ca496b16a7b4bbcc6d97ede81ba8621ebd6d947875fcf4845ef3a5f08dd5522581cf6de7b9c065379cbb3754d1a001e8480021a00029361031...
}
I am uncertain of how to submit it to the endpoint with Content-Type application/octet-stream
. The API documentation specifies that the payload should be:
string <binary>
Signed transaction message binary blob.
I am using JavaScript for this and have attempted passing the cborHex
directly, using
Buffer.from(txBody.cborHex).toString('base64')
, and the entire JSON object Buffer.from(JSON.stringify(txBody)).toString('base64')
but consistently receive the same response:
{
"code": "malformed_tx_payload",
"message": "I couldn't verify that the payload has the c…node. Please check the format and try again."
}
After examining the swagger specification, I discovered that the endpoint supports a JSON payload. By looking at the source code of cardano-wallet
here:
newtype PostExternalTransactionData = PostExternalTransactionData
{ payload :: ByteString
} deriving (Eq, Generic, Show)
I assumed the structure should resemble something like this:
{
"payload": ?// some binary blob here that I can't find. I've tried with:
// Buffer.from(txBody.cborHex).toString('base64') and
// Buffer.from(JSON.stringify(txBody)).toString('base64')
}
Do you have any suggestions on how to construct the payload and send the signed transaction?