23

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

eth
  • 85,679
  • 53
  • 285
  • 406
tokyomonogatari
  • 233
  • 1
  • 2
  • 6

2 Answers2

28

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.

mKoeppelmann
  • 7,616
  • 8
  • 36
  • 48
  • 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 03 '20 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 '20 at 03:08
  • 1
    @MichaelMartin 's answer addresses the issue that I was referring to. – Ajoy Bhatia Apr 29 '20 at 03:11
  • @ajoy-bhatia, you might want to check out the 'baseline protocol' project. Either way, code can't often judge the 'intent' behind an event, and this might be something that would have to be taken to a court of law, eg party b was able to see the code, but didn't realise that party a was doing something fraudulent – timhc22 Apr 29 '20 at 22:49
  • @timhc22 in the United States, an agreement is legally enforceable if the parties involved intended to enter it. This is why contracts don't legally require signatures if intent can be proven. If two people intend to execute a contract together on Ethereum using a smart contract, that is undoubtedly enforceable by law. – trndjc May 20 '21 at 01:04
3

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