miguelmota / ethereum-development-with-go-book

📖 A little guide book on Ethereum Development with Go (golang)
https://goethereumbook.org
Other
1.74k stars 427 forks source link

Cannot get transaction's field "From" #3

Closed ghost closed 6 years ago

ghost commented 6 years ago

https://github.com/miguelmota/ethereum-development-with-go-book/blob/master/code/transactions.go - this code don't show transaction's field "From".

For instance, for transaction https://etherscan.io/tx/0x5d49fcaa394c97ec8a9c3e7bd9e8388d420fb050a52083ca52ff24b3b65bc9c2 it shows nothing.

For transaction https://etherscan.io/tx/0x36368eb4665367100bcb46427e8ac39b7873abfca2015116c478f84642a8812d it shows 0x0000000000000000000000000000000000000000

miguelmota commented 6 years ago

Hi @invisible73, the example code shows how to read the transactions FROM address. Take a look below:

Transaction hash (orange) and transaction FROM (red)

screen shot 2018-08-27 at 1 20 31 pm

Transaction hash (orange) and transaction FROM (red)

screen shot 2018-08-27 at 1 20 19 pm

Hope this helps. Please reopen issue if you have more questions

ghost commented 6 years ago

Yes, I understand that. Problem is that here is no "from" value in result.

What I have as result:

0x5d49fcaa394c97ec8a9c3e7bd9e8388d420fb050a52083ca52ff24b3b65bc9c2 10000000000000000 105000 102000000000 110644 [] 0x55fE59D8Ad77035154dDd0AD0388D09Dd4047A8e 1 0x3d3442a9b1d8a0b99bfebeff26836afdc966f6e24d3b9feeb580e22dce7f968c 2000000000000000000 105000 102000000000 110645 [] 0x12fe1ECc85F4f4b3Ceb2281aAb5ED5fEB046ad7a 1 0x36368eb4665367100bcb46427e8ac39b7873abfca2015116c478f84642a8812d 130590449340000000000 100000 91000000000 46367 [] 0xc494A03D990582cD9CA9C2EE4a64DD49548F6DF5 0x0000000000000000000000000000000000000000

What I expect:

0x5d49fcaa394c97ec8a9c3e7bd9e8388d420fb050a52083ca52ff24b3b65bc9c2 10000000000000000 105000 102000000000 110644 [] 0x55fE59D8Ad77035154dDd0AD0388D09Dd4047A8e 0x0fd081e3bb178dc45c0cb23202069dda57064258 <- field "from" 1 0x3d3442a9b1d8a0b99bfebeff26836afdc966f6e24d3b9feeb580e22dce7f968c 2000000000000000000 105000 102000000000 110645 [] 0x12fe1ECc85F4f4b3Ceb2281aAb5ED5fEB046ad7a 0x0fd081e3bb178dc45c0cb23202069dda57064258 <- field "from" 1 0x36368eb4665367100bcb46427e8ac39b7873abfca2015116c478f84642a8812d 130590449340000000000 100000 91000000000 46367 [] 0xc494A03D990582cD9CA9C2EE4a64DD49548F6DF5 0x0000000000000000000000000000000000000000 <- field "from", should be 0x5521a68d4f8253fc44bfb1490249369b3e299a4a

ghost commented 6 years ago

https://github.com/miguelmota/ethereum-development-with-go-book/pull/5/files - pull-request to fix that

miguelmota commented 6 years ago

@invisible73 thanks for the fix! the error was that I had err != nil instead of err == nil