rust-ethereum / ethabi

Encode and decode smart contract invocations
Apache License 2.0
517 stars 186 forks source link

Function should have a method to retrieve the 4 byte signature #243

Closed ryanobjc closed 3 years ago

ryanobjc commented 3 years ago

Function has been written towards encoding rust types for sending transactions. But decoding on-chain bytes given an ABI is another important use case.

One blocker is Function cannot tell you what the 4 byte signature is. Doing it 'yourself' is hard because the signature module is private (so one would have to re-invent that code), and the 'input_param_types()' method is also private.

Hashing the results of 'signature' isn't sufficient since ETH smart contracts don't use the return type in the hash.

ryanobjc commented 3 years ago

it would be nice if this function could be added to the 14.x series. Since web3 doesn't yet support ethabi 15, I can't use this new API!

alex88 commented 2 years ago

@ryanobjc had the same issue, you can use the master repo and you get the function