I have functions which are forced to return a bytes32 object, but then in my webapp I need to reconvert them to a classic string. How can I do that?
Asked
Active
Viewed 7,245 times
13
eth
- 85,679
- 53
- 285
- 406
arodriguezdonaire
- 3,027
- 3
- 20
- 37
2 Answers
15
Try using the web3.js function web3.toAscii (doc), which might change name to web3.toUtf8 or something similar in the future.
MrChico
- 1,786
- 14
- 19
1
In version 1.0 of web3 js use the new utils function
web3.utils.hexToAscii('0x4920686176652031303021')
philip_nunoo
- 111
- 2
https://web3js.readthedocs.io/en/1.0/web3-utils.html
– Jonathan Scialpi Sep 06 '18 at 10:52