18

How can I retrieve the solidity code of an already published contract in the mist wallet?

22

There is no general solution for this because the solidity code is not published on the blockchain. On the blockchain only the resulting byte code is published. There are different block explorers like ether.camp that offer the option to upload the solidity code. They can use the solidity code to verify that it indeed matches with the byte code on the address.

There is one project that aims to do this automatically by scraping github repositories for source code that fits to published byte code.

| improve this answer | |
  • 1
    It seems to me that "contract" is really a misnomer if the Solidity code is not known to the person calling its functions. If a party creates a real contract, which defines the terms of an agreement, and then asks another party to sign it without showing what the terms are, I think they would be shown the door, laughing all the way. So how can a piece of code be called a "contract" if only one of the signatories knows its contents? – Ajoy Bhatia Feb 13 '18 at 18:52
  • 2
    I think your example though tells you exactly why it can be called a contract. You wouldn't sign a contract without reading it, as you mentioned. In this case, you can see the byte code on the blockchain, but not the source code. However, you can easily ask the other party for the source code, and verify that the byte code matches the source code you were given before you make any commitments to it. – Michael Martin Apr 28 '19 at 16:45
  • @AjoyBhatia it is important not to mix up a 'legal' contract with a 'technical' contract, a smart contract merely executes a piece of code, but it is only 'legally binding' if a society is confident that a court will respond in a certain way if the contract is broken. Albert Ni spoke a bit about this at the recent EthGlobal Hackathon in London. The video should be uploaded soon. – timhc22 Mar 3 at 13:44
  • @timhc22 - I get that, but I presumed that the reason that some code on the Ethereum blockchain is called a "contract" is that it is seen as analogous to a legal contract. It is said that with blockchain technology, we can have "self-executing" contracts - i.e. contracts which themselves verify the conditions of the contract and execute the next step, so that escrow is not needed, for example. In practice, I don't see Solidarity code as being anywhere near a contract between multiple parties unless those parties can verify that the code written actually does what it is supposed to do. – Ajoy Bhatia Apr 29 at 3:08
  • @MichaelMartin 's answer addresses the issue that I was referring to. – Ajoy Bhatia Apr 29 at 3:11
2

See source at https://github.com/comaeio/porosity It does exactly what you need.

| improve this answer | |

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.