0 votes
1 view
in Blockchain by (11.8k points)

I fired one transaction on Sawtooth. I can see transaction data using API. My question is how to decode the transaction payload.

{

      "header": {

        "batcher_public_key": "03d58421f80cf7f2d51efd7f4fc28fd07a81de146f7d01acc70c9e5dcfdf2cc20f",

        "dependencies": [],

        "family_name": "document",

        "family_version": "1.0",

        "inputs": [

          "7d5acb"

        ],

        "nonce": "",

        "outputs": [

          "7d5acb"

        ],

        "payload_sha512": "9be6b4029768c2dda71b86eed2b1ba441442ec56714b863993f12aeab09242ef84087bc53b0cfadb93bbf99bcc7cdb8e03d71b1158887c8c3735abafb9765a43",

        "signer_public_key": "03d58421f80cf7f2d51efd7f4fc28fd07a81de146f7d01acc70c9e5dcfdf2cc20f"

      },

      "header_signature": "e4379a4a4f66c52677df299ddc136a968efb64fba9de30acdf230a719442cdc56c2cf55953c14bbc5cc68991a8bef156df3d32fcf6c37f201c279f6ad7065cab",

      "payload": "o2RWZXJiY3NldGROYW1leCBlZjlkMThjZGIwYjNkZDNmNWU1ZWE2MDliZjY3MDhmOWVWYWx1ZWA="

    }

I want to decode payload": "o2RWZXJiY3NldGROYW1leCBlZjlkMThjZGIwYjNkZDNmNWU1ZWE2MDliZjY3MDhmOWVWYWx1ZWA=".

Can anyone please guide.

1 Answer

0 votes
by (27.7k points)

The sawtooth rest-API returns base64 encoded data, First, you have to decode your Data

import base64
    decoded = base64.b64decode("o2RWZXJiY3NldGROYW1leCBlZjlkMThjZGIwYjNkZDNmNWU1ZWE2MDliZjY3MDhmOWVWYWx1ZWA=")

 it really depends on how you encoded your data, Use deserialization for
cbor, protobuf, etc.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...