Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Mint an NFT certificate for SUMilan events' participants

License

Notifications You must be signed in to change notification settings

Axelera/SUMilanCertificates

Repository files navigation

SingularityU Milan Chapter Certificates

Generate NFT EIP-721 compliant participation certificates for SingularityU Milan Chapter events.

ARCHIVED: this repository has been archived because it has been merged inside of SUMilanApp monorepo.

Overview

NFTs are generated by a Smart Contract deployed on Ethereum (currently only on the Ropsten testnet because of the fees are too high on the Mainnet).

  • The Smart Contract is written in Solidity.

  • Hardhat is used to develop, test and deploy the Smart Contract.

  • Alchemy's blockchain APIs are used to sign transactions.

  • Pinata APIs are used to publish certificate images to IPFS.

  • OpenZeppelin's libraries are used inside the Smart Contract.

  • Node.js is used to create an HTTP endpoint, reachable by the webapp.

Usage

Requirements

1. Required software

Node.js and npm must be installed on your machine.

2. Ethereum wallet

The Smart Contract is deployed by an Ethereum wallet/address, so you must have private and public keys of an Ethereum address. You can create an ETH wallet using Metamask and then export the account private key form there. The public key is just your Ethereum address. These keys will be used to deploy the Contract and sign the transactions.

3. Alchemy API

In order to sign transactions to invoke the Contract's functions, you must be able to connect to an Ethereum node. Since today running an ETH node is challenging for most of the people, there are Node-as-a-Service platforms like Alchemy, Infura, etc. that offer you HTTP APIs to handle this problem.

Our implementation uses Alchemy as ETH node "backend", so you have to create an App on Alchemy and obtain an API URL from the Alchemy Dashboard.

4. IPFS & Pinata API

In order to keep the certificate image stored somewhere publicly and safely, we choose to upload it to IPFS. Again, running an IPFS node is challenging, so services like Pinata handle this for you and expose their HTTP APIs.

Our implementation uses Pinata APIs, so you must create an account there and obtain the API Keys.

5. Supabase API

This repo is stricly connected to the webapp, because it offers a "backend" for generating NFT partecipation certificates for the SingularityU Milan Chapter events' attendants. The events' data are stored on Supabase database, so you must have the Supabase API Keys also in this repo.

Installation

  1. clone this repo:
    git clone https://github.com/Axelera/SUMilanCertificates.git
    
  2. move inside the repo directory:
    cd SUMilanCertificates
    
  3. create a file called .env and put these lines inside:
    METAMASK_PRIVATE_KEY="<obtained at step 2 of requirements>"
    METAMASK_PUBLIC_KEY="<obtained at step 2 of requirements>"
    
    ALCHEMY_API_URL="<obtained at step 3 of requirements>"
    
  4. install dependencies:
    npm insall
    

Deploy the contract

Once you have completed the Installation steps, you are ready to deploy the Contract to Ethereum. By default, the target network is Ropsten (reasons explained above).

  1. compile the Contract:
    npx hardhat compile
    
  2. deploy the Contract with this command:
    npx hardhat run scripts/deploy.js
    
    should generate this output:
    Deploying contracts with the account: <METAMASK_PUBLIC_KEY>
    Account balance: <Your ETH Ropsten balance>
    Contract deployed to address: <ETH address of the deployed contract> # <- write it down
    

Store the contract address

Once you have deployed the Contract and obtained its address, add the following line to the .env file (which you created in the step 3. of Installation section):

CONTRACT_ADDRESS="<the contract address>"

Run the Node.js API

See here.

Repo structure

  • contracts/: Smart Contract's Solidity code. More info here.
  • scripts/: JS scripts to deploy and update the Contract (run with npx hardhat run command).
  • test/: JS scripts to test Contract's functionalities (run with npx hardhat test command).
  • api/: more info here.
  • hardhat.config.js: the configuration file for Hardhat, docs here.

Roadmap

We are planning to migrate the Smart Contract from Ethereum to IOTA, because the second one has no fees. IOTA Smart Contracts implementation supports Solidity contracts by running an EVM but now it's all still in beta (info), so we want to wait until it will be more stable.

Contributing

Every contribution is welcome! Feel free to open issues and/or create PRs.

License

SUMilanCertificates is released under the MIT License.

Releases

No releases published

Packages

No packages published