Bitcoin Cash Smart contracts

Srihari Kapu
HackerNoon.com
3 min readOct 28, 2018

--

Today I want to speak something interesting. It's about Smart contracts on top of the Bitcoin cash Blockchain. For those of you who don't know what is Bitcoin cash. Bitcoin cash is a hard fork of the Bitcoin Blockchain in which people spoke about scalability and transaction fee, the volume of transactions. i.e in simple words Bitcoin, the community decided to create a new blockchain which can accommodate a larger size of blocks and less transaction fee on the transactions. Apart from all that instant transaction is there to blow up your mind, I mean practically no that instant but its really better than bitcoin transaction speed. If you don't know what is a fork, let me help you to understand it, A hard fork is a permanent divergence from the previous version of the Blockchain, and nodes running previous versions will no longer be accepted by the newest version.

hard fork

What's so special about Bitcoin cash?

There isn’t a much of a difference between Bitcoin and Bitcoin cash. Both of them are built to serve the same purpose “Peer to Peer Digital cash”. Below are some of the interesting facts about the Bitcoin and Bitcoin Cash.

Bitcoin vs Bitcoin Cash

Can we create smart contracts on Bitcoin Cash?

Yes! we can write smart contracts on Bitcoin Cash. Well, let me tell you what are the difficulties we gonna face in writing the Bitcoin Cash smart contracts.

  • Community & Developers working on writing Bitcoin cash is in the early phase. So, Be prepared you to need to do your homework ready by yourself not a lot of people are there as of now to help you on your coding the Bitcoin Cash contracts.
  • We are going to use a high-level language named “Spedn” for coding our smart contracts.
  • Haskell is used for testing Bitcoin cash smart contracts.

Let us code our first Bitcoin cash smart contract:

  1. Install Haskell Toolkit on your device.

2. Create a new project:

3. To launch run :

4. For a list of Haskell commands:

5. Clone the “Spedn”

6. Build “Spedn”

7. Create a directory for a smart contract:

8. Let's consider a case for writing our smart contract:

Let’s assume Alice want to tip a waiter Bob with a paper wallet but she wants to be sure that the coin will not get lost due to Bob losing the paper.

This contract locks a coin in such a way that Bob can redeem it at any time but if he didn’t do so in 7 days then Alice can get it back.

9. Compile your smart contract:

10. Compiled contract template:

Open source

--

--

Srihari Kapu
HackerNoon.com

Bringing the best content for you to read is my job.