Search code examples
c#ethereumnethereum

How to parse a signed transaction in Nethereum?


I made a transaction using TransactionSigner.SignTransaction(...), and stored it for future reference. How do I parse it back to get the public key/source wallet address, destination address, nonce, and the amount in Wei?

I tried searching the GitHub repo for Parse method, but found none for transactions.


Solution

  • You will need to use the Nethereum.Signer.TransactionFactory, https://github.com/Nethereum/Nethereum/blob/master/src/Nethereum.Signer/TransactionFactory.cs

    The TransactionFactory checks based on the RLP the way the transaction has been signed (using a ChainId or the default one).

    Depending of the way it was signed you will be returned a Transaction https://github.com/Nethereum/Nethereum/blob/master/src/Nethereum.Signer/Transaction.cs or a TransactionChainId https://github.com/Nethereum/Nethereum/blob/master/src/Nethereum.Signer/TransactionChainId.cs

    P.S Thanks for referencing this question in Nethereum gitter.