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

valist-software-license

v0.0.7

Published

Valist Software license

Downloads

5

Readme

Valist Software License lightweight SDK

About

Valist is the Universal software deployment and monetization protocol. Valist Software License is the lightweight sdk of valist-sdk only having fewer core functionality like purchaseProduct, purchaseProductToken, checkLicense and hasLicense.

A checkLicense function:

  • Prompts a human-readable message signature request from the user's wallet
  • Recovers the address from the signature
  • Uses that address to check the user's balance on the Software License NFT contract

A purchaseProduct function prompts the user to purchase the Software License NFT with native MATIC.

A purchaseProductToken function prompts the user to purchase the Software License NFT with the user's desired (and supported) token.

A hasLicense function that checks whether a given address has license to a given product ID.

Learn more about Valist.

Installing the package

Install the package using npm or yarn as desired to get started.

npm install --save valist-software-license

OR

yarn add valist-software-license

Documentation

For the TypeScript API documentation, please see the following link:

Usage

Creating License client

import { create } from "valist-software-license"
import ethers from "ethers"

const provider = new ethers.providers.Web3Provider(window.ethereum);
const client = create(provider, {chainId: 80001})

// Or with wagmi
import { create, Signer } from "valist-software-license"
import { useSigner } from "wagmi"

const { data:signer } = useSigner();
const client = create(signer as Signer, {chainId: 80001})

// Or with ethers wallet
import { create, Provider } from "valist-software-license"
import { Wallet } from "ethers"

const provider = new ethers.providers.JsonRpcProvider('https://rpc.ankr.com/polygon_mumbai');
const wallet = Wallet.createRandom().connect(provider);
const client = create(wallet, {chainId: 80001})

Purchase Product License using MATIC

// Valist Product ID
const productId = "0x62540d928401ecc8386fe86066a1d1f580e60737f0d87444ba7558786dc2e905";
// desired recipient address for license
const recipient = "0xFf57433E786C00e0df38bA17a9724EC78C3F6f5B";

const tx = await client.purchaseProduct(productId, recipient);
// Wait for the transaction to be mined...
await tx.wait();

Purchase Product License using ERC20 tokens

// Valist Product ID
const productId = "0x62540d928401ecc8386fe86066a1d1f580e60737f0d87444ba7558786dc2e905";
// desired recipient address for license
const recipient = "0xFf57433E786C00e0df38bA17a9724EC78C3F6f5B";
// chainlink token address
const tokenAddress = "0x326C977E6efc84E512bB9C30f76E30c160eD06FB";

const tx = await client.purchaseProductToken(tokenAddress, productId, recipient);
// Wait for the transaction to be mined...
await tx.wait();

Check license by signing message

// Valist Product ID
const productId = "0x62540d928401ecc8386fe86066a1d1f580e60737f0d87444ba7558786dc2e905";
const address = "0xFf57433E786C00e0df38bA17a9724EC78C3F6f5B":
const nonce = client.generateNonce()
// This is the default signing message if custom signing message is not provided
const signingMessage = `Authenticate your wallet with address: ${address}\nNonce: ${nonce}`;
const { hasLicense } = await client.checkLicense(productId, signingMessage);
console.log(hasLicense); // True or False

Check license of address

const productId = "0x62540d928401ecc8386fe86066a1d1f580e60737f0d87444ba7558786dc2e905";
const address = "0xFf57433E786C00e0df38bA17a9724EC78C3F6f5B";

const hasLicense = await client.hasLicense(productId, address);
console.log(hasLicense); // True or False

Development

Building

yarn build

Linting

yarn fix

Testing

yarn test

Generating and publishing html docs to GitHub pages

yarn doc:html
yarn doc:publish

Publishing npm package

npm publish

Author

👤 Pawan Paudel

🤝 Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

Copyright © 2022 Pawan Paudel.