multiversx

How to decode base64 & hexadecimal response from query


The query comes as

"returnData": [
                "zWCLtKpUXZbkWNM9deAVPizTxXASOjX63ubdUHDN+vw=",
                "zWCLtKpUXZbkWNM9deAVPizTxXASOjX63ubdUHDN+vw="
            ],

How can I decode that string? I can see it is decodable base64 first, but I get a very weird string after. Can someone show me the steps to follow to receive the decoded final string?


Solution

  • Base64 encodes binary data, which means if you send data that is not a string you won't be able to retrieve a string back. So to properly parse the return data you will need to know what data types were actually returned.

    It might also be helpful to use a base64 to hex decoder first, so you get the hex representation of your data.

    To give you more concrete recommendations we would need to know what data you expected, preferably showing the whole endpoint definition as well as any custom structs that might be involved.