2

I am trying to find out how parse a transaction using the RPC.

I am running both a carthage and main net node on localhost. Both are rolling nodes.

I have previously read this answer but I cannot get the parsing part to work.

Forging a tx works fine, using the exact same values as in the aforementioned post:

tezos-client -l -P 8732 rpc post chains/main/blocks/head/helpers/forge/operations with '{ "branch": "BLNbywpgiWAgniGbxjoEKhbniMbG4G6sePkXGe99eNPJmVsnskA", "contents": [ { "kind": "transaction", "source": "tz1NfEiS2uJsX43vowNjau5pdqg3Nvy8whvc", "destination": "KT1Ec3jNXyxyA54nezwcjGDRoutECJCQjpya", "fee": "1274", "counter": "86610", "gas_limit": "10100", "storage_limit": "0", "amount": "5060726" } ]}'

I obviously get the same response:

"57037ede6eb1863e65b46c54e08dac3f70be870b4a168db3615b66fb07964ff36c002122d44d997e158c36c60649d198c4175dad425efa09d2a405f44e00f6f0b40201420eaa410ac21addf427211cddd6115cba385a940000"

Now padding it the parse operation with zeroes does not work:

tezos-client -l -P 8732 rpc post chains/main/blocks/head/helpers/parse/operations with '{ "operations": [ { "data": "0800002122d44d997e158c36c60649d198c4175dad425efa09d2a405f44e00f6f0b40201420eaa410ac21addf427211cddd6115cba385a94000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "branch": "BLpcXF8ADJbGuyUKNv7TypXRd5rqnoPn3PMqJLNBeRSr4VFeUuK"} ] }'


The node replies:

Command failed : The operation cannot be parsed

I have also tried with signing transactions with my own private key, using the current branch on head, but nothing works.

What am I missing?

1

I put together a series of tutorials on how to use the Tezos RPC, using postman to give people working examples. It covers some of the aspects like this that aren't documented too well. The link is below.

I believe your issue might be, as well as padding the forged hash with zeros at the end. You also need to remove the first 64 characters (which is the block hash), before it can be sent to the parse API. Have a look at the below to test it out

https://gitlab.com/camlcase-dev/tezos-rpc-postman

  • And the signature is just the last 128 hex characters of the transaction? Where can I find documentation on how the Tezos transactions are encoded? – Thorkil Værge Sep 21 '20 at 11:21
  • 1
    @ThorkilVærge 128 zero's, 64 zero hex bytes. We currently don't implement the forging ourselves ourselves, but its on our list of things to do. The folks over at Baking-Bad have a C# product that performs local forging: github.com/baking-bad/netezos/blob/master/Netezos.Forge/Local/… – Simon McLoughlin Sep 21 '20 at 11:30
  • But if I have the signature and an unsigned transaction, can't I just convert the signature to hex and append that to the unsigned tx to get the signed transaction? – Thorkil Værge Sep 21 '20 at 12:02
  • @ThorkilVærge you can yes. It all depends on how you are performing the operation and the specifics of your application. There are many reasons why you might not want to use the real signature, since its not checked by default anyway. We have one such example in our mobile application. For security reasons, the secret key should only be in RAM when absolutely necessary. In our app we present the user with some confirmation screens, before doing the injection. Its unnecessary to pass this data around multiple screens, possibly exposing it, when the RPC doesn't require the real thing. – Simon McLoughlin Sep 21 '20 at 13:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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