[Ethereum] How to sign a transaction in Rust

parityraw-transactionrustserver-side

Given a private key, I would like to sign a transaction offline, so it can be sent to a node or Infura without unlocking an account first. I can find many examples in javascript using ethereumjs-tx but I am using Rust and rust-web3 and can't find a single example that writes data. I need to be able to call functions, not just send value, so how to construct the function parameters is of particular interest. Also, how can I wait and process the return value if the function has a return value?

Best Answer

There is a package for this called ethereum-tx-sign on crates.io. It provides a RawTransaction structure with a sign method. It doesn't have any dependency on web3 and you can sign the transactions offline.

Related Topic