KVStoreUtils

@human-protocol/sdkarrow-up-right


@human-protocol/sdkarrow-up-right / kvstore / KVStoreUtils

Class: KVStoreUtils

Defined in: kvstore.ts:354arrow-up-right

Introduction

Utility class for KVStore-related operations.

Installation

npm

npm install @human-protocol/sdk

yarn

yarn install @human-protocol/sdk

Code example

Signer

Using private key (backend)

Constructors

Constructor

new KVStoreUtils(): KVStoreUtils

Returns

KVStoreUtils

Methods

get()

static get(chainId, address, key, options?): Promise<string>

Defined in: kvstore.ts:429arrow-up-right

Gets the value of a key-value pair in the KVStore using the subgraph.

Parameters

chainId

ChainIdarrow-up-right

Network in which the KVStore is deployed

address

string

Address from which to get the key value.

key

string

Key to obtain the value.

options?

SubgraphOptionsarrow-up-right

Optional configuration for subgraph requests.

Returns

Promise<string>

Value of the key.

Throws

  • Thrown if the network's chainId is not supported

Throws

  • Thrown if the Address sent is invalid

Throws

  • Thrown if the key is empty

Code example


getFileUrlAndVerifyHash()

static getFileUrlAndVerifyHash(chainId, address, urlKey, options?): Promise<string>

Defined in: kvstore.ts:479arrow-up-right

Gets the URL value of the given entity, and verifies its hash.

Parameters

chainId

ChainIdarrow-up-right

Network in which the KVStore is deployed

address

string

Address from which to get the URL value.

urlKey

string = 'url'

Configurable URL key. url by default.

options?

SubgraphOptionsarrow-up-right

Optional configuration for subgraph requests.

Returns

Promise<string>

URL value for the given address if it exists, and the content is valid

Code example


getKVStoreData()

static getKVStoreData(chainId, address, options?): Promise<IKVStorearrow-up-right[]>

Defined in: kvstore.ts:374arrow-up-right

This function returns the KVStore data for a given address.

Parameters

chainId

ChainIdarrow-up-right

Network in which the KVStore is deployed

address

string

Address of the KVStore

options?

SubgraphOptionsarrow-up-right

Optional configuration for subgraph requests.

Returns

Promise<IKVStorearrow-up-right[]>

KVStore data

Throws

  • Thrown if the network's chainId is not supported

Throws

  • Thrown if the Address sent is invalid

Code example


getPublicKey()

static getPublicKey(chainId, address, options?): Promise<string>

Defined in: kvstore.ts:540arrow-up-right

Gets the public key of the given entity, and verifies its hash.

Parameters

chainId

ChainIdarrow-up-right

Network in which the KVStore is deployed

address

string

Address from which to get the public key.

options?

SubgraphOptionsarrow-up-right

Returns

Promise<string>

Public key for the given address if it exists, and the content is valid

Code example

Last updated