Giter Club home page Giter Club logo

xrpl-nft-proof-of-attendance-infrastructure's Introduction

XRPL-NFT-Proof-of-Attendance-Infrastructure

XRPL-NFT-Proof-of-Attendance-Infrastructure is a MERN stack application that contains functionality to allow event organizers to mint and distribute Attendance NFTs on the XRP Ledger. The core parts of this application consist of a React frontend, Express backend, Rest API (nftRoutes.js), and XrplNFTHelper.js. Please note, mongo has been disconnected. Any db solution can replace it but isn't needed at this point. All metadata storage for the NFT's is currently stored locally is JSON object files. In a live version these files will need to be stored in a location with a public URI.

In order to facilitate storing json files with a public uri and continue using the site without the need for a db solution XummApi.js has was introduced. It consists of 11 REST API endpoints and will allow the developer to build on top a marketplace for NFT owners and minters to trade and sell their NFTs utilizing the XUMM Wallet and Pinata IPFS solution.

Install and use the developer example

  1. Install all packages. Do three npm installs in all three directories.
XRPL-NFT-Proof-of-Attendance-Infrastructure-main/XRPL-NFT-Proof-of-Attendance-Infrastructure-main/ npm install
XRPL-NFT-Proof-of-Attendance-Infrastructure-main/XRPL-NFT-Proof-of-Attendance-Infrastructure-main/backend/ npm install
XRPL-NFT-Proof-of-Attendance-Infrastructure-main/XRPL-NFT-Proof-of-Attendance-Infrastructure-main/frontend npm install

  1. Run backend then frontend.
../backend/npm start
../frontend/npm start

XrpNFTHelper.js

XrplNFTHelper.js is Javascript class that is meant to be used within any NodeJS project. It contains functionality that allows event organizers to mint and distribute Attendance NFTs on the XRP Ledger. It is meant to be imported and instantiated inside the routes file of your project.

Instantiating XrpNFTHelper.js Please note, the XrpNFTHelper class has a constructor that takes a javascript object. Before performing a transaction on the ledger certain details are required, depending on the type of transaction (All required paramaters are listed in the comments). These details are passed during the instantiation of XrpNFTHelper class.

import XrplNFTHelper from './XrplNFTHelper.js';

router.route('/burnAllNFT').get((req, res) => {

  const nftManager = new XrplNFTHelper({TransactionType: "NFTokenBurn", 
  Account: body.account, 
  Secret:  body.secret,});

  nftManager.burnAllNFT().then( (result) => { return result }) 
  
  })

XrpNFTHelper.js Functions

  • mintToken() Mint Single token.

    @Params (required class object variables) - created during instantiation of XrpNFTHelper.js

    TransactionType: this.transactionDetails.TransactionType,
    Account: this.transactionDetails.Account,
    URI: this.transactionDetails.URI,
    Flags: this.transactionDetails.Flags,
    NFTokenTaxon: this.transactionDetails.NFTokenTaxon,
    
    @returns NFTokenID string
    
  • mintX() Mint any number of tokens with identical info.

    
    @Params (required class object variables)
    TransactionType: this.transactionDetails.TransactionType,
    Account: this.transactionDetails.Account,
    URI: this.transactionDetails.URI,
    Flags: this.transactionDetails.Flags,
    NFTokenTaxon: this.transactionDetails.NFTokenTaxon,
    
    @returns array of NFTokenID strings
    
    
  • getTokensFromLedger() Get all tokens from the ledger.

@Params (required class object variables)

Account: this.transactionDetails.Account

@returns array of NFTokenID's strings
  • burnNFT() Burn specified NFT.

Params (required class object variables): 
          TransactionType: this.transactionDetails.TransactionType,
          Account: this.transactionDetails.Account,
          NFTokenID: this.transactionDetails.NFTokenID

  @Returns: String Transaction Result.
  • burnAllNFT() Burn all NFTs in the account.
  Params (required class object variables): 
  transactionDetails.Secret
  transactionDetails.Account

  @Returns: 
  Array of NFTokenID's for removal of metadata storage

Rest API - nftRoutes.js

The rest API is located at XRPL-NFT-Proof-of-Attendance-Infrastructure/backend/routes/nftRoutes.js.

There are currently 6 GET routes (listed below) that create a class object of XrpNFTHelper.js based on paramaters passed via the body header of a GET request. Each route expects a stringified JSON object.

For example, in a react front end the /mintNFT route is properly accessed as such:

const headers = {'body': JSON.stringify(formData)}

let response = await fetch('/api/mintNFT', {headers})
  setResponse(response)

Rest API Specifications:

  • /api/mintNFT Mints the specified amount of tokens.
Expects Stringified JSON object with the following key, value pairs.
*Please note: these are required. Additional metadata can be attached to memo key.

{
  account: String, 
  secret:  String,
  numberOfTokens: String //body header should contain a string that represents an int.
}

@Returns

  • /burnNFT Burn specified Event token.
Expects Stringified JSON object with the following key, value pairs.

{
    account: String, 
    secret:  String,
    nftTokenID: String
}

@Returns
-String (Transaction Result)
  • /burnAllNFT Burn all NFTs in the account.
Expects Stringified JSON object with the following key, value pairs.

{
    account: String, 
    secret:  String,
}

@Returns
Stringified JSON object array with list of removed tokens.


  • /getTokens Get all NFT's from storage.

@Returns Stringified JSON object Array of NFTokenID strings that currently exist in metadata storage


  • /getTokensFromLedger Get all NFT's from ledger.

Expects Stringified JSON object with the following key, value pairs.

{
    account: String
}

@Returns Stringified JSON object Array of NFTokenID strings that currently exist per the ledger


  • /getData Get all metadata.

Expects Stringified JSON object with the following key, value pairs.


  {
    nftTokenID: String
  }


@Returns Stringified JSON object with a memo object containing all details.


xrpl-nft-proof-of-attendance-infrastructure's People

Contributors

spicycheeto avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

jonathanlei

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.