Code on the chain! An introduction in writing smart contracts and tooling for Blockchain Development - Tom Davies/Vallard Benincosa - Codemotion Amsterdam 2018
We've all heard of bitcoin and also blockchain, the technology that underpins it. But how do you develop on blockchain? How do you create your own smart contracts? In this session, you'll get to understand the basics of blockchain development. We’ll provide a brief blockchain overview, describing the concepts and mechanisms of the technology, before we take you through creating your very own crypto token, introducing some basic developer tool chains and walking through your first smart contracts using Ethereum, the popular public blockchain.
Pompili - From hero to_zero: The FatalNoise neverending storyCodemotion
More Related Content
Similar to Code on the chain! An introduction in writing smart contracts and tooling for Blockchain Development - Tom Davies/Vallard Benincosa - Codemotion Amsterdam 2018
Similar to Code on the chain! An introduction in writing smart contracts and tooling for Blockchain Development - Tom Davies/Vallard Benincosa - Codemotion Amsterdam 2018 (20)
Code on the chain! An introduction in writing smart contracts and tooling for Blockchain Development - Tom Davies/Vallard Benincosa - Codemotion Amsterdam 2018
1. Tom Davies, Sr. Manager, Cisco DevNet,
Vallard Benincosa, Software Engineer, Cisco
Code on the Chain!
An introduction to writing smart contracts & tooling for
blockchain development
Tom
Infra Developer, Enterprise App Dev, App Dev, Solution Architecture
Tom
Tom
Val
Tom
Tom
Tom
Tom
Val
In this peer 2 peer network an actor on the network can be what is called a miner. A miner is a participant who tries to create the next block in the blockchain.
The miners are incentivized in two ways:
As part of creating a block they create new tokens that they own
They get commissions or a percentage of the transactions
Mining on some networks can be done with commodity hardware. Monero for example I’ve managed to run on a few UCS servers. But the more famous blockchains require special hardware due to competition. One example is Bitcoin which requires special ASICs. Even GPUs aren’t good enough for Bitcoin anymore and ASICs such as the Antminer S9 have been popular. You can buy some of these on eBay or other aftermarket sites. I have an S9 that I bought with Bitcoin cash that runs and at one point was making 20 euro a day.
Val
Essentially each miner is trying to come up with the next block, but its not as easy as just putting together a bunch of transactions. They need to also do what is called ”Proof of Work”. Some blockchains have other consensus protocols such as ”Proof of Stake” but the original Bitcoin and many others are derived from “Proof of work”. Essentially, we’re trying to take all the transactions, hash them together and then come up with a hash that starts with a certain amount of zeros.
This idea of a hash is a “One way function”. From algebra, you are familiar with simple functions like y = x^2. If I give you x = 2, you know y = 4. If you’re advanced enough in your algebra, if I give you a number like 144 and say that is y, you can tell me that x was 12 or -12. This is a two way function, we can simply find x if we know the value of y and the function. A one-way function is more complex in that if I give you y it is nearly impossible for you to tell me what x was. The only way you can do it is by brute force. In bitcoin we use the eliptical curve function which would take a computer thousands of years to figure out x given y.
The beauty, however of a one-way function is that if I give you y and then give you x, then you can verify that x does indeed give you y in a super fast O(1) computation.
In blockchain, we take a hash of the transactions, the timestamp, and the previous block and something called a nonce and run it through this one-way function each time trying to come up with some number that begins with a certain amount of zeros. The only thing we can change is the nonce, and we just brute force it until something comes up.
Because this is an all or nothing game, many miners “pool” there servers together so that if one lucky miner finds the magic nonce, the miners all share the reward based on their percentage of hashing power contributed towards the search.
Val
Once the right nonce is found, the block is broadcast to the network. The other servers can validate the correctness of the block. If it checks out that block becomes the next block on the chain. Several miners may come up with a different block they think should be the next block and that is actually valid. The network holds on to both of those blocks. Then as subsequent miners mine blocks they base it on one of the previous blocks. The block with the longest history becomes the “real block” and eventual consensus is made.
Val
This eventual consensus is one of the beauties of the chain. In the original paper by Satoshi Nakamoto, the word “block chain” is not even mentioned. The word comes from the fact that each header of a new block must refer back to a previous block. This enjoys the property that altering even one transaction way back in the chain would change the entire chain and so the chain is tamper and censor resistent. In bitcoin this works and encourages would be hackers to instead contribute resources towards keeping the block fare. In bitcoin only 21 million coins will be created. After that point in 2140 miners will be incentivized only by collecting fees for including transactions in their blocks.