Tag Archives: Simply

Smart contracts – Simply Explained

Smart contracts (also called distributed apps) are very popular nowadays But what are they and what problems do they solve? The term “smart contract” was first used by Nick Szabo in 1997, long before Bitcoin was created

He is a computer scientist, law scholar and cryptographer so I’ll spare you his exact words But in simple terms: he wanted to use a distributed ledger to store contracts Now, smart contracts are just like contracts in the real world The only difference is that they are completely digital In fact a smart contract is actually a tiny computer program that is stored inside a blockchain

Let’s take a look at an example to understand how smart contracts work You probably are familiar with Kickstarter, the large fundraising platform Product teams can go to Kickstarter, create a project, set a funding goal and start collecting money from others who believe in the idea Kickstarter is essentially a third party that sits between product teams and supporters This means that both of them need to trust Kickstarter to handle their money correctly

If the project gets successfully funded, the project team expects Kickstarter to give them the money On the other hand, supporters want their money to go to the project if it was funded or to get a refund when it hasn’t reached its goals Both the product team and its supports have to trust Kickstarter But with smart contracts we can build a similar system that doesn’t require a third-party like Kickstarter So let’s create a smart contract for this! We can program the smart contract so that it holds all the received funds until a certain goal is reached

The supporters of a project can now transfer their money to the smart contract If the project gets fully funded, the contract automatically passes the money to the creator of the project And if the project fails to meet the goal, the money automatically goes back to the supporters Pretty awesome right? And because smart contracts are stored on a blockchain, everything is completely distributed With this technique, no one is in control of the money

But wait a minute! Why should we trust a smart contract? Well because smart contracts are stored on a blockchain, they inherit some interesting properties They are immutable and they are distributed Being immutable means that once a smart contract is created, it can never be changed again So no one can go behind your back and tamper with the code of your contract And being distributed means that the output of your contract is validated by everyone on the network

So a single person cannot force the contract to release the funds because other people on the network will spot this attempt and mark it as invalid Tampering with smart contracts becomes almost impossible Smart contracts can be applied to many different things, not just on crowdfunding Banks could use it to issue loans or to offer automatic payments Insurance companies could use it to process certain claims

Postal companies could use it for payment on delivery, and so on and so on… So, now you might wonder where and how you can use smart contracts Right now there are a handful of blockchains who support smart contracts, but the biggest one is Ethereum It was was specifically created and designed to support smart contracts They can be programmed in a special programming language called Solidity This language was specifically created for Ethereum and uses a syntax that resembles Javascript

Its worth noting that Bitcoin also has support for smart contracts although it’s a lot more limited compared to Ethereum So now you know what smart contracts are and what problem they solve I hope you enjoyed this video and if you did, hit the like button and get subscribed And as always: thank you very much for watching! #youtube/simply-explained

How does a blockchain work – Simply Explained

Blockchains are incredibly popular nowadays But what is a blockchain? How do they work, what problems do they solve and how can they be used? Like the name indicates, a blockchain is a chain of blocks that contains information

This technique was originally described in 1991 by a group of researchers and was originally intended to timestamp digital documents so that it’s not possible to backdate them or to tamper with them Almost like a notary However it went by mostly unused until it was adapted by Satoshi Nakamoto in 2009 to create the digital cryptocurrency Bitcoin A blockchain is a distributed ledger that is completely open to anyone They have an interesting property: once some data has been recorded inside a blockchain, it becomes very difficult to change it

So how does that work? Well, let’s take a closer look at a block Each block contains some data, the hash of the block and the hash of the previous block The data that is stored inside a block depends on the type of blockchain The Bitcoin blockchain for example stores the details about a transaction in here, such as the sender, receiver and amount of coins A block also has a hash

You can compare a hash to a fingerprint It identifies a block and all of its contents and it's always unique, just as a fingerprint Once a block is created, it’s hash is being calculated Changing something inside the block will cause the hash to change So in other words: hashes are very useful when you want to detect changes to blocks

If the fingerprint of a block changes, it no longer is the same block The third element inside each block is the hash of the previous block This effectively creates a chain of blocks and it’s this technique that makes a blockchain so secure Let's take an example Here we have a chain of 3 blocks

As you can see, each block has a hash and the hash of the previous block So block number 3 points to block number 2 and number 2 points to number 1 Now the first block is a bit special, it cannot point to previous blocks because it's the first one We call this the genesis block Now let's say that you tamper with the second block

This causes the hash of the block to change as well In turn that will make block 3 and all following blocks invalid because they no longer store a valid hash of the previous block So changing a single block will make all following blocks invalid But using hashes is not enough to prevent tampering Computers these days are very fast and can calculate hundreds of thousands of hashes per second

You could effectively tamper with a block and recalculate all the hashes of other blocks to make your blockchain valid again So to mitigate this, blockchains have something called proof-of-work It's a mechanism that slows down the creation of new blocks In Bitcoins case: it takes about 10 minutes to calculate the required proof-of-work and add a new block to the chain This mechanism makes it very hard to tamper with the blocks, because if you tamper with 1 block, you'll need to recalculate the proof-of-work for all the following blocks

So the security of a blockchain comes from its creative use of hashing and the proof-of-work mechanism But there is one more way that blockchains secure themselves and that's by being distributed Instead of using a central entity to manage the chain, blockchains use a peer-to-peer network and anyone is allowed to join When someone joins this network, he gets the full copy of the blockchain The node can use this to verify that everything is still in order

Now let's see what happens when someone creates a new block That new block is send to everyone on the network Each node then verifies the block to make sure that it hasn't been tampered with If everything checks out, each node adds this block to their own blockchain All the nodes in this network create consensus

They agree about what blocks are valid and which aren't Blocks that are tampered with will be rejected by other nodes in the network So to successfully tamper with a blockchain you'll need to tamper with all blocks on the chain, redo the proof-of-work for each block and take control of more than 50% of the peer-to-peer network Only then will your tampered block become accepted by everyone else This is almost impossible to do! Blockchains are also constantly evolving

One of the more recent developments is the creation of smart contracts These contracts are simple programs that are stored on the blockchain and can be used to automatically exchange coins based on certain conditions More on smart contracts in a later video The creation of blockchain technology peaked a lot of people’s interest Soon, others realized that the technology could be used for other things like storing medical records, creating a digital notary or even collecting taxes

So now you know what a blockchain is, how it works on basic level and what problems it solves Want to learn how you can implement a simple blockchain with Javascript? Then checkout this video here And as always: thank you very much for watching