[Ethereum] web3.toAscii(transaction hash) for web3js version 1

javascripttransactionsweb3js

When i used web3.toAscii I received the following error :

enter image description here

I think the reason is my web3 version i.e. '1.0.0-beta.34'

If so, is there any alternative command for web3 version 1 for the following command ?

transaction = web3.eth.getTransaction('0x0c485e0f155f7f216d06e70ef85b684392c9b190c2f7c0af67ec1b56d6945498')
input = web3.toAscii(transaction.input)
console.log(input)

I also used following command :

web3.utils.hexToAscii(0x0c485e0f155f7f216d06e70ef85b684392c9b190c2f7c0af67ec1b56d6945498)

However, I receive the following error :

enter image description here

That mean its input cannot be a transaction hash.

Best Answer

The equivalent should be web3.utils.hexToAscii

web3.utils.hexToAscii('0x4920686176652031303021');
> "I have 100!"
Related Topic