3

I'm trying to get the raw value of the transaction without using the websocket. For now I'm using a WebSocket for my application and I am in the process of removing it, I could find everything I wanted on substrate expect the original value in "extrinsics". Is there a way to get it ? My current work is to to try to rebuilt it with the data from the block that I received from substrate but not sure of how this can be done. But even if this can be done, every type of transaction has a different content and that is opening the door for lot of mistakes.

{
"block": {
 "header": {
   "parentHash": "0x723d60ec7870e881477ee638aae8b9226e37d0b1c1d0a8b8fbea08d5594e412d",
   "number": "0x1b",
   "stateRoot": "0x7ffe18a6a48979ccf0f41b5ae31bcf14076ba60cf3e006a33856cd0411df9465",
   "extrinsicsRoot": "0x80f5180564d5f5dc1b98e18abbd383dc35f0bc0ec996c517bc07316c431da1a9",
   "digest": {
     "logs": [
       "0x0642414245b5010300000000e7e2cd1000000000f0ce7e95377374a4a1d157034f14d949547bb25acebcc2533a1ef94690203409f596f4167f577ec5971f2718da3005d80258de8008f42833a8bed8b812b45e082d1d9f452808a6df2529e5a8d8a7cb36e581460063576d9f77ced3a91a5e2a06",
       "0x054241424501013e06daff0861a460e3e4433e06d9ea3e1a03c72d4725fa2d8d4cfc995a9b3b3e07e64b9f63200c05b895a69746c63d21ebf319ca525604356a70dede74522881"
     ]
   }
 },
 "extrinsics": [
   "0x280403000b100676d98901",
   "0xa105043600040000000000cc7593f343f0e7386bbf1ac7a3891f6cd8285260aab616ebbb6dc13a3334654466212cccbc2f2381610a7b094cdac6c6878a49c2af9a3c127d15c769ff7f93870000e41cee5fe6ab936f465874a8c6bac34fc0c0cdea153c01c3aeedb276dd30c6b16841043b15dce2a5c9d8c800c6999815bcc68efc7ed0401186dada1e935c415b4a7ab3d76daa16850f1bb470666f2d9a27849d8fec56fac55931f8062cfc17281f080642414245b5010100000000e6e2cd10000000008a356eca73e2f18c3c301a59d96b3e21f4f9b939a697e596135c657f9b18243cb1a2d946ade5a0b2eb743d26fa539051d39775946231a0b595f18a7e86c98100238d68623624e1ebebc7a519ca429cb7892425ade17e0789963f8fccebfd360505424142450101a6423a420b9a524e2e2df92777a134ddc4da865f82f6ed94b9273972d6adfd0975a926e70a6332e055edceb3e6e36a57973f8b6c1cd05a8bac57e87bf2c8cc8c",
   "0x41028400d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d01b8b84d2b12deb6519799e4a14c0b1c4138bb25f9d60a50ec320967982675eb69f1ea2fa65419ab354d7780c082fad3d41d45b4db43061cc7a73b2d432987b6848501040005070056f14a2288b6ab1668ea4281a830666821431ba62cfbdf6fb432f468ba56116d07005cb2ec22"
 ]
},
"justifications": null
}

I would like this value

0x41028400d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d01b8b84d2b12deb6519799e4a14c0b1c4138bb25f9d60a50ec320967982675eb69f1ea2fa65419ab354d7780c082fad3d41d45b4db43061cc7a73b2d432987b6848501040005070056f14a2288b6ab1668ea4281a830666821431ba62cfbdf6fb432f468ba56116d07005cb2ec22

The best way would be directly from substrate and if not possible build from what substrate gives me. Is this possible without websocket ?

2
  • What are you trying to achieve from taking this approch? scale-value crate can be used for dynamicly deserialising scale if you don't want to use the standard per-parachain strong typing routes that subxt gives. (You're asking how to decode a block and get the extrinsics. It's a little tricky because of the sign extras on each signed transaction. I have a go here but don't take it as gospel: github.com/gilescope/polkadyn/blob/… )
    – Squirrel
    Aug 11 at 7:53
  • You could do http(s) rather than websocket but if you want to get the data in binary then you'd have to talk libp2p with a node (non-trivial). At the moment hex encoded scale encoded in json is as good as it gets.
    – Squirrel
    Aug 11 at 7:56

1 Answer 1

2

You can also use the endpoint /blocks/:blockId/extrinsics-raw of Sidecar which returns a block along with its extrinsics as hex strings. This endpoint was added on v17.3.0 and the response it returns is very similar to what you need :

{
  "parentHash": "0x949c61fe1ad22f823efa036d1fc7c7bc6e20462d595ad63e29edbb8ddb88e2ff",
  "number": "0x0111da7e",
  "stateRoot": "0x8aaf3eebc40116ce71a883454623df3a608da3c5cd940800d8ca0c10910959bf",
  "extrinsicRoot": "0xe34596913819f563d0880e2b33ea8f8016d0c8dd62abd0d0383d0f7a938825d8",
  "digest": {
    "logs": [
      {
        "type": "PreRuntime",
        "index": "6",
        "value": [
          "0x42414245",
          "0x035400000031ecdf100000000018e190a2cf7e332a60fe86950752e2b9b9f446bd71628832a2646603f7ee244e65002b815a440e2e625cbb629ad4165c6aa78e76a0dec009eea0b8e0e1f50f0f6d59bc98b2f6f31d7003255cabf900cc811bfb67d9484fb08ee8d2b0d5709b0f"
        ]
      },
      {
        "type": "Seal",
        "index": "5",
        "value": [
          "0x42414245",
          "0x2cc27242fbc6904860eb252e32b3fa2feb9f26c6e27a52308b7a11b44230f42e23d84ed628a8cd570e2cba8860ebcbf687af25e564013ff707e2ac6f278b498e"
        ]
      }
    ]
   },
   "extrinsics": [
   "0x280403000b70bc2f808b01",
      "0x86680200043600a104ec3f2410c680ad000000000000cefcd9bf686783c725c83d0ec8164bd1a3d3330deefe2bc4f67e1a74514970429d6f9019be7ce7a33a0c1c2808946fa9a5463febb7b6b701e7d6885d98e62b89ec3f2410c680ad000001000000a8d......",
      "0xad0184009a2960ba755f4f91f2ecbd9ba881baead34353d33eac421d289d925c96738e320148b27c6f9f0dcbab22a035da3a97c4d0f273e0316e1b027a0bb2d6c45a8761688ed14840ba28082a2d1ce7b4520e5895513971791ad1a8137f8f9a072679908a8503290100270101"
      ]
}

More details about the endpoint can be found in the PR that implemented it and the docs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.