Hacker News new | past | comments | ask | show | jobs | submit login
How to Learn Solidity: The Ultimate Ethereum Coding Guide (blockgeeks.com)
133 points by PetrolMan on June 5, 2017 | hide | past | favorite | 53 comments



And remember, that there's a special function called VIP() .

This is an implied function that wraps around your full code. This is instantiated if/when core founders are losing money on a function that possibly had a bug in it. This function returns the wrapped function, under the guise of a new blockchain, with invalidations applied to all 'unintentional' side effects of bad or buggy code.

It happened with the DAO, because founders lost too much money. Just be aware, that VIP() can happen to your code, regardless if your implementation is a bug or intentional. Wrong people losing money means VIP() returns successful.


The real story of what happened during the DAO to me seemed like fast, responsive, and intelligent leadership.

They had a problem, they asked the community how they would like it dealt with, and acted accordingly.

Saying the founders were losing too much money so they hard forked it is a gross misrepresentation of the reality. It's like a Fox News representation of what actually happened.


It's completely the wrong way to handle this. To me, this "currency" is dead. There is no trust, other than if the creators lose more money on a venture, they'll "convince" the community to reverse it. I remember reading and playing around with it when it came out. It was raw, bare, and frankly awesome. The base tenant was that:

"The Contract is the Code, and the Code is the Contract."

It was a programmers no-man's land where anyone could stake a claim, and start doing cool stuff. And if you screwed up, it was your fault. Nobody else's. And you had to watch out, because it was easy to lose money into nothingness (yeah, BTC had checksums, Eth didnt - another point of amateur hour).

Until the DAO.

When that happened, I think $150m of Eth went into it. Massive amounts. The idea was to have a distributed living self-autonomous company. And, by the older ideals, lots of someones didn't do their homework. Or they did and it was intentional. Regardless, the "completely innocent magnanimous leaders of Ethereum" decided to force a Blockchain split, and rewind it all. Of course, Something like 2/3's of the total amount was owned by Ethdevs. Surprised? Nope.

Bitcoin? Sure, I'll play. But Ethereum has proved that if you are in the special class of people (Creators with loads of money lost), you don't matter. Nor do the ideas of what they were supposedly founded with.


> 2/3's of the total amount was owned by Ethdevs

Source?


I was in the irc room during that time. It was the number batted around by ethdevs in freenode #ethereum.

Regardless, the very people who build the protocol, application stack, and seed blockchain machines were also the ones who had massive stockpiles of eth from the auction... You do remember the auction, right?

They had absolute fiduciary reason to undo their losses.

Edit: And in all honesty, this would be compute-expensive, but the nature of the blockchain would be able to tell how much ethcoin came from before the auction rather easily. After all, a blockchain is just a append-only distributed ledger. Well, we did know the transactions, but you'd likely have to go to Ethereum Classic and replay what addresses put money in.


>I was in the irc room during that time. It was the number batted around by ethdevs in freenode #ethereum.

Let me guess, you don't have the logs. "I was in the irc room at the time" yeah okay that's credible. This is just hearsay FUD.


If it's dead then why are you here?


Because the premise of a compute based blockchain is inherently interesting. I'm very much for the furtherance of this topic and area of computation.

I believed that Ethereum initially had an interesting idea. I thought their system had little rigor in the way Bitcoin does... but I'm willing to look over pre-alpha stuff for the underlying concepts.

Tl;Dr. Showed up on top of HN. Greatly interested in the concept of compute-blockchain, but dissuaded of Ethereum specifically of company policy/choices.


To me, this turns me off to the entire tech, no matter how stupid and kneejerk that sounds. If the biggest draw to get me using your technology (immutable contracts) is actually not true, then I'm less inclined to give it a shot outside of novelty value.


Unfortunately it's not an honest portrayal of events.

Disclaimer: I was a DAO investor. The DAO held 5% of my Ether at the time of the attack.

