Let's say peer A is deployed a contract and exposes contract ABI. Peer B wants to join the same network.He have the ABI with him.But he wants to see the real contract code before joining the network.How peer B will be able to see that.
2 Answers
Unless Peer A has made the source code available, you will only be able to see the byte code (i.e., the compiled code).
Even if Peer A makes the source code available, however, you should still be cautious. If Peer A was malicious, he/she may have published source code with an identical ABI, but with different code behind the interface.
For this reason, if you really want to be ultra secure, you should get the source code, read it until you become comfortable that it does what it is supposed to do, and then compile it yourself into byte code. Not until you've confirmed that the byte code that you've compiled yourself is identical to what is running at the smart contract's address can you be certain that you fully understand what will happen if you send ETH there.
For example, this is the Golem factory contract (https://etherscan.io/address/0x7da82c7ab4771ff031b66538d2fb9b0b047f6cf9). As you can see, the source code has been "Verified." In this case, Etherscan performed the process I describe above, and you can be confident that the source and the byte code are identical.
- 9,943
- 4
- 31
- 72
Peer A should have posted it at GitHub.com/(TheRelevantRepositorySubdirectoryHere).
Otherwise, it is available on the block in question as bytecode. The EVM executes this bytecode when the contract is used: such as storing/changing data or using a constant function. Of course, there's always bytecode to opcode converters.
Related: https://stackoverflow.com/questions/33798205/how-to-get-or-verify-the-source-code-of-a-contract
- 792
- 1
- 8
- 14
-
Registering the contract code in Git holds good for public network.But if I am using private network what should we do then. – Budhaditya Dutta Jun 15 '17 at 09:50
-
@BudhadityaDutta You need to get the code from that person directly. Otherwise, you'll just see the bytecode. – Jossie Calderon Jun 15 '17 at 10:29
inputdata field. I think the OP is asking about the Solidity 'source code'. – Thomas Jay Rush Jul 15 '17 at 20:40