I'm trying to post a transaction with a message on a local ethereum blockchain using the data field. I don't know how to retrieve the message.
code:
import web3
w3 = web3.Web3(web3.HTTPProvider("http://127.0.0.1:7545"))
alice = w3.eth.accounts[0]
text = b'Hello'
print(text)
tx = {
'from': alice,
'to': alice,
'data': text,
}
tx_hash = w3.eth.sendTransaction(tx)
tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)
my_tx = w3.eth.getTransaction(tx_hash)
print(my_tx.input)
output:
b'Hello'
0x48656c6c6f
I want to retrieve the original message 'Hello'.