Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solidity method hash mismatch #204

Closed
kumavis opened this issue May 16, 2015 · 2 comments
Closed

Solidity method hash mismatch #204

kumavis opened this issue May 16, 2015 · 2 comments

Comments

@kumavis
Copy link
Contributor

kumavis commented May 16, 2015

im having an issue calling a solidity function
following the trace in the stack and comparing to byte code I can see that it is trying to match the target function signature and the available function signatures
but there is no match and it falls past all of them and hits the STOP

web3 is 0.4.2, solc is 0.9.21

methods

  • 0c9d7d48
  • 141961bc
  • 19ac74bd
  • 278ecde1
  • 2c0f7b6f
  • a87430ba
  • c1cbbca7
  • e1152343

target

  • bfe04e52

hard to tell but it seems like this is where cpp is generating the hashes of the methods
u256(FixedHash<4>::Arith(it.first))
https://github.com/ethereum/cpp-ethereum/blob/80ff45c4ef2a8b40f97c53a87118a92089f26a2f/libsolidity/Compiler.cpp#L180

whereas web3 does this
web3.sha3(web3.fromAscii(this._name)).slice(2, 10);
https://github.com/ethereum/web3.js/blob/25d9f5121735b76481b2518fe49ae285b75bac4d/lib/web3/function.js#L71-L73

@chriseth
Copy link
Contributor

The ways to generate the hashes are the same: web3.sha3 returns a string of the form "0xabcde...", so slicing it at (2, 10) is correct. Can you tell us the signatures of the functions?

@kumavis
Copy link
Contributor Author

kumavis commented May 17, 2015

This turned out to be my fault, my web3.sha3 was not ignoring the 0x at the beginning

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants