Man Convicted of Burying Busload of Children Alive in 1976 Considered For Parole

Frederick Woods is the only suspect still in prison after the 1976 case in which children from a school bus were kidnapped, transferred to a moving truck, and buried in the ground. Woods, along with…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Smart Contracts

There are a million articles out there explaining what smart contracts are. In short, they all say that a Smart Contract is “A program that runs on the Ethereum blockchain.” How does one make this program run? How does this program even exist on the blockchain? Why are there programs on the blockchain? These are some of the topics we will be covering in this article.

In the Ethereum blockchain, there are two main entities. Actual people who are interacting with the blockchain and Ethereum smart contracts. However, both these entities have addresses. What do I mean by this? Both smart contracts and people have an address. Both of them can store Ether in their accounts. They can spend Ether as and when they want and however they want to. So what exactly is the difference here?

Smart Contracts are hardcoded. Once deployed, one cannot alter a Smart Contract. The logic encoded in this smart contract cannot change once it has an address attributed to it. As a person, I can commit to someone that every week, on Monday at 7 AM, I will transfer 1 Ethereum to your address. However, there is no way anyone can enforce this commitment. One Monday, I might forget. The other Monday, I might send 0.5 Ether. A smart contract, however, once coded, cannot break this commitment. If one codes a Smart Contract to send 1 Ether to X address every Monday at 7 AM, it will honor the code as long as the Smart Contract has money in its address. No one can tamper with this. No one can alter this.

In the previous paragraph, I mentioned something called the state of a Smart Contract. What exactly does this mean? Each smart contract can hold data. This data is stored in variables which can be numbers, strings, addresses, and so on. Even more complicated variable types are mappings which map addresses to string or integer or even to addresses. These are just a few examples. After mining a block, that block holds the current state of all the smart contracts in the Ethereum blockchain. The current state is the current value of all the variables, the amount of Ether stored in the Smart Contract addresses, and other normal addresses.

Apart from variables, Smart Contracts contain functions as well. They execute when certain conditions are satisfied. One can run a function on the Smart Contract by sending a transaction with the required parameters in the data field of the transaction. For example, if I want to enter a competition that has an entry fee of 0.01 Ether. I would interact with the host’s Smart Contract(mostly done via a DApp) and send 0.01 Ether to their address. Then the host’s Smart Contract will give my address a pass. Later, when I want to enter the competition, I would need to verify my address and, once approved, can join in successfully.

Thus, with Solidity’s variables, functions, and many more APIs, one can build various features on the Ethereum blockchain. You might have heard of the term NFT(Non Fungible Token). These are nothing but Smart Contracts with certain logic in them. Each NFT is a Smart Contract which has a variable that stores the owner’s address of the NFT. It also has specific functions that help transfer the ownership of the NFT to someone else. They have particular modifiers that help prevent attackers from gaining unwarranted control of the NFT. The technical term for an NFT Smart Contract is called ERC721. We’ll dive into what this means in a future article! For now, all you need to know is that ERC721 defines a set of functions that need to be implemented to make a Smart Contract into an NFT.

To summarise, we have seen:
Smart Contracts are nothing but Solidity programs compiled and stored on the blockchain network with a specific address attached.
* How an agreement once encoded and deployed cannot be altered with.
* We can interact with a Smart Contract by sending a transaction with some data along with it.
* Some use cases of Smart Contracts and how they are in use today.

This article was originally published in the blog, blockchainiseasy.github.io.

Add a comment

Related posts:

How to Make Sysadmins More Human

If you ask an average person, what does a common sysadmin’s day look like, you will probably hear something about dealing with huge amount cables in server rooms filled with blue light or bashing out…

LIFE AFTER CHILDHOOD SEXUAL ABUSE

Talking about life after sexual abuse at childhood by a family member encapsulates pretty much. There is the "how do we recover from sexual abuse, trauma therapy, sexually transmitted diseases…

How to fix Vulnerabilities in Node.js

Node.js is a powerful and widely-used JavaScript runtime that has gained immense popularity in the web development community. However, like any software, Node.js is not immune to vulnerabilities that…