08
Jun
20

CARDANO (ADA) Full Guide - A scalable Smart Contract Platform

Cardano is a smart contract platform that offers scalability and security through a layered architecture. Created by one of the founding fathers of the original Ethereum protocol Charles Hoskinson – Cardano’s USP happens to be its underlying scientific philosophy.

 

 

Two companies that are responsible for Cardano’s upkeep are:

 

  • IOHK: IOHK or Input Output Hong Kong was founded by Charles Hoskinson and Jeremy Wood to research on different peer-to-peer blockchain innovations and build accessible financial services.
  • Emurgo: Emurgo is the financial arm of Cardano that develops, supports, and incubates blockchain-based startups. Much of IOHK’s funding comes from a 5-year contract with Emurgo.
  •  

    These two organizations work in synergy to ensure the proper development of Cardano.

     

    Cardano and Scientific Philosophy

     

    As mentioned before, Cardano strictly adheres to a set of principles and philosophies. These principles, as taken from the Cardano website, are:

     

  • Separation of accounting and computation into different layers.
  • Implementation of core components in highly modular functional code
  • Small groups of academics and developers competing with peer-reviewed research
  • Heavy use of interdisciplinary teams including the early use of InfoSec experts
  • Fast iteration between white papers, implementation, and new research required to correct issues discovered during review.
  • Building in the ability to upgrade post-deployed systems without destroying the network
  • Development of a decentralized funding mechanism for future work
  • A long-term view on improving the design of cryptocurrencies so they can work on mobile devices with a reasonable and secure user experience
  • Bringing stakeholders closer to the operations and maintenance of their cryptocurrency
  • Acknowledging the need to account for multiple assets in the same ledger
  • Abstracting transactions to include optional metadata in order to better conform to the needs of legacy systems
  • Learning from the nearly 1,000 altcoins by embracing features that make sense
  • Adopt a standards-driven process inspired by the Internet Engineering Task Force using a dedicated foundation to lock down the final protocol design
  • Explore the social elements of commerce
  • Find a healthy middle-ground for regulators to interact with commerce without compromising some core principles inherited from Bitcoin.
  •  

    Cardano Consensus Algorithm

     
    Ouroboros Logo
     

    At the heart of Cardano lies the Ouroboros consensus algorithm. Ouroboros is a peer-researched staking algorithm that will help Cardano process thousands of transactions per second. Several modern cryptocurrencies have opted for the staking model to move on from the traditional proof-of-work (POW) model. The consensus in traditional POW models like in Bitcoin and Ethereum works something like this:

     

  • Specialized nodes in the network called “miners” own mining equipment called “ASICs” and solve cryptographically hard puzzles within the ecosystem.
  • When they successfully discover a block they get a block reward.
  • This process is hugely wasteful resource-wise. This is done on purpose to economically disincentivize attacks from hijacking the blockchain.
  •  

    When you look at the last point, it can be both a positive and a negative. While there is no doubting the security offered by POW, its wastefulness makes it very unscalable. This is why several projects are opting for virtual consensus mechanisms like proof-of-stake (POS). In the POS system, some validators lock up a stake within the network. When they sign off on blocks, they receive a block reward corresponding to their stake.

     

    What is Cardano Ouroborous?

     

    Cardano’s Ouroboros is a variation of the POS algorithm. Let’s look at how it works:

     

  • Ouroborous divides Cardano’s timeline into different epochs. Each epoch lasts for a short time, around 20 seconds, and is further subdivided into slots.
  • Each slot gets its own randomly chosen slot leader.
  • The Slot leader act like miners does in a POW protocol in the sense that they are the ones who select the blocks that get added to the blockchain. Each slot leader can only add one block.
  • If the slot leader misses their chance to validate a block, they will have to wait for their opportunity to prove blocks again.
  •  

    Stakeholder election

     

  • To be considered a stakeholder, you must own a 2% stake in Cardano. Owning a 2% stake allows you to become an elector and elect slot leaders for the next epoch during the current epoch.
  • The more stake the stakeholder has in the system, the more chance they get to be elected as slot leaders.
  • Slot leaders are chosen using a multiparty computation (MPC), which uses a randomness factor in the form of an action called “coin tossing.”
  • Though the elector’s results are randomly generated, they will eventually agree on the same final value.
  •  

    The three phases of the election

     

    The three phases of stakeholder elections are as follows:

     

  • Commitment Phase.
  • Reveal Phase
  • Recovery Phase.
  •  

    Commitment Phase

     

  • An elector first generates a random value and creates a commitment. The commitment is a message that contains encrypted shares and proof of secret.
  • The elector signs the commitment with their private key and specifies the epoch number and attaches their public key. Doing this solves two purposes – Everybody can check who created this commitment and check which epoch it belongs to.
  • Following this, the elector sends their commitments to other electors. Eventually, the commitments are collected from all the other electors.
  •  

    Reveal Phase

     

    In this phase, the electors send a special and secret value called “opening.” These opening are put into the block and become part of the Cardano blockchain.

     

    Recovery Phase

     

  • This is the last phase of the election process. In this phase, the elector has both commitments and openings.
  • Some electors may maliciously publish their commitment without the opening. To circumnavigate this, honest electors can post all the encrypted shares and simply reconstruct the secrets. What this does is that it ensures that the system works even if some of the electors may be dishonest. This makes sure that the system is Byzantine Fault Tolerant.
  • Finally, an elector can verify that all the commitments and openings match. The moment they confirm that the secrets from the commitments are extracted, it forms a seed.
  • Eventually, all the electors will now possess a seed. This seed helps us leverage randomness in our slot leader selection.
  •  

    Selecting the slot leader

     

    Slot leader selection happens via the Follow the Satoshi (FTS) algorithm, named after the anonymous creator of Bitcoin – Satoshi Nakamoto.

     

  • The algorithm randomly selects a coin from the state.
  • Whoever owns that coin becomes the slot leader.
  • The slot leaders will also have the power not only to choose the blocks in the main blockchain but also to choose blocks in other blockchains inside the Cardano ecosystem.
  •  

    Functional programming and Cardano

     

    Cardano has chosen Haskell and Plutus as their languages of choice. Haskell will be used to code Cardano, while Plutus will be used for the smart contract creation. Both of them are functional languages.

     

    When it comes to programming languages, there are two families:

     

  • Imperative
  • Functional.
  •  

    Imperative Programming Languages

     

    All of our traditional programming languages like C++, Java, and even Solidity are imperative programming languages. The coder needs to put down all the steps that the computer needs to take to reach a goal. This is also known as algorithmic programming.

     

    Let’s take an example of what we mean by that. Let’s look at C++. Suppose we want to add 5 and 3.

     
    int a = 5;
    int b = 3;
    int c;
    c= a + b;

     

    So, what exactly happened here? We did an addition, but it took four steps:

     

  • Declaring an integer a and assigning the value 5 to it.
  • Declaring an integer b and assigning the value 3 to it.
  • Declaring an integer c.
  • Adding the values of and b and storing them in c.
  •  

    Functional Programming Languages

     

    This style of programming, also known as declarative programming, was created to build a functional approach to problem-solving.

     

    How does functional programming work?

     

    Suppose there is a function f(x) that we want to use to calculate a function g(x) and then we want to use that to work with a function h(x). Instead of solving all of those in a sequence, we can simply club all of them in a single function – h(g(f(x))).

     

    So, why is the functional approach so desirable?

     

  • This approach is a lot more secure than imperative.
  • Functional approach helps in simpler Formal Verification which pretty much means that it is easier to mathematically prove what a program does and how it acts out.
  • It helps impart “High Assurance Code.”
  •  
    Both Haskell and Plutus are functional languages.
     

    Looking into Plutus

     

    Plutus is a higher level and simplified version of Haskell and has more similarities to mathematics rather than programming. Plutus is intended for use by institutions that require a high level of accuracy.

     

    To understand how basic Plutus programming works. Let’s do some addition, multiplication, factorial, and Fibonacci:

     

    add : Nat -> Nat -> Nat {
    add Zero n = n ;
    add (Suc m) n = Suc (add m n)
    }

    mul : Nat -> Nat -> Nat {
    mul Zero _ = Zero ;
    mul (Suc m) n = add (mul m n) n
    }

    fac : Nat -> Nat {
    fac Zero = Suc Zero ;
    fac (Suc n) = mul (Suc n) (fac n)
    }

    fib : Nat -> Nat {
    fib Zero = Suc Zero ;
    fib (Suc Zero) = Suc Zero ;
    fib (Suc (Suc n)) = add (fib n) (fib (Suc n))
    }

     

    In the code itself, you can see the differences between a functional approach and an imperative approach instead of painstakingly going through different sequential operations. We clubbed everything together in a function.

     

    Data scaling and reduced bloating

     

    Every little piece of data, relevant or not, gets stored in the blockchain for eternity. The problem is that as a network increases in size, the sheer influx of data the blockchain gets more and bulkier. As the blockchain gets more massive, it will become tougher for normal nodes to download and maintain it. The way Cardano wants to solve this problem is by incorporating the following techniques:

     

  • Pruning
  • Subscriptions
  • Compression
  •  

    Apart from these techniques, the Cardano chain uses partitioning. Instead of having a whole blockchain, a user can have a chunk of the blockchain and significantly reduce the amount of data they need to store. They can do so with sidechain integration.

     

    Sidechains

     

    Sidechain, as a concept, has been in the crypto circles for quite some time now. The idea is very straightforward; you have a parallel chain which runs along with the main chain. The side chain will be attached to the main chain via a two-way peg.

     

    Based on the research by Kiayias, Miller, and Zindros (KMZ) involving “non-interactive proofs of proofs of work,” Cardano’s sidechain will achieve the following functions:

     

  • Getting a compressed version of a blockchain.
  • Creating interoperability between chains.
  •  

    Using this system, Cardano aims to build an “internet of blockchains.” As per Hoskinson, Cardano wants to implement cross-chain transfers through sidechains without having to go through any middlemen.

     

    Achieving true interoperability

     

    Cardano needs to focus on the following features increase interoperability with the legacy world:

     

  • Metadata
  • Attribution
  • Compliance
  •  

    Metadata

     

    We are all familiar with the term “metadata,” but what exactly does it mean? Metadata is the story behind a transaction. If you spent 10 USD, the metadata would be:

     

  • What did you buy?
  • How did you get the money?
  • Where did you spend it?
  •  

    In traditional finance, this metadata is crucial since it’s a very opaque system. By adequately leveraging metadata, they can do the following:

     

  • Improve interoperability by telling them how data is exchanged among various systems.
  • It helps identify the data’s characteristics and behavior, making it very useful in resource protection.
  • Efficient electronic data organization.
  •  

    While this is good, the problem with metadata is that it’s incredibly personal, so it can inevitably lead to your privacy being compromised. Cardano is researching how to attach metadata to the chain selectively.

     

    Attribution

     

    Attribution extends the story told by metadata to include the names of the people involved in the transactions. If the blockchain permanently fixes attribution to itself, it will significantly compromise user privacy. Cardano enables its users to hand out attribution when needed.

     

    Compliance

     

    Compliance is used to check the legality of a transaction. Features like KYC (Know Your Customer), AML (Anti Money Laundering), ATF (Anti Terrorist Financing), etc., are included in compliance. So, if your friend pays you $100, compliance checks if the transaction is malicious or not.

     

    Cardano is researching how to use Metadata and Attribution along with Compliance to help their users whenever they need to interact with the banks.

     

    Current status of Cardano’s network

     

    The Cardano roadmap is a summary of Cardano development, which has been organized into five eras: Byron, Shelley, Goguen, Basho, and Voltaire. Each era is centered around a set of functionalities that will be delivered across multiple code releases.

     
    4 images of the respective team members and the roadmap of CARDANO (ADA)
     

  • Byron: Enables users to trade and transfer Ada. The Cardano mainnet was also launched.
  • Shelley: Ensures that the tech is in place for it to become a fully decentralized and autonomous system
  • Goguen: Will see the integration of smart contracts.
  • Basho: Centered around performance improvements.
  • Voltaire: IOHK will add a treasury system and governance.
  •  

    Cardano has recently announced the deployment of the Byron reboot. It comes with many updates for the Cardano blockchain in readiness for the Shelley era. The team has also rolled out a new “pre-release” version of their Daedalus wallet, dubbed Daedalus Flight, which lets the users try the wallet features.

     

    According to an IOHK blog post, the Byron reboot updates the Cardano network’s features, including the Cardano node and the Cardano explorer, the wallet backend, and the Daedalus wallet. IOHK says that the new code for the Byron reboot was built “from the ground up.” The blog post calls the revamped design modular, meaning that it will differentiate the ledger, consensus and network components. This will make it easy to upgrade any of them without impacting the rest. All these updates are expected to prepare the Cardano network for the upcoming Shelly mainnet.

     

    The Byron reboot will allow the Cardano network to process more transactions per second. Additionally, it will increase the network’s participation as the Cardano node will be more efficient for memory usage. This will make it easier for users to run a node even in poor network conditions.

     

    Cardano’s first major release, named Byron, went live on September 29, 2017, and saw the Cardano main-net launch. Cardano devs believe this will be a slow and sustainable migration without any obstacles. After the launch of Byron, IOHK will unveil the Haskell Shelley testnet, which will involve “onboarding stake pool operators from the Incentivized Testnet to help them set up and prepare for running their pools on the Shelley mainnet.”

     

    Cardano features to keep in mind

     

  • The Cardano ICO raised approximately $62 million.
  • Cardano’s token is named Ada after Ada Lovelace, a 19th-century mathematician recognized as the first computer programmer and daughter of the poet Lord Byron.
  • The following equation determines the fees for transferring ADA vary -> transfer fee = a + b * size. In a is a constant that currently equals 0.155381 ADA and b is another contract that equals 0.000043946 ADA/byte. “size” is the size of the transaction in bytes.
  • Each transaction costs at least 0.155381 ADA, with an additional cost of 0.000043946 ADA per byte of transaction size
  • The transaction fees in each epoch are collected in a fee pool and given to the appropriate slot leader.
  •  

    Conclusion

     

    Cardano has made a unique niche in a very crowded space by blending science and philosophy. Its combination of a brilliant team and functional programming can bring the blockchain and smart contracts to mainstream consciousness. We suggest that you go to their website and read up some more about this fascinating project.

     

    disclaimer

    CHAIA.iO is not a registered investment, legal or tax advisor or a broker/dealer. All investment/financial opinions expressed by CHAIA.iO or the authors of the respective articles on www.chaia.io are from personal research and experience of the owner of the site or the authors and are intended as educational material. Although best efforts are made to ensure that all information is accurate and up to date, occasionally unintended errors or misprints may occur. You should take independent financial advice from a professional in connection with, or independently research and verify, any information that you find on our Website and wish to rely upon, whether for the purpose of making an investment decision or otherwise.

    Rajarshi Mitra
    Blockchain Researcher