5

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.

  • The contract code is included in the data field of the transaction that has created it. – Ismael Jun 15 '17 at 6:03
  • The words "contract code" are a bit muddy. The 'byte code' is included in the input data field. I think the OP is asking about the Solidity 'source code'. – Thomas Jay Rush Jul 15 '17 at 20:40
  • Related: ethereum.stackexchange.com/questions/188/… – eth Jul 15 '17 at 23:31
3

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.

0

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

  • 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 9: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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.