Live data from Hacker News

Understanding Ethereum Smart Contracts

gjermundbjaanes.com

121–130 of 162 posts

Re: Understanding Ethereum Smart Contracts

#121
post #89
post #39

Earlier quoted context omitted.

> There are no floating point numbers. Since you're probably working with "money", this can make things tricky. That is actually a feature when it comes to working with money. You don't ever want to use floating-point arithmetic with monetary values due to its inability to represent all possible decimal fractions of your base unit. This is just as true for over-hyped blockchain stuff as it is for any imaginable appli…

>That is actually a feature when it comes to working with money. You don't ever want to use floating-point arithmetic with monetary values due to its inability to represent all possible decimal fractions of your base unit. This is just as true for over-hyped blockchain stuff as it is for any imaginable application in the "classic" financial sector. I feel like this is constantly repeated but is simply untrue and work…

> [...] only to eventually encounter all the issues that floating point was invented to solve. When they encounter those issues they then end up having to adapt their code only to basically re-invent a broken, unstable quasi-floating point system when they would have been much better off using the IEEE floating point system [...]

Would you care to elaborate on some of these issues? I'm genuinely curious.

Re: Understanding Ethereum Smart Contracts

#122
post #62

I've also just begun to play with smart contract programming. One problem I'm having is with event listening. It seems that MetaMask doesn't yet support subscriptions, nor does my localhost testRPC instance pass it in the web3 object. Some have suggested I need to run my own node just to listen for contract events. Has anyone figured out an easier solution?

Quick question, do you have to download the full ethereum chain before you can start messing with smart contracts? Or is there a "light" client you can use?

You shouldn't use the main ethereum network when testing smart contracts - develop on a local testnet and then if you want, on a public testnet (eg rinkeby or ropesten) first

Re: Understanding Ethereum Smart Contracts

#123
post #7

Earlier quoted context omitted.

Scaling is definitely a serious concern and is a large focus of Ethereum developers at the moment. I don't understand much about the proposed solutions, but they generally think the Ethereum network can be sharded in a way that allows only a small subset of the network to run any given contract and still guarantee reliability similar to as if the whole network had run it.

You'll need some very hard guarantees that that 'small subset' can never be under the control of a single entity.

It doesn't work like that - a working sharding scheme should not fail if one shard is taken over. This is the most recent description of ethereum sharding if you want to learn more -> https://youtu.be/9RtSod8EXn4?t=3h12m30s . In particular look at step 4 where the fork choice rule is changed so that shards with invalid blocks cannot exist on a valid base chain.

Re: Understanding Ethereum Smart Contracts

#124
post #89
post #39

Earlier quoted context omitted.

> There are no floating point numbers. Since you're probably working with "money", this can make things tricky. That is actually a feature when it comes to working with money. You don't ever want to use floating-point arithmetic with monetary values due to its inability to represent all possible decimal fractions of your base unit. This is just as true for over-hyped blockchain stuff as it is for any imaginable appli…

>That is actually a feature when it comes to working with money. You don't ever want to use floating-point arithmetic with monetary values due to its inability to represent all possible decimal fractions of your base unit. This is just as true for over-hyped blockchain stuff as it is for any imaginable application in the "classic" financial sector. I feel like this is constantly repeated but is simply untrue and work…

Additionally, the most widely used programming language in finance, Microsoft Excel, is based entirely on IEEE binary floating point arithmetic (though with a few hacks on top [1]).

[1]: https://stackoverflow.com/a/43046570/392585

Re: Understanding Ethereum Smart Contracts

#125
post #101

Earlier quoted context omitted.

Not every single aspect of HFT is insanely speed critical and even in non-critical areas we still don't use fixed decimal point arithmetic on principle. For example we do a lot of profit/loss reporting and analytics which are not speed critical, we write user interfaces and web apps in Javascript that work with money, so on so forth. I will agree BigDecimal is fine to use if speed really doesn't matter, it's at least…

Honest question - why is that something to avoid? What does the floating point representation buy you that say an int64 doesn't, with the same choice of units ie. 1 = 10^-6 dollars?

Tracking the decimal point is all that comes to my mind.

Re: Understanding Ethereum Smart Contracts

#126
post #97
post #10

What I'd greatly appreciate is a walk through of a plausible real world use case. I find it hard to concentrate on the technology itself until I understand the application.

Having recently gone through the prolonged pain of probating a will, I think smart contracts could be used to enforce wills without the need for probate. But of course, that opens up its own can of worms, like the need for potential heirs to maintain a digital identity for possibly decades. What happens if someone cuts all digital ties and effectively becomes a hermit? At least with ordinary probate, you can simply v…

Paper wallets, maybe?

Re: Understanding Ethereum Smart Contracts

#127
post #10

What I'd greatly appreciate is a walk through of a plausible real world use case. I find it hard to concentrate on the technology itself until I understand the application.

My mom works for Mercedes and she's been telling me (She's really tech-y) they really wanna use Blockchain/Smart contracts to help validate someone before they purchase a car. Essentially before you buy a car, you need to verify you have the credit, cash, etc.. whatnot. She says that Diamler/Mercedes think they could make this a lot smoother with smart contracts and what not.

Re: Understanding Ethereum Smart Contracts

#128

Earlier quoted context omitted.

This seems like a perfect use-case for payment channels, e.x. Lightning Network: Car continuously delivers micropayments to charger while charger continuously delivers power to car, if one stops the other also stops. If the power is cut off prematurely the car only loses maybe a couple cents worth of power. (Payment channels are built using smart contracts, but they’re simple enough that Bitcoin’s more limited smart…

That happens today: when I pump gas into my car, the price on the display goes up. When it hits the limit, the gas flow stops. No blockchain is required.

The difference is there is no counterparty risk. Not with the gas station, not with Visa.

Admittedly that’s not a big problem with gas pumps (at least where I live, though card skimming is definitely a thing) but you can easily imagine other use-cases. For example your computer could automatically pay an untrusted WiFi hotspot per MB (and automatically pay the VPN you use to secure said untrusted WiFi hotspot)

Zero counterparty risk digital microtransactions have never been possible until now. I’m pretty sure it will eventually be cryptocurrency’s killer application.

Re: Understanding Ethereum Smart Contracts

#129
post #10

What I'd greatly appreciate is a walk through of a plausible real world use case. I find it hard to concentrate on the technology itself until I understand the application.

My mom works for Mercedes and she's been telling me (She's really tech-y) they really wanna use Blockchain/Smart contracts to help validate someone before they purchase a car. Essentially before you buy a car, you need to verify you have the credit, cash, etc.. whatnot. She says that Diamler/Mercedes think they could make this a lot smoother with smart contracts and what not.

Would it be used for an internal system, or for contacting credit score companies, banks, etc?

Re: Understanding Ethereum Smart Contracts

#130
post #101

Earlier quoted context omitted.

Not every single aspect of HFT is insanely speed critical and even in non-critical areas we still don't use fixed decimal point arithmetic on principle. For example we do a lot of profit/loss reporting and analytics which are not speed critical, we write user interfaces and web apps in Javascript that work with money, so on so forth. I will agree BigDecimal is fine to use if speed really doesn't matter, it's at least…

Honest question - why is that something to avoid? What does the floating point representation buy you that say an int64 doesn't, with the same choice of units ie. 1 = 10^-6 dollars?

What if you need to calculate the percentage difference between two monetary values?

Ints wont cut it there.

Post reply on HN