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

@verida/vda-reward-client

v4.4.0

Published

Client to manage reward

Downloads

74

Readme

VDA Reward Client

A client library for claiming Verida Reward.

Users can claim the Verida token as reward for registered claim type such as Facebook, Twitter, and etc. Claim types are added and removed by the Verida team.

Verida package dependency

This packages has dependency for following verida-js packages.

  • @verida/types
  • @verida/vda-common
  • @verida/vda-client-base

Also, has a dependency for following verida-js packages for test.

  • @verida/vda-common-test
  • @verida/vda-node-manager
  • @verida/encryption-utils

Installation

yarn add @verida/vda-reward-client

Usage

This library can be in read only mode where it just calls the view functions or in read and write mode where it can also call the claim() and claimToStorage() functions.

Read Only

Setup the library in read only mode for reading usernames and DIDs:

import { VeridaRewardClient } from '@verida/vda-reward-client'
import { EnvironmentType } from '@verida/types'

// Create name Client
const rewardClient = new VeridaRewardClient({
    environment: EnvironmentType.TESTNET
})

Get claim type info

const claimTypeInfo = await rewardClient.getUsernames(`<claimType id>`);
console.log(usernames)

Read and Write

In order to write to the blockchain, you will require a Polygon private key with MATIC tokens.

Setup the library in read and write mode to support the above get methods and claim reward:

import { VeridaRewardClient } from '@verida/vda-name-client'
import { EnvironmentType, Web3CallType } from '@verida/types'

// DID address that controls the proof of eligibility to mint the SBT
const DID_ADDRESS = '0x...'
// DID private key that controls the proof of eligibility to mint the SBT
const DID_PRIVATE_KEY = '0x...'
// Polygon private key that will fund blockchain transactions
const POLYGON_PRIVATE_KEY = '0x...'
// How to make blockchain requests. This should be 'web3' unless using Verida's meta transaction server.
const CALL_TYPE = 'web3'
// (Optional) Polygon RPC URL (Mumbai testnet)
const RPC_URL = 'https://rpc-mumbai.maticvigil.com'

// Create name Client
const rewardClient = new VeridaRewardClient({
    environment: EnvironmentType.TESTNET
    callType: CALL_TYPE,
    did: DID_ADDRESS,
    signKey: DID_PRIVATE_KEY,
    web3Options: {
        rpcUrl: RPC_URL,
        privateKey: POLYGON_PRIVATE_KEY
    }
})

Claim to an address

const claimTypeId = '<Claim type id>'; //ex: 'facebook'
const hash = '<Input credential>'; //ex: facebook id
const receiverAddress = '<Recipient wallet or contract address>';
const proof = '<Proof from Verida>';
await rewardClient.claim(claimeTypeId, hash, receiverAddress, proof)

Claim to storage

const claimTypeId = '<Claim type id>'; //ex: 'facebook'
const hash = '<Input credential>'; //ex: facebook id
const didAddress = '<DID address that has a node in the `StorageNodeRegistry` contract>';
const proof = '<Proof from Verida>';

await rewardClient.claimToStorage(claimeTypeId, hash, proof, didAddress);

if DIDAddress of the rewardClient instance has a node in the StorageNodeRegistry contract and want to claim the rewards for the address, you can last parameter as following:

await rewardClient.claimToStorage(claimeTypeId, hash, proof);