Having said that, it's not as simple as saying: I support the DAO refund because it was in my best interest. That doesn't necessarily follow, and it didn't necessarily follow for most of the other DAO investors.

I still held 95% of my crypto $ in Ether. I would have been happy to eat the 5% loss if it would have been the right thing to do and instilled confidence in Ethereum and its leadership. There were many debates at that time about what the right course of action was, and it was a very hard decision. If saving 5% of my investment meant I ended up with a worthless 100%, it would be foolish to save that 5%. And everyone else knew this as well.

I think the decision the Ethereum team made was the best moral and legally advisable choice. They had the opportunity to stop the theft of 14% of all Ether, which would have gone to a criminal actor. It required a very risky solution (a hard fork) which came with big consequences (an alternative chain which remains to this day), so the solution wouldn't be feasible for smaller attacks (as some people like the poster before you try to allege). But for an attack which threatened 14% of the available supply, a hard fork to retrieve the funds was a viable solution.

Most of the market agrees with this decision. In the time since the Ether market cap has grown to the second largest of any cryptocurrency at 1/2 the size of Bitcoin. The alternative chain that didn't fork is still alive but only has less than 10% of the Ether market cap. The vast majority of dApps are running on the Ether chain. And it's the chain that is being taken seriously by enterprise (look up "Enterprise Ethereum Alliance"). Large businesses know the founders can't simply hard fork whenever they want to better themselves. The model works around consensus, consensus that is clearly shown by the considerations listed above, and I am glad that the consensus model is strong enough withstand an attack on 14% of its supply and respond with a difficult solution to rescue the chain from a catastrophe. It makes me feel more confidence in the technology, the community, and the protocol.


Your whole argument is predicated on the idea that what happened with the DAO was "theft".

All the publicity for the DAO explicitly said that the code was the full specification of the contract even if it disagreed with any other statements, and the code allowed someone to transfer the funds to their own child DAO. What crime, exactly, are you accusing them of committing when everyone agreed to a contract that allowed them to do what they did? How do I know using another contract won't be labeled theft and rolled back?

> Most of the market agrees with this decision.

This is exactly the problem. Ethereum would have been interesting if it could enforce unpopular decisions because they're specified in the code and them's the rules. Instead it will enforce them as long as there's not too much public outcry. No thanks.


> Your whole argument is predicated on the idea that what happened with the DAO was "theft".

So did the Ethereum Devs, who owned a bulk of coin from the initial auction. And they just so happened to also control development of the protocol AND the client programs. This was the message they "asked" users... https://upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Et...

"....IN WHICH FUNDS RELATED TO THE EXPLOIT ARE RESTORED...."

Consensus is nice, especially when you can manufacture it. Noam Chomsky talks about this in great detail. https://www.youtube.com/watch?v=tTBWfkE7BXU

Chomsky: "The first place to look is, who's in a position to make the decisions that determines the way a society functions."


Your two points:

> What crime, exactly, are you accusing them of committing when everyone agreed to a contract that allowed them to do what they did?

And

> How do I know using another contract won't be labeled theft and rolled back?

What the DAO hack revealed is the following fact, which I learned over the past year:

That there are two kinds of cryptocurrency holders, one group demands immutability at any cost, the other group demands 'reasonable immutability'.

The reason why ETH/ETC split was 90/10 because majority of the Ethereum holders fall in the second group, and majority of the people who fall in the first group holding nothing but bitcoins.


There is no morality on the blockchain.

As far as legality goes, I think the attacker is in the clear because what matters is the code and not the intentions.


Or, "the code is the contract" as they say.


> Ethereum contracts are unstoppable and uncensorable until a core developer loses money

Source: https://news.ycombinator.com/item?id=14162399


Maybe the immutability is not 100% now, but it will be when the technology is finalized, which will take a few more years. The fork to save DAO funds was a good thing, because otherwise too much ETH would have been in the hands of an attacker. The ETH distribution would have been skewed. That's all.


Can you really call the person an attacker when they simply used the contact as-written?

I think that's spinning things a bit to fit a narrative.


Yes you can call the person an attacker. The rules of a mature Ethereum protocol should be neutral to the intentions of users, including those that one would reasonably characterize as hackers, but Ethereum was not a mature protocol at the time. It was effectively in early-stage beta. The DAO was the first smart contract of its kind, and was expecting $500,000 worth of ETH to be deposited in it. Instead $150 million worth was deposited.

I believe that a fork like the DAO rescue would be perceived as totally unjustified and impractical today, and Ethereum is still a very young and experimental project. I think in a few years, when the network and technology are mature, such an application-rescue HF would be unthinkable.


Regardless of any of this, the person didn't attack anything.

I'm not saying my position on whether the fork was right or wrong, but I think folks on either side should not characterize that incident as an attack.


The project was very young, and the community miniscule, at the time. It could be justified as a one-time beginner's incident. The network and ecosystem can be expected to behave very differently when it's mature, or even today, given how much larger the community is now, and how much more aware people are of the risks facing smart contracts (which means there is much less justification to rescue those who put money in a complex smart contract that gets hacked).

The project itself made mistakes early on by not sufficiently warning people of the risks of the DAO, which gave justification for the do-over. I think they can be excused given the DAO was the very first smart contract of its kind, and given how much was deposited in the DAO so quickly, which was totally unexpected.

So I think Ethereum can easily be forgiven for the DAO and subsequent hard fork to redo it. It was a highly experimental technology, that saw a major hack of a early-stage application that was only aiming to attract $500,000 of ETH, but had ended up having $150 million worth of ETH deposited in it, when the ecosystem and the state of the technology were not ready.


> The project itself made mistakes early on by not sufficiently warning people of the risks of the DAO, which gave justification for the do-over.

This is the weakest justification I've heard out of all of them. How do you get a "do-over" for not realizing that weird new financial instruments are risky? And how does rolling back the risk make people more aware of risk? Anyone who was not aware of the risk the whole time deserves the most to lose their money.

The right time for the DAO to say "wait, guys, this is risky as hell and we have no idea what we're doing" and give back the money was before they lost the game they had created.

(The fact that you refer to this loss as their "smart" "contract" getting "hacked" indicates that you still don't want people to be aware of the risks.)


>How do you get a "do-over" for not realizing that weird new financial instruments are risky?

People didn't realize the smart contract was at great risk of being hacked, and the project, meaning thought leaders in Ethereum, were partially at fault for this, for not warning people.

This was the first smart contract of its type. It's easy to blame the community in hindsight. I choose to forgive it, as I remember early on in any endeavor, mistakes are normal.

>The fact that you refer to this loss as their "smart" "contract" getting "hacked" indicates that you still don't want people to be aware of the risks.

I don't follow. "Smart contract" is a term of art, and does not imply it's well made or secure. I also don't know what putting the quotations around the "hacked" is supposed to signify.


The "contract" was evaluated according to the rules that supposedly made it a contract, not hacked. Getting a bad deal in a contract is not getting hacked.

There will be more bad deals in the future because Solidity is badly designed. Mistakes are normal indeed, and Ethereum is certainly not done making them. Promising "this time it's for real, no more take-backs" is just increasing the risk unless they buy some insurance or something.

What's the indication that anyone is aware of the risks now, or that Ethereum devs are warning people of the risks? The investment in Ethereum has increased -- there are banks getting involved in this shit. The risk has not decreased. And yet the devs are still not handing back the investors' money and asking them to kindly wait until more security or insurance features are designed.


It was hacked from the perspective of ordinary people.

I address the sanctity of the protocol in an earlier comment:

>The rules of a mature Ethereum protocol should be neutral to the intentions of users, including those that one would reasonably characterize as hackers, but Ethereum was not a mature protocol at the time. It was effectively in early-stage beta.

>What's the indication that anyone is aware of the risks now, or that Ethereum devs are warning people of the risks?

That's what I've observed. I haven't compiled instances of social behaviour that indicates this so I have no objective evidence on-hand.

>The investment in Ethereum has increased -- there are banks getting involved in this shit

They're not putting hundreds of millions of dollars worth of ETH in complex smart contracts like the DAO.


This is simply not true. The protocol spec that the DAO was in is still alive and well. It's called ETC.

Could it be that you just resent the fact that people give a lot more value to a forked chain called ETH? This is understandable, since the DAO fail made clear that code run on blockchains still depend on human consensus. Code will run according to spec, but only as long as the people running the nodes decide to adopt a specific version of the protocol. Note that no blockchain tech, not even ETC, is free from this fact. You can run a blockchain using the protocol you want, but what gives it value is human consensus.

Ethereum is not a tech utopia. But it is a damn cool tech, and understanding its limitations is important to be able to take advantage of it.


Your Solidity contracts can run on Ethereum Classic, which you can be confident won't be forked since its users tend to believe in the principle of the immutability of the code.


The classic branch is still susceptible to the same problem, though. They didn't fork because of the DAO, but who's to say they won't fork because they don't like the result of a different contract?

If I'm going to trust the enforceability of my contract to some group of people, I trust the established legal system--warts and all--much more than the mob rule of the Ethereum crowd.


The dev team for Classic is much less likely to attempt to do so, and the miners less likely to adopt such a fork, since they declined to accept the fork the first time it happened.

If a fork happened in Classic to protect some party's financial interests, I think the more likely scenario is the great majority of miners opting to stay on the original branch.

I get that it's not a complete guarantee, but neither is the legal system. Contracts can be invalidated based on a judge's perception of their unfairness, on a technicality, or even on a whim.


>much more than the mob rule of the Ethereum crowd.

Also known as "miner consensus", same for all crypto currencies including btc


> The classic branch is still susceptible to the same problem, though.

So is bitcoin.


Ah, have fun over there


I'm not wholly on one side of the fence or the other on the fork. But since the decisions made by the community involved can affect your holdings, it's reasonable to advise people to choose the community that has similar values to them.

Unless they're interested for purely speculative purposes, in which case it was a good bet that the non-Classic version would be more remunerative.


The Core founders invested very little in the DAO, and pushing for a decision that went against the interests of the network would have hurt them far more through reducing the value of the portion of their holdings they still held, than helped by rescueing the portion they put in the DAO.

In short, you're mischaracterizing the motives of the lead developers who supported the HF.


The whole idea around proof-of-work based chains isn't immutability, it's that the longest chain always wins. If the majority of CPU power 'votes' for a particular chain that chain sits as the de-facto chain. For most chains this means >50% wins, as requiring anything higher for consensus increases the potential for network deadlock.

With that, are there any trust algorithms that aren't susceptible to 51% attacks? Ideally power (stake or hash in this case) is distributed amongst actors as much as possible. Cryptocurrency doesn't take us from centralized -> decentralized currency: it moves us from almost wholly centralized currency to more decentralized currency. The move is welcome but idealistically seeing the options as completely centralized or completely decentralized seems a bit misguided to me.


Just replace "code" with "valuable resource", and "founders" with "interested actors", and your comment is much more broadly applicable, if not universal.


Odd, I can't find this function whatsoever. By the way, Solidity is open source so there are no secrets - go look for yourself: https://github.com/ethereum/go-ethereum/search?utf8=%E2%9C%9...

No function as op describes, also no source or reference. Screams FUD, nothing to see here...


Citation? I have tried Googling it, but came up short.


One of the main Ethereum co-founders is working on a new experimental contract language targeting the Ethereum Virtual Machine called Viper which still seems to be under relatively active development[1].

Why pick Solidity if Viper and other languages like Low-level Lisp-like Language (LLL) by Consensys[2] are around the corner? Or is this just a matter of language flavour similar to how anybody can pick from a plethora of languages targeting the JVM (Clojure, Scala, Java, etc.)?

[1] https://github.com/ethereum/viper

[2] https://media.consensys.net/an-introduction-to-lll-for-ether...


Viper is not completed, and it might never be completed.

Solidity is here now, and the demand for Solidity developers is growing by the hour.


>>[...] it might never be completed.*

"Complete" is certainly in the eyes of the beholder, but Viper's author seems to think the language is "complete enough" to have started writing Ethereum's new Proof-of-Work/Proof-Of-Stake hybrid system (aka Casper contracts[1]) in Viper[2][3].

[1] https://www.ethnews.com/proof-of-stake-vitalik-buterin-share...

[2] https://ethereumclassic.github.io/blog/2017-03-13-viper/

[3] https://github.com/ethereum/casper/blob/master/README.md


I've been using Solidity for a bit. I wouldn't say it is my favorite language, it's a bit too javascripty for my personal preference, and its genuinely hard not to introduce subtle security flaws into the code. As a smart contract language it leaves a lot to be desired. That being said, it is really the only game in town on Ethereum right now. The other language implementations on the EVM are in various states of disuse. If you are interested in smart contracts on Ethereum you have to learn Solidity unless you want to reinvent the wheel with your own language implementation.


well said, agree with you!


Last year I was pretty excited about Ethereum for a few months. But then I got to thinking about the social problems I care about, like how factory and middle class jobs are being wiped out by robots and AI, and I couldn't think of how DAPS could fix those sorts of problems on a large scale.


People are not meant to work in factories. They're meant to own parts of factories and other productive enterprises. Ethereum reduces the barriers to entry to becoming a stakeholder in value created by enterprises. The cost to exchange a token is 1000X less than the cost to exchange a security. This is an orders of magnitude reduction in barriers to entry and expansion of liquidity. It means the economy can grow in all directions and become more inclusive in its ownership structure.

We're still very early days, but this is what distributed smart contracts make possible. The second and third order consequences of this will be enormous.


Do you mean people won't work in factories but instead sit around and collect profits, or do you mean people will work in factories but own them cooperatively, or that people will work but not in factories but in some other type of economic enterprises, or what?

And could you give me a link where this is described in more detail, including addressing various possible objections?


I mean people will sit around and collect profits.

I don't have any links about this. This is my own view on an ideal future. I haven't come across any objections to it.


>I don't have any links about this. This is my own view on an ideal future. I haven't come across any objections to it.

This is what I am talking about. Ethereum supporters think it is going to make the economy into an anarchist-libertarian techno-paradise, but they don't present specific ideas and write them up so they can be subjected to critical scrutiny. You know, lots of ideas seem great until you try to work them out.

My own thought is that economics starts with basic needs and desires, like for food, shelter, health care, internet access, and so on. Today these are provided largely by small and medium enterprises, and people earn their money working for them. I don't see how most of these things could be provided by DAPS, and so I conclude Ethereum isn't going to make much difference to the average person.


Here's a more detailed write-up on it:

https://www.reddit.com/r/Futurology/comments/61lg8g/the_robo...

You're right that there are no complete road maps written out. But proponents of this vision can hardly be blamed for not being able to create a detailed plan for things they believe will be invented. It will necessarily be impossible to predict exactly what form the future will take. Yet we can make reasonable extrapolations based on the nature of knowledge, and the role knowledge plays in investment.


FWIW: The current Humble Book Bundle does contains the book Introducing Ethereum and Solidity[1].

[1]: https://www.humblebundle.com/books/linux-book-bundle


Are there any resources more informed readers might suggest for building a "toy" EVM language? Say based on racket? Thought it might be a good way to understand things deeply.


Now this truly is a job for the future..


bullish. whenever the average HN comment is negative for new tech you know it's going to be huge.

great guide here too.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: