How Smart Contracts work on Blockchain

Usman Fazil
Coinmonks
Published in
2 min readMay 19, 2018

--

It’s been quite a time since I’m working on blockchain ,and till tomorrow I was never too sure about how a smart contract works/run on blockchain. So I thought I should write a small article on it, and help others who are having a hard time understanding the same thing.

Fig 1.1

Lets take Ethereum smart contracts as an example, so when we write a smart contract it is converted into it’s byte code and that byte code can be sent to Blockchain with a transaction. That transaction will be just like other transactions on Blockchain. The data field of the transaction will have the byte code generated from the smart contract, now a transaction contain a “to-address” and a “from-address”. So here “from-address” will be equal to the address of the person deploying this smart contract and “to-address” will be left empty. But when the transaction is mined and pushed to blockchain a new address is generated and “to-address” will be set equal to this new generated address, and when the transaction is accepted in the network anyone can interact with that smart contract using the address that was generated.

--

--

Usman Fazil
Coinmonks

Blockchain and crypto enthusiast, exploring the vast field of peer to peer communication. Check git here https://github.com/usmanfazil