what is ethereum

Lessons from the Blockchain: What is Ethereum?

Exploring the Code

Let’s have a look at the concept of code. We’re going to consider the function of a really simple escrow service, like PayPal. What escrow is mutual payment protection, basically when two parties want to transact, they want somebody in the middle to make sure that neither of them gets ripped off.

The seller asks for payment in escrow, effectively, give the money to a trusted third party, when they get the money I give you the thing, then they release the money to me once you confirm that I’ve given you the thing. This is a really simple explanation of an escrow, purely to give context to what we are exploring here in answering the question ‘What is Ethereum?’.

Ethereum’s programing language is called Solidity, and compared to the other languages out there this has more features and is much nicer to work with, and as you can see below it is much nicer to look at also. Despite the Developer Tools for Ethereum being around for about two years, they are still quite limited at this stage.

what is ethereum - advanticle.com

This is an example of a simple contract, where there are normal variables. In the case of an escrow smart contract, there would be two variables at the top. There would also be the address of the Seller (their Ethereum wallet public key or address). There would also be a mapping, like an object of addresses to number on signages. These would tell us the address of any buyers, and how much money they have sent. This is followed by events which tell the outside world what has happened.

Next, there is a constructor, this is something that only ever runs once, and runs from the context of whoever deployed the contract. So, for example, it could be in this instance the seller, and we are saying that the seller is whoever deployed this contact.

There can be other functions which can be public, such as ‘buy’ which is payable, this means you can send money through this function. It logs that somebody has bought a ‘thing’ and then it puts the message.sender to the Buyer and says ‘add the value that they sent to the Seller’s balance’ in the contract.

Then there is a final function called ‘release’ which makes sure that the release of funds is successful, and it says ‘regarding this Seller, send them the money that the Buyer sent us.’ The Buyer calls the release function, and it should be sending the money to the Seller that the Buyer has sent to this function.

When a contract is in development and testing you’ll be working with the deployment of bytecode, which are simple machine instructions. This is what every VM looks at and interprets and runs. There is also an ABI, Application Binary Interface, for anyone who wants to interact with this contract from external libraries. This just tells that other library what functions the contract contains.

This would normally be run on a public testnet, on localhost, something like Coven, which is maintained by a proof of authority consensus algorithm, it is really quick with a block time of about 4 seconds, so you can send transactions really quickly and run demos to figure out if there are any issues. You could run this on a public main net, but you will be exposed to all of the other aspects of working out in the open online.

When testing the amounts will appear different as the VM only deals in integers (whole numbers), so 0.5 Ether, in this case, will appear as a value of 5. One Ether can be split down into one times ten to the eighteen units. Lots of tiny little units.

Once a contract is deployed, there is no way to change what is in it, regardless of which party you are in the transaction. The Buyer and the Seller have no capacity to change the code. The contract has full custody of the money, from a programming perspective, I have to tell the contract what to do with the money. I don’t send the money from the contract to the other party, I program the contract and tell the contract I want it to send the money. The contract acts as the escrow agent in this transaction. It has custody of the funds.

The concept that I want to get across is that once a contract is put on the blockchain it is unable to be modified. There is no way that anyone can change that it does anything. The Seller deploys the contract, the Buyer chooses to enter into it. After the Buyer enters into the contract they no longer control the funds. The fund can nowhere other than what was specified in the contract. The code is there and the code is there for good.

Questions from the audience

So does the code have a similar relationship inside Ethereum as a DApp or does it sit on top of Ethereum?

It’s sitting inside the Ethereum Virtual Machine. It now occupies a part of that machines state, and it will forever if it does not have a ‘kill function’ included. This can present a problem if there is poorly written code as it can, among other things, clog up the public test net.

So why would you build on top of the Ethereum network?

Because you can do powerful things like those which we have discussed. You can build contracts that sit inside the Ethereum machine that cannot be modified once they are deployed, and anyone can access them.

Solidity object orientated code?

Yes.

So if that smart contract is there forever on the Ethereum blockchain, is that consuming computer resources, with Ethereum being a ‘computer’, and who is paying for the resources that that smart contract is consuming?

Is it consuming resources, kind of. Who is paying for the cost, whoever chooses to use the contract. If I choose to make the smart contract do some things, make it execute some code, change some storage, change some state, then I pay for that. I pay in Gas, which is the fuel or fee required to process a transaction on the Ethereum network. That fee goes to the Miners, they are the ones verifying the transactions. I pay a tiny bit of Ether which gets sent to the Miners, they are the ones verifying those transactions and they get all of those fees. That goes to them, as well as the block reward for finding a new block.

Is that a one-off payment, or is that a recurring payment?

Is it a one-off payment and that contract uses no more computing resources than when it is running. While it is running it is the only time that it is using the resources on the Ethereum network.

What is the security of the Ethereum network into the code?

Each of the transactions, all of the operations within those transactions are verified in exactly the same way that Bitcoin transaction is verified; by everybody else in the network. The output of that transaction is verified by everybody, in the same way, that a transaction of value is verified, for example, a transaction of Ether from me to somebody else. It’s all verified in the same way.

So if you wanted to have recurring payments, how would you set that up?

You would write a script that sent transactions every now and then.

How would it know when to be sent, say on a subscription basis for periodic payments?

You could set the service up on a ‘user pays’ basis, so when the user has consumed what they have paid for and have not made another payment, you stop providing them with the said service until they pay again. So when they pay, you set a variable to ‘true’ so they can use the service for that period, and you set a ‘last paid date’. Every time they use the service you check the ‘last paid date’ and if it has ticked over for a month and they are out of date you don’t let them use the service.

So they have to manually pay every month?

Yes. Because people have custody of their own funds. You could lock it into a contract which the service provider would control and they would give themselves the money periodically, but, that kind of against the spirit of things. I wanted to stop using that service, I should just be able to stop paying for it.

But what about in scenarios where there are distributed payouts, you wouldn’t want to have to make payments manually everytime?

No, which is why you would develop an application which would just pay them all.

So how do you feel about the news that China and South Korea are thinking about banning cryptocurrencies, and how do you feel about banks wanting to create their own cryptocurrencies?

It’s not impossible to ban them, I’m sure that you could find a way to filter cryptocurrency transactions, or access to cryptocurrency networks and filter those out of your national internet traffic. I believe it’s not going to happen though. These governments are going to realize that these things aren’t going away. How long has Bitcoin been around? How long has Ethereum been around? These things aren’t slowing down, they are picking up the pace.

There are now more Developers working on Ethereum, not to mention other projects, than there ever have been, and next week there will be even more. As more people understand ‘What is Ethereum?’ thed demand is increasing with the use case for Ethereum. This train is not stopping. If these governments want to remain relevant they will have to accept them, and they will have to find a way to utilize them and benefit from them instead of banning them. Banning them is completely foolish.

How do I feel about banks wanting to create their own cryptocurrencies and the effect that will have? There may be benefits about the access and speed, but until somebody figures out the scaling issue, the blockchain will not be able to do what the Visa network can currently do. You could have a private blockchain, but then that’s no different than using your Visa card, and I don’t know why you would do that. A private blockchain for a bank seems really really silly. A public blockchain for a bank is technically unfeasible right now. It will be interesting to see where it goes in the next 18 months, but I don’t see a bank really having any impact on this space.

Can a smart contract make a request for money rather than just accepting it?

Currently no. Currently, contracts can’t ask people for money, or to pay them. They can only accept money when it is given to them.

So one of the main benefits of the blockchain is to remove the middleman, like Lawyers and Accountants, but when you create a contract you have to pay for Gas, so you are still paying a middleman effectively, right?

You pay for Gas when you interact with the smart contract, and the cost involved is only when you do something. And comparatively, it’s also incredibly cheap right now. I would probably pay a couple of dollars to activate a smart contract compared to hundreds of times more than with a Lawyer or an Accountant, per se.

(Visited 15 times, 1 visits today)

MJ Author