0

I queried a transaction result using:

http://localhost:26657/tx?hash=0x43B8422E9FD4FD4A01213772E989CDA5F36103A0EA679B95932052B20C016267

and then fetch the transaction content 'tx' in the returned JSON object.

rgEoKBapCjZS59jqCgpnb29nbGUuY29tEg4KCW5hbWV0b2tlbhIBNRoUr67sqicZ8wXbWkNLD8E6c0TGM/YSBBDAmgwaagom61rphyEC6ICqudQCIugpL8NEvi6Fblxk+ZB+51T+NUDg0WdMQCUSQG0z4HhxINONIjPcQc/GDyVOjU9CRovZaT3GxcekSvN6SBQx94xgwMkq7EqivCxSqYB/TDC0Gp5Z/6z2+Z4Km3k=

I decoded this with

base64.StdEncoding.DecodeString(base64Str)

and then it printed the following result

�((� 6R���

google.com ┼▒└␊├⎺┐␊┼5���'��ZCK�:sD�3��� j &�Z�!耪��"�)/�D�.�n\d��~�T�5@��gL@%@m3�xq Ӎ"3�A��%N�OBF��i=��ǤJ�zH1��`��*�J��,R��L0��Y����� �y

What's the correct way to decode a transaction?

godvlpr
  • 141
  • 1
  • 3
  • 11
  • https://stackoverflow.com/questions/15334220/encode-decode-base64 is working for you? – Manjeet Thakur Aug 02 '19 at 12:33
  • Manjeet Thakur, no i already tried, i think this base64 something else encoded – godvlpr Aug 02 '19 at 12:38
  • 1
    BDW Your output is correct. – Manjeet Thakur Aug 02 '19 at 12:39
  • No it isn't, i think that the output can be encoded too – godvlpr Aug 02 '19 at 14:08
  • If DecodeString doesn't return an error, it succeeded, whether you believe it or not. What makes you think that it's not working? – Peter Aug 02 '19 at 14:46
  • Because i wait readable JSON, but have many incorrect symbols – godvlpr Aug 02 '19 at 15:08
  • Your Go code is fine, the `rgEoK [..] m3k=` string just isn't JSON data. Either you have an error somewhere in your code, or you have a problem with the Tendermint API. Having the full Go code ([mcve]) would be useful. – Martin Tournoij Aug 03 '19 at 13:09
  • 2
    I solved this problem. Tendermint's api sent encoded string and before decoding with base64 I must decode this one with tendermint's codec because i used Cosmos SDK and this message was encoded when i sent transaction with Cosmos SDK's tools – godvlpr Aug 04 '19 at 19:08

0 Answers0