Giter Club home page Giter Club logo

mina-protocol's Introduction

MinaFT | Zero-Knowledge App -> zkApp

First ERC721 like smart contract on Mina Protocol with basic NFT minting and transferring UI.

Zero-Knowledge App (zkApp) Functionning

Deploying a smart contract on mina protocol is done in a completely different way to the standard way on Ethereum.

Ethereum is known for having an Ethereum Virtual Machine (EVM), which uses some of the computing power provided by the full nodes on its network to calculate the deployment of smart contracts on its blockchain. Each smart contract allocates a certain amount of computing power so that it can be deployed on the Ethereum blockchain by the EVM.

Mina Protocol does not have an EVM or a Decentralized Virtual Machine.

Instead, a library previously installed by the developer is used to cryptographically sign the operation of the smart contract (zkApp). The smart contract is deployed locally off-chain from the computer itself or from a server. The cryptographic signature generated on the entire contract is then taken over by the mina protocol to be validated by its peer nodes.

This generated cryptographic signature proves the honesty of the contract's operation, the owner behind it, and data stored on it without revealing any of the raw data recorded. By asking a series of conditional questions, he is able to summarise the validity of the application.

Fundamentally, a zkApp consists of a smart contract and a UI to interact with it.

zkApp Initialisation

Initialize the necessary libraries to interpret correctly the methods and configured rules by MINA Foundation and O1Labs company. Install zkApp CLI :

npm install -g zkapp-cli

Start own Project

1. Create own project

zk project <mynamedproj>

Inside src directory is built a the smart contract file.

2. Select an accompanying UI framework

? Create an accompanying UI project too? …
❯ next
svelte
nuxt
empty
none

3. Running tests

npm run test

3.1 Re-running tests automatically

npm run testw

4. Configure zkApp

zk config

The command prompts guide you to add a deploy alias to your project [config.json] file.

The deploy alias can be anything you want. For more details, see Deploy alias in Tutorial 3: Deploy to a Live Network.

For this example on Berkeley Testnet, use:

  • Deploy alias name: [berkeley]

  • This example uses [berkeley], but the deploy alias name can be anything and does not have to match the network name.

  • Mina GraphQL API URL: [https://proxy.berkeley.minaexplorer.com/graphql]

  • Transaction fee to use when deploying: [0.1]

  • Account to pay transaction fees: Create a new fee payer pair

Smart Contract Structure

  • main | mina protocol connexion
  • deploy | deploying the token contract to the blockchain
  • mint | minting NFTs
  • transfer | handling NFT transfers
  • getState | display public address of the wallet holding the tokens

Issue 0.0 | git remote repository synchronisation with local repo

git fatal: unable to access 'https://github.com/devstackweb3/mina-protocol/minanft.git/': URL using bad/illegal format or missing URL

Issue trying to push in a sub-directory from a local repository made on desktop.

git remote add origin 'https://github.com/devstackweb3/mina-protocol/minanft.git'
git push -u origin main

remote: Not Found fatal: repository 'https://github.com/devstackweb3/mina-protocol/minanft.git/' not found

First of all checking the status of push attempts in the remote add origin state.

git remote -v

Remove previous repo added in the remote side before push attempt.

git remote rm origin

Possible single quote issue with the problem of identification URL path.

git remote add origin "https://github.com/devstackweb3/mina-protocol/minanft.git"
git push -u origin main

Possible READ only access, lack of administrator use connexion with remote library.

Solution with password integration is too old & seems deprecated. Github removed use of username and password on August 13, 2021.

git remote add origin "https://devstackweb3:[email protected]/devstackweb3/mina-protocol/minanft.git"

Possible READ only access, lack of administrator use connexion with remote library. Solution with token credentials is more recent (2022).

git remote set-url origin https://[email protected]/username/reponame.git

Taking a step back from the configuration of the local repository, I noticed that default configuration of project has started with the name of MinaNF dedicated to Github repo name. A name by default accessible in next.config.js and pages/reactCOIServiceWorker.tsx, for any possible changes. In fact the project was created under a new repo named MinaNF.git.

Issue 0.1 | fatal refusing to merge unrelated histories

Following an attempt to pull a request from the current remote main branch stated inside the "https://github.com/devstackweb3/mina-protocol" through the remote add origin, this error occurs when 2 totally different git projects try to be merged together.

To solve the problem, the following command is helpfull :

git pull origin master --allow-unrelated-histories

Partial Solution | Updating remote repository mina-protocol.git

Context : GitHub repo has seen new commits pushed to it, while were working locally :

git pull --rebase origin main
git push origin main

Solution | Updating remote repository

Add all modified documents/folders or new documents/folders created.

git add .

Naming the latest changes and putting in pre-deliver mode before pushing repository to the remote side on github.

git commit -m "MYNAMEDUPDATEDCOMMIT"

Adapting the updates to the remote github repository before pushing.

git pull --rebase origin main

Pushing the whole commits made on the branch named "main".

git push origin main

Issue 1.0 | SnarkyJS Library depreciated

It's necessary to update imports and methods used in the previous reference for a clear interpretation by libraries. image

References

Official documentation Mina Protocol

https://docs.minaprotocol.com/zkapps/how-to-write-a-zkapp

Project shared during the ETHAMSTERDAM (2022 | Event)

https://ethglobal.com/showcase/minaft-b1f35

https://github.com/orkunkilic/MinaFT/blob/main/src/index.ts

mina-protocol's People

Contributors

devstackweb3 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.