Exploring Mina: Is It Just Another Blockchain?

Avinash NayakAvinash Nayak
4 min read

We all know there are many existing blockchains like Bitcoin, Ethereum, Litecoin and other similar chains that have transformed the world with their decentralised digital currencies, but in the development space they might fall behind

Introducing Mina Protocol that is not just another blockchain, After going through the Mina Protocol's technical whitepaper here are some key points

  • Unlike traditional blockchains, the Mina Protocol introduces the concept of a "succinct blockchain." here, each block's state transition can be efficiently verified in constant time, regardless of the number of previous transitions. This marks a significant departure from traditional blockchains, where verification time increases linearly with the number of transactions.

  • The secret behind Mina's succinct blockchain is the use of recursively composed Succinct Non-interactive Arguments of Knowledge(SNARKs). These SNARKs allow Mina to construct a blockchain that is not only efficient but also maintains the decentralized nature of traditional blockchains.

  • Also on the financial side, the Mina protocol offers payment functionality like other blockchains with their Native token as MINA and with a verification time of just 0.2 seconds, this makes MINA feasible for lightweight clients to retrieve and verify the blockchain history

  • When it comes to transaction models, Mina employs an account-based approach, similar to Ethereum, as opposed to the UTXO model used by Bitcoin. In this system, the current state of the blockchain consists of a list of all account balances rather than a list of unspent coins (UTXOs). This simplifies the transaction process and enhances user-friendliness. Users can use Auro wallet to make transactions like sending MINA or interacting with dapps

  • Mina uses Ouroboros Samasika as its consensus mechanism, the first provably-secure proof-of-stake (PoS) consensus protocol for succinct blockchains. This consensus mechanism ensures the security and integrity of the blockchain while maintaining its efficiency.

Mina for Developers

Developers can develop zkApps on MINA protocol, similar to smart contracts, that are powered by zero-knowledge proofs, More about zk apps here, but here's a quick intro,zkapps are written in typescript, a statically-typed superset of JavaScript that compiles to plain JavaScript.

To get started you need to install zkapp-cli you can do that by using your package managers like npm using npm install -g zkapp-cli you can verify the installation by using zk --version and it outputs the version installed

A zkApp consists of a smart contract and a user interface (UI). The smart contract's custom logic is executed by a prover function running in the user's web browser, generating a zero-knowledge proof. The proof is then verified by the Mina network using a verifier function. Users interact with the zkApp's UI to input data, and transactions containing the proof are sent to the Mina blockchain for validation and state updates.

Development steps:

  • You can start by cloning this repository using git clone https://github.com/br0wnD3v/zkApp_Base

  •     cd contracts
        npm install
        npm run build // to convert the ts files to js
    
      cd ui
      npm install
      npm run start // to start the ui
    
  • The content directory looks like

      ├── contracts
      │   ├── build
      │   │   └── src
      │   │       ├── index.d.ts
      │   │       ├── index.js
      │   │       ├── index.js.map
      │   │       ├── interact.d.ts
      │   │       ├── interact.js
      │   │       └── interact.js.map
      │   ├── jest.config.js
      │   ├── package.json
      │   ├── src
      │   │   ├── index.ts
      │   │   └── interact.ts
      │   └── tsconfig.json
      └── ui
          ├── next.config.js
          ├── package-lock.json
          ├── package.json
          ├── public
          │   ├── assets
          │   └── coi-serviceworker.min.js
          ├── src
          │   ├── pages
          │   │   ├── _app.page.tsx
          │   │   ├── api
          │   │   │   └── hello.ts
          │   │   ├── reactCOIServiceWorker.tsx
          │   │   ├── zkappWorker.ts
          │   │   └── zkappWorkerClient.ts
          │   └── styles
          │       ├── Home.module.css
          │       └── globals.css
          └── tsconfig.json
    
  • To begin with the contracts aspect, developers can write smart contracts using TypeScript within the "contracts/src" directory by using snarkyjs and zk file This command generates two files "hello.ts" and "hello.test.ts." In "hello.ts," users can write the contract's logic and tests in "hello.test.ts".

  • Once the smart contract is coded and tested Now you can develop the frontend using the same snarkyjs library to interact with the smart contract on the ui, using auro wallet

We use zkappWorker.ts and zkappWorkerClient.ts to activate the blockchain instance asynchronously this helps in a smooth interaction

Conclusion

Mina Protocol offers a developer-friendly environment for building zkApps using TypeScript and zero-knowledge proofs. Developers can write smart contracts, test them, and develop the frontend UI to interact with the contracts using the provided tooling and libraries.

0
Subscribe to my newsletter

Read articles from Avinash Nayak directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Avinash Nayak
Avinash Nayak