7

This question already has an answer here:

On a Smart Contract called "mem" there is a function called "get()" that returns a bytes32 that is supposed to be a string. How can I decode the string? The result is an hex value. I have tried toString() on geth console, but I am probably doing something wrong...

mem.get(); "0x4d61726b65745061792e696f206973206465706c6f79696e6720536d61727420" mem.get().toString(); "0x4d61726b65745061792e696f206973206465706c6f79696e6720536d61727420" mem.get().toString('hex'); "0x4d61726b65745061792e696f206973206465706c6f79696e6720536d61727420"

marked as duplicate by The Officious BokkyPooBah, Community Sep 27 '16 at 12:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

10

You can use web3.toAscii(hexString) as documented in Web3 JavaScript Ðapp API:

> web3.toAscii("0x4d61726b65745061792e696f206973206465706c6f79696e6720536d61727420")
"MarketPay.io is deploying Smart "

You can also use web3.toUtf8(hexString):

> web3.toUtf8("0x4d61726b65745061792e696f206973206465706c6f79696e6720536d61727420")
"MarketPay.io is deploying Smart "

Not the answer you're looking for? Browse other questions tagged or ask your own question.