npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@jitendra_123/sas-sdk

v1.0.4

Published

SDK for starknet-attestation-service

Downloads

290

Readme

SAS-SDK

@jitendra_123/sas-sdk is an SDK for interacting with the StarkNet Attestation Service (SAS) on StarkNet. It simplifies schema creation, attestation management, and validation for developers building on StarkNet.

Features

  • Schema Management: Create, fetch, and manage schemas.
  • Attestation Services: Register, fetch, and revoke attestations.
  • Validation: Verify attestation validity.
  • StarkNet Compatibility: Built for seamless integration with StarkNet's ZK-rollup ecosystem.

Installation

Install the SDK via npm:

npm install @jitendra_123/sas-sdk

Usage

Here is an example of how to use the SAS SDK:

const { SAS } = require('@jitendra_123/sas-sdk');
require('dotenv').config();

const {
  ACCOUNT_ADDRESS,
  SR_CONTRACT_ADDRESS,
  SA_CONTRACT_ADDRESS,
  SR_ABI,
  SA_ABI,
} = require('./constants');

(async () => {
  try {
    const sas = new SAS(
      process.env.NODE_URL,
      process.env.PRIVATE_KEY,
      ACCOUNT_ADDRESS,
      SR_CONTRACT_ADDRESS,
      SA_CONTRACT_ADDRESS,
      SR_ABI,
      SA_ABI
    );

    // Register a new schema
    const schema = "felt252 emp_Name, u256 emp_ID, felt252 emp_Teams, u256 emp_BG";
    const resolver = "0x0000000000000000000000000000000000000000";
    const revocable = true;
    const registrationResult = await sas.createSchema(schema, resolver, revocable);
    console.log('Schema registered:', registrationResult);

    // Fetch a schema by UID
    const schemaUID = "0x1956053be88994deebeed5da9405e422a94451e6bc5fb9ff8612b4fa49aece7c";
    const schemaDetails = await sas.getSchema(schemaUID);
    console.log('Fetched Schema:', schemaDetails);

    // Register an attestation
    const recipient = "0x0124f678b5b285a9c88b7283dcd19bf9e2a5f7d89afe0a7cd7ed5da3f3257212";
    const expirationTime = 1764996235;
    const schemaData = "felt252 name Jk, u256 stu_ID 92890, felt252 stu_Branch cse";
    const attestationResult = await sas.registerAttestation(
      recipient,
      expirationTime,
      revocable,
      0,
      schemaData,
      0,
      schemaUID
    );
    console.log('Attestation registered:', attestationResult);

    // Validate attestation
    const attestationUID = "0xaec37c669883d8a6d8db9f9403b707680c1f89fd5167331f0c2651ad14ce82bd";
    const isValid = await sas.isAttestationValid(attestationUID);
    console.log('Is Attestation Valid:', isValid);
  } catch (error) {
    console.error('Error:', error.message);
  }
})();

Environment Variables

Create a .env file in your project root and add the following:

NODE_URL=<your-starknet-node-url>
PRIVATE_KEY=<your-private-key>

API Reference

SAS Class

Constructor

const sas = new SAS(
  nodeUrl,
  privateKey,
  accountAddress,
  srContractAddress,
  saContractAddress,
  srAbi,
  saAbi
);

| Parameter | Description | |---------------------|------------------------------------------------| | nodeUrl | The StarkNet node URL. | | privateKey | Private key for authentication. | | accountAddress | StarkNet account address. | | srContractAddress | Schema Registry contract address. | | saContractAddress | Schema Attestation contract address. | | srAbi | ABI for the Schema Registry contract. | | saAbi | ABI for the Schema Attestation contract. |

Methods

  • createSchema(schema, resolver, revocable): Registers a new schema.
  • getSchema(schemaUID): Fetches details of a specific schema.
  • getAllSchemas(): Fetches all registered schemas.
  • registerAttestation(...): Registers a new attestation.
  • isAttestationValid(attestationUID): Checks the validity of an attestation.
  • revokeAttestation(...): Revokes an attestation.

Repository

For more information, visit the GitHub repository.

License

This SDK is released under the MIT License.