Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

professional etherem devs haven't even gotten to the point where they can write correct contracts themselves. but the concept is pretty simple.

a "smart contract" is a script that runs on a blockchain to execute terms and manage funds.

the problem is that the tools that you use to make these are basically garbage. you don't write fin-tech in what amounts to javascript y'know?



Normally, if you deal with money, then you try to be extremely careful, right? You have to care much about security, verify that your app is not vulnerable, make an audit etc.

And I think that even beginners know that you can't trust users' input - you have to sanitize it. And under no circumstances you want to execute it!

But here it is the opposite, isn't it? You basically give users ability to run any code within your application (blockchain). And you give them very insecure, confusing and badly designed language.

To me it is an epitome of insecurity. It is like giving a shotgun to a child!


Users cannot run 'any code'. They can run contract code, which can only interact with the underlying application through a protocol. The multisig hack was not a case of the underlying application being compromised. The contract itself was compromised due to a vulnerability in its code. The only parties affected were those that trusted the contract. The rest of the contracts operating on the application were unaffected.


the problem is that the tools don't facilitate writing correct contracts

i don't know how to do this myself, mind your. to be broadly applicable the tech has to be accessible to people who would be writing contracts. a fucking professional using the state of the art for this shit has very little tooling support for checking that the contract actually operates in a particular fashion.

something like an SQL query planner that helps you write contracts


Write your own tools.

The EVM, which is what executes contracts, has a public spec. It's a bytecode machine and writing a compiler for it should be rather trivial compared to x86.

There are also several other languages you can code in and there are some code verifier tools that allow you to check if your contract is good.

The problem is that despite these tools existing, even if they are used, they are underused.


Writing custom tools is not a solution for the standard professional developer. If Ethereum is to take off, it will need one of

* Little to none "get up and running" time. Custom tools don't allow for that.

* Provide such tremendous value that it is worth overcoming the initial setup hurdle.

Right now, Ethereum has neither.


There are plenty of alternative tools for Ethereum, including alternative languages.

I was merely pointing out that nobody is being stopped from improving the situation, if it was as bad as some portrait it.


To be fair, traditional "dumb" contracts written by lawyers also have exploits and loopholes. That's why we have courts with judges and juries that can make subjective decisions based on context outside of the contract. Smart contracts don't allow for that subjective judgment, and thus won't work in a subjective society.


That's a different subject. I was only addressing the notion that Ethereum the application is at risk from the code that users run on it.

I completely agree that the tools and processes for writing and testing smart contracts need to improve.


Solidity's relationship to JavaScript is negligible and way overplayed in its marketing. Similarities are entirely superficial.


This 100%. I think this becomes evident almost as soon as one tries to do any smart contract coding. It's an entirely different paradigm with considerations that dwarf anything about language syntax and style. In fact I think these considerations are very non-trivial to grasp.


I agree, the syntax being similar doesn't really mean much for similarity when it comes to actually solving problems.


What would be an example of a "smart contract"?


A kickstarter clone, that could be implemented in a few lines of code on top of Ethereum..

If there is > 1,000 Ether in this contract address before timestamp x then send the Ether to the project lead, else refund all the users.


Nice! Thank you. You know there are many different types of contracts, why didn't they just call it 'smart transactions'?


Because it's conceptually more like a contract. Someone writes the contract code, and then by uploading and depositing money into the contract it's as if they signed it. After that point it works without anyone needing to trust the signer.

And they can include conditions about arbitrary information that is reported on the blockchain (weather data, stock prices, etc...)

And multiple people can sign these things. They really are like contracts.


Their main use case is maintaining critical/sensitive state information that you want to protect via rules of interaction between multiple parties (that don't trust each other) without the need for a trusted intermediary. The contract is tamper proof and only via correctly and cryptographically signing messages/transactions intended for the smart contract will the state of the smart contract change, but only according to the rules defined in the smart contract.

The (non-fintec) example I often hear about often is a voting system. (See: https://github.com/stonecoldpat/anonymousvoting , here zk-snarks algorithm is introduced to ensure privacy)

Essentially anything that requires co-ordination between parties that don't trust each other over a piece of data (a balance of money, the tally of a ballot) is a perfect use case for smart contracts. But since there is cost to running it on these secure networks it is important that they remain O(1) or at most O(n) time complexity, which for these kinds of applications is often totally enough. (eg. if (the message is signed by the 'owner') { send the funds } else { throw })


Basic smart contract found here:

https://blockgeeks.com/guides/smart-contracts/


Another interesting use case is for supply chain management, since the history of a interactions relating product can be documented in a secure manner Eg. you can buy a nike shoe that you can cryptographically validate that it was signed off by Nike, who made it, when they made it, when it was shipped, and even how much each of these parties got paid for their service. (Take a listen here: https://media.consensys.net/state-change-44-shining-a-light-...)


I can write secure smart contracts in Solidity or straight in EVM assembly, it's really not that hard as long as you code it defensively.


People were saying the same thing about non-C++ back in the day. "Web apps aren't written in scripting languages y'know?"


I view this more as "web apps should not be written in C++ due to security issues that we have long come to understand" than "web apps should be written in C++ due to performance issues we are guessing at"... like, do you believe that in a few years people will decide "no, strongly typed and proof assisted languages were overkill for contracts: it was actually better to code them in a language that has weirdly fluid rules and type semantics for reasons they did not quite grok in 2017"?


This criticism doesn't apply to Ethereum. Solidity is compiled to a VM. You can write other languages that meet your criteria that still use Ethereum.


I know, and I am very excited for those languages to exist and be usable, and thereby have been tracking a couple such efforts; until then, this is about as useful as pointing out that website development is theoretically possible using a computer. The person did not state that it would always be the case that smart contracts are hard: only that right now, on Ethereum, they are hard, and the comment even used "gotten to the point where" (indicating this is a temporary state) and specifically blamed the "tools", which is all absolutely true and is born out not just in theory but in practice; it doesn't even disagree with your own statements that other different tools would be better. Why are you so defensive about this commentary?


I'm like a goalie. Defense is my game.

Actually, I didn't mean to come across as defensive. I just like to nerd out about tech.

Once you accept the inherent craziness of the proposal, and go "Ok, this is crazy. What now?" you end up concluding that the future is going to be very interesting. It'd be worth investing some amount (that you can afford to lose!) in ETH on the off-chance that it doesn't suffer a major disaster. There are quite a few interesting applications for this technology, and historically that's been a pretty solid bet.


The main thing to keep in mind at this point in time is that these contracts have very little tolerance for inefficiency, since inefficiency in this case costs money. Even solidity is very inefficient. Sure it would be great to write contracts in Haskell or Coq but can you insure O(1) or at most O(n) run time with little to no constant overhead? For example LLL (Low-Level Lisp-Like Language) produces 70% more efficient code than solidity [1] and thus it is the chosen language for the ENS (Ethereum Name Service) registry smart contract (who wouldn't want to pay 70 less for interacting with a contract?). But no doubt, better languages will come with time :)

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


Difference being that a poorly written web app amounts to some leaked passwords and email addresses.

A poorly written smart contract that handles real money, on the other hand...


So? It's their money to lose.

Yes, it's crazy, but it's also happening.


Agreed, and the massive hacks and losses will continue as long as smart contracts are written in Solidity.


The EVM is Turing-complete, so this will be a risk with any language that compiles into a smart contract.

Solidity doesn't appeal to me because its goal seems to be on-boarding JavaScript programmers. But new languages that compile to EVM can be easier to use "safely" and you will see several of these in the next few years.

I'm really excited that a project to embed Turing-complete behavior in a blockchain has actually taken off. It's completely insane from one perspective, but completely awesome from another.


The EVM might be Turing complete but you can still have languages that compile down to only some tractable sub-set of the possible EVM programs.

The interesting question is whether a language can be design which allows the important domain-relevant requirements to written down in an understandable way and also proved rigorously.

So far neither lawyers nor programmers have done a very good job of this in their respective field. Watching people trying to do it in both fields simultaneously sounds like popcorn time to me.


Huh? Lawyers have done an exceptional job. There are huge swaths of activity around which there is consensus about legal dogma.

And huge swaths of activity where programmers have laid out clear deterministic expectations.

If you're saying lawyers have failed to specify the legal ramifications of All Possible Activity then... Sure. So? Even if Ethereum only works for one single narrowly defined contract, it could be immensely useful.

The question for me isn't "where could it fall short" but "where might it measure up?"


The EVM might be turing-complete but since you can only get finite number of execution cycles, you can usually determine the behaviour of your program or if it halts within the current gas limits.


...passwords that might be reused for the email addresses, and paypal, and...

A web app might not touch real money, but a leak can still have real money consequences for the users.


Sure, but in theory I can change passwords and maintain separate credentials for my banking-related needs.

Short of auditing the Solidity contract code myself, there's nothing I can do to protect myself from the hacks themselves because the very mechanism by which money is transferred is riddled with bugs.

This is mostly just semantics anyway - I'm just trying to establish that writing money-transfer software in a poorly designed language is, one way or another, worse than writing a web app in one.


There are also other consequences:

- vulnerabilities can be used to attack users directly or through social engineering

- (rare today, but definitely a problem with C++ web apps) you can break through a hole in the app and pwn the whole server


A law can only can be as bug free as software?

100% bug free software is impossible! As long as they are written by humans? Their will always be bugs. Matter who is writting them.


It doesn't need to be bug free if there are checks and balances. Like an independent contract layer that holds funds in escrow for 10 days and allow a third party to cancel fraudulent transaction under certain conditions.

You don't need to prevent all bad behaviors, just slow attackers down.

Of course sometimes they can get through the review process too, but you start having probabilities you can multiply to decrease the likelihood of losses.

Over time we'll start to have good defaults for how those checks work. For now it's the wild west.


i'd like formally verified laws if i could


I dislike algorithms that I understand, and I distrust algorithms that I don't when it comes to stuff like social security or insurance.

Smart contracts by composition would be really nice. Like a compile to EVM lisp!


Related: could we please have a Lisp for Ethereum VM? Thanks!


Lisp programmers know the value of everything and the gas cost of nothing...


Yeah if someone's working on it, please link. Would contribute



Nice thanks! Is this officialy supported still?



This might be possible at some point, but for that we first need to figure out how to formalize intent and meaning. In real-world laws, both are extremely important.


> ethereum dev.

how would you even get started for this kind of job? all of the ads popping up seem to be looking for somebody who already has significant experience


RTFM & Hack?




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

Search: