There seems to be an issue with the transaction payload in the Cardano wallet when submitting an

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?

Answer №1

This particular snippet of code indicates that when decoding external transactions that are sealed, the wallet first attempts Base 16 encoding and if that is unsuccessful, it then tries Base 64:

instance FromJSON (ApiT SealedTx) where
    parseJSON v = do
        tx <- parseSealedTxBytes @'Base16 v <|> parseSealedTxBytes @'Base64 v
        pure $ ApiT tx

Following this, the BytesString is sent to a specific function at this link, along with information on the currentNodeEra that the node is operating in.

(Different eras have different decoding methods)

It's possible (though not confirmed) that the node is running on an Alonzo era while you're submitting a transaction encoded in Mary. If that's the case, the decoding process could fail.

I trust this explanation sheds some light on the matter.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Eliminate JavaScript that blocks rendering:

Currently, I am working on optimizing my website's speed and aiming for a perfect 100/100 score on PageSpeed Insights. The website in question is www.chrispdesign.com. Despite my efforts to relocate the code and make necessary adjustments, I have bee ...

Issue in TypeScript where object properties may still be considered undefined even after verifying using Object.values() for undefined values

I'm encountering an issue with TypeScript regarding my interface MentionItem. Both the id and value properties are supposed to be strings, but TypeScript is flagging them as possibly string | undefined. Interestingly, manually checking that id and va ...

Transmitting a plethora of information using jQuery

Here's the code I currently have for sending data: var test={imagename:"apple.jpg",x:"13",y:"33"}; $.ajax({ type: "POST", url: "some.php", data: test, success: function(response){ console.log(response); } }); ...

How can Vue FullCalendar be configured dynamically?

I am trying to dynamically change some options in Vue FullCalendar, but the calendar is not applying them. You can check out my example here. The button at the bottom should set the maxTime option from 20:00 to 18:00. Is there a way to refresh the calen ...

Enhance Image Size with a Custom React Hook

I've created a function to resize user-uploaded images stored in state before sending them to the backend. const [file, setFile] = useState(null) function dataURLtoFile(dataurl, filename) { let arr = dataurl.split(','), mime = arr[0].ma ...

Possible rephrased version: "Encountering a Jquery clash

It appears that the issue causing my problem may be a Jquery conflict. Please correct me if I am wrong after reviewing the information below. I am new to Jquery and attempting to add a dropdown plugin to a website. The attempt is successful, but an existi ...

What is the best way to use element.appendChild to generate a link?

I am currently utilizing the following snippet of Javascript to extract information from the current webpage using a browser extension. I have only included a portion of the code that is relevant, as the full script is quite lengthy. The code works perfect ...

What could be causing the NaN error when parsing a number in Javascript?

I'm having trouble figuring out why I keep getting a NaN when I try to print a number with JavaScript. This code snippet is used in multiple places on the website and usually works without any issues. The URL where this issue is occurring is: Here ...

Angular's NgShoppingCart is designed in such a way that items stored in the localStorage are automatically cleared out

I am currently working on an Angular project using version 8.0.0. To integrate a shopping cart feature into my Angular project, I decided to incorporate the NgShoppingCart library by following the instructions provided here. After adding the library in m ...

Stagnant variable value after onClick event

After exploring various solutions, none seem to quite fit my needs. I want to update the variable "currentIndex" when a user clicks on an image. Currently, the change occurs within the onClick function but does not affect the outside variable. I am unsur ...

Different option for positioning elements in CSS besides using the float

I am currently working on developing a new application that involves serializing the topbar and sidebar and surrounding them with a form tag, while displaying the sidebar and results side by side. My initial attempt involved using flex layout, but I have ...

What is the most effective method to query Prisma using a slug without utilizing a React hook?

Retrieve post by ID (slug) from Prisma using getStaticProps() before page generation The challenge arises when attempting to utilize a React hook within getStaticProps. Initially, the plan was to obtain slug names with useRouter and then query for a post ...

Looking to display an alert message upon scrolling down a specific division element in HTML

In the midst of the body tag, I have a div element. <div id="place"> </div> I'm trying to achieve a scenario where upon scrolling down and encountering the div with the ID "place", an alert is displayed. My current approach involves che ...

The table disappears when there is no data available in the database

One of my challenges involves a table that displays data retrieved from a database. The code for this is as follows: <table class="table table-hover table-bordered" style="width:300px" id="contact"> <tbody data-bind="foreach:items"> ...

Postman seems to be functioning correctly while AXIOS is encountering issues

I've encountered a strange issue with my MERN app. When I use Postman to send a PUT request to my API, it successfully updates both the API and MongoDB. However, when performing the same action on the front-end, the API does not update even though the ...

Preserve user-inputted text from jQuery within a div container

With the help of the knowledgeable individuals here, I successfully created a prototype to address an issue I had encountered. The problem involved using a textbox input with a password requirement to update an HTML element. Although everything is functio ...

Node.js is raising an error regarding strict mode, despite the fact that Babel 6 preset es2015 is being used, which

When working with node js, I encountered an error message stating uncaughtException: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode, despite using babel 6 es2015 preset which should include use strict. My pro ...

Is there a specific code repository available that can verify and transform blog comments into XHTML strict format?

I'm currently developing a PHP website that allows users to make comments similar to a blog, and I am specifically interested in restricting the use of certain HTML tags. Is there any existing library that can process user comments and output valid XH ...

Incorporating Paged.JS functionality into a React/JS web application

My attempt to showcase my html page using paged.js in a react project has hit a snag. The html loads perfectly when accessed from local host (not via npm start, but the live server extension on vscode). However, following the steps outlined on this website ...

Seeking assistance in optimizing my Javascript code for more efficient canvas rendering

I've created a script for generating random moving lines as a background element for my portfolio. While it runs smoothly on its own, I encounter frame drops when combining it with other CSS animations and effects, especially at the beginning (althoug ...