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

return value of web3.eth.sendTransaction #686

Closed
palango opened this issue Mar 7, 2018 · 4 comments · Fixed by #1883
Closed

return value of web3.eth.sendTransaction #686

palango opened this issue Mar 7, 2018 · 4 comments · Fixed by #1883

Comments

@palango
Copy link
Contributor

palango commented Mar 7, 2018

  • Version: 4.0.0-beta.11
  • Python: 3.6
  • OS: osx

What was wrong?

The return value of web3.eth.sendTransaction(...) seems to be HexBytes, not a str as shown in the docs.

How can it be fixed?

Fix the return value or fix the docs.

@carver
Copy link
Collaborator

carver commented Mar 21, 2018

👍 documentation fix TODO
(plus all the other methods that were changed to HexBytes)

@lmittmann
Copy link

Why has the return value been changed to HexBytes? I always need the string representation.

This is one of many changes in 4.0.0 that require lots of updates in my code base and are really annoying. Now I need to mess up my code with lots of Web3.toHex(...) conversions.

@pipermerriam
Copy link
Member

@lmittmann I'm sorry that the v3 -> v4 changes are causing you problems, however, there are good reasons behind all of these changes.

The HexBytes one specifically is part of a broader change removing ambiguity about return values and input values.

Given a string "0xabcd" we can't infer if this is the hex encoded value b'\xab\xcd', or the literal string "0xabcd". When returning values like this, we chose to use a bytes representation as that removes the ambiguity. However, we found that returning bytes was very unfriendly UX when inspecting return values, so we came up with a thin wrapper around the bytes type, HexBytes that when represented in a terminal, shows the hex encoded value.

@carver
Copy link
Collaborator

carver commented Apr 9, 2018

Now I need to mess up my code with lots of Web3.toHex(...) conversions.

Maybe a small solace, but from HexBytes, you can also call val.hex().

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

Successfully merging a pull request may close this issue.

4 participants