create account

Solidity isn't even that bad. by atherz

View this thread on: hive.blogpeakd.comecency.com
· @atherz ·
$0.03
Solidity isn't even that bad.
Reading through the Ethereum documentation for making smart contracts with Solidity, and honestly that argument that people say for Lisk about "not having to learn a new language" is **much weaker** than people think.

Solidity looks more like a mix between C and Javascript to me, which are both relatively easy languages to learn (hard to master, of course).

```javascript
contract MyAdvancedToken is owned, TokenERC20 {

    uint256 public sellPrice;
    uint256 public buyPrice;
    mapping (address → bool) public frozenAccount;

    event FrozenFunds(address target, bool frozen);

    function MyAdvancedToken(
        uint256 initialSupply,
        string tokenName,
        string tokenSymbol
    ) TokenERC20(initialSupply, tokenName, tokenSymbol) public {}

    function _transfer(address _from, address _to, uint _value) internal {
        require (_to != 0x0);
        require (balanceOf[_from] >= _value); 
        require (balanceOf[_to] + _value >= balanceOf[_to]); 
        require(!frozenAccount[_from]);
        require(!frozenAccount[_to]); 
        balanceOf[_from] -= _value; 
        balanceOf[_to] += _value; 
        Transfer(_from, _to, _value);
    }
[...]
```

Here is a snippet of the ERC20 code, which allows someone to create an ERC20 coin. This standard is actually the simplest way you can have any sort of programmed currency, with balances, transfer scripts, as well as extra functions for connecting to the markets, freezing accounts and minting new coins.

The standard data types for Solidity are 8-bit numbers, 256-bit numbers, strings and addresses. There are "requires" and "asserts" that enforce particular states (whatever's inside the functions), and public/private/internal modifiers so that other contracts can or can't use the contract's functions.

There are events that can be emitted to whatever app is listening, whether that be software or a web app.  And most importantly, there are functions which organize and store routines like any other language. You can even inherit other contracts and interfaces just like C++ and Java.

I'd say that the biggest risk in making smart contracts is the fact that the programmer is messing with tokens that have *real value* due to proof of work. Bugs in said programs can evaporate user funds, and there's not enough regulation yet to insure users of the dapplications.

Looking at this though, it seems valuable to get into this instead of waiting for Lisk like a lazy Javascripter. But also looking at this makes me realize that the only worth these coins have are the businesses behind them and the free market. Pretty scary how arbitrary the value of crypto tokens really are.
👍  , , , , , , ,
properties (23)
authoratherz
permlinksolidity-isn-t-even-that-bad
categorysolidity
json_metadata{"community":"busy","app":"busy/2.4.0","format":"markdown","tags":["solidity","ethereum","programmer","contracts","javascript"]}
created2018-04-26 22:24:45
last_update2018-04-26 22:24:45
depth0
children0
last_payout2018-05-03 22:24:45
cashout_time1969-12-31 23:59:59
total_payout_value0.034 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,674
author_reputation895,362,037,265
root_title"Solidity isn't even that bad."
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id52,338,783
net_rshares5,878,019,679
author_curate_reward""
vote details (8)