Coder Social home page Coder Social logo

transgate-js-sdk's Introduction

transgate-js-sdk.js

Transgate JS-SDK

ES Version

The Transgate JS-SDK is a utility package for Transgate that enables developers to easily launch Transgate.

Register an develop account

Please register an account on the zkPass Dev Center and create a project. Then you can add schemas for your project.

Installation

You can install the package either using NPM or using Yarn

Using NPM

npm install @zkpass/transgate-js-sdk

Using Yarn

yarn add  @zkpass/transgate-js-sdk

Example

import TransgateConnect from '@zkpass/transgate-js-sdk'

const requestVerifyMessage = async () =>{
  try{
    const appid = "8fb9d43c-2f24-424e-a98d-7ba34a5532f5" //Locate this form on the development platform

    const connector = new TransgateConnect(appid)
    const isAvailable = await connector.isTransgateAvailable()

    if(isAvailable){
      //The schema ID that you add for the project
      const schemaId = "516a720e-29a4-4307-ae7b-5aec286e446e"

      const res = await connector.launch(schemaId)// This method can be invoked in a loop when dealing with multiple schemas

      //You have the flexibility to handle the validation results based on your requirements.        

    }else{
      console.log('Please install zkPass Transgate from https://chromewebstore.google.com/detail/zkpass-transgate/afkoofjocpbclhnldmmaphappihehpma')
    }
  }catch(error){
    console.log('transgate error', error)
  }
}
  

Verify result fields

Field Name Description
allocatorAddress The address of the allocator node
allocatorSignature Signature of the task information by the allocator node
publicFields Values of public fields defined in schema
publicFieldsHash Hash of public fields values
taskId Unique id of the task allocated by the allocator node
uHash Hash value of user unique id in the data source
validatorAddress The address of the validator node
validatorSignature The signature of the verification result by the validator node

Error code

Error Code Description
100000 ILLEGAL_NODE
100001 TRANSGATE_NOT_INSTALLED
100002 ILLEGAL_APPID
100003 ILLEGAL_SCHEMA_ID
100004 TASK_RPC_ERROR
100005 CONNECT_NODE_ERROR
110001 NOT_MATCH_REQUIREMENTS
110002 VERIFICATION_CANCELED
110003 UNEXPECTED_VERIFY_ERROR

transgate-js-sdk's People

Contributors

stoneomo avatar

Stargazers

 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.