0.1.4 • Published 2 years ago

@gitcoinco/passport-sdk-reader v0.1.4

Weekly downloads
-
License
AGPL-3.0
Repository
-
Last release
2 years ago

Gitcoin Passport SDK: Reader

Reads from any Gitcoin Passport stream (on Ceramic)

Installation

Add to your project...

yarn add @gitcoinco/passport-sdk-reader

--

Or download this .git repository and install dependencies manually...

yarn install

Build...

yarn run webpack

Basic Usage

Firstly, we need to import the library/bundle and construct a PassportReader instance, passing in a ceramic node URL and a networkId

// add to your project as a module
import PassportReader from "@gitcoinco/passport-sdk-reader"

// or import the bundle
<script src="./dist/reader.bundle.js" type="script/javascript"/>

...

// create a new instance pointing at Gitcoins mainnet Ceramic node
const reader = new PassportReader("https://ceramic.passport-iam.gitcoin.co", "1");

// read a Passport for any Ethereum Address
const passport = await reader.getPassport("0x0...");

The PassportReader instance exposes read-only methods to get the content of a Gitcoin Passport:

  • getGenesis - pass in an Ethereum address and get back the did:pkh and genesis IDX streams
reader.getGenesis(address: string): Promise<CeramicGenesis | false>
  • getPassport - pass in an Ethereum address and get back a fully hydrated Passport record
reader.getPassport(address: string): Promise<CeramicPassport | Passport | false>
  • getPassportStream - pass in a Ceramic DID and get back a raw Passport stream record *note that this is a shallow copy of the passport (and needs to have its stamps hydrated)
reader.getPassportStream(address: string): Promise<CeramicPassport | false>