I am trying to visualise transactions for Ethereum, currently, I know there are blockchain explorers such as Etherscan.io and Etherchain.org, however I don't want to keep calling their API to get data, rather use my own full node to get all the data I require since it give me greater control.
So I set up a full node and use the Web3JS library to get blocks and transactions. However, the Web3JS doesn't have the option to get an account via given address (unless I am mistaken). So, once I have the transaction object, I can figure out who the sender and receiver are, but I also want to know whether the sender or receiver is a contract or an account. I know on etherchain's API we can get accounts using the address, is it possible to do the same using geth and Web3Js?
Ethereum's yellow paper mentions that each account has a nonce, balance, storageHash and codeHash, so I thought it would be possible to get an account using addresses from the blockchain. Please help we figure out how to determine whether a given address is a contract or an account, without using blockchain explorers mentioned above?
getCodereturns 0x0, then that address is clearly not a contract. Presumably, the OP is asking the question because he/she wants to know if an address that has interacted with his/her dapp is a contract (and perhaps behave differently). If it's already interacted, and getCode returns 0x0, isn't it true that it is not (and never will be) a contract? I'm not saying it is, I just confused by the previous comment. – Thomas Jay Rush Mar 12 '17 at 16:28