KVStoreClient
@human-protocol/sdk / Modules / kvstore / KVStoreClient
Class: KVStoreClient
kvstore.KVStoreClient
Introduction
This client enables to perform actions on KVStore contract and obtain information from both the contracts and subgraph.
Internally, the SDK will use one network or another according to the network ID of the signerOrProvider
. To use this client, it is recommended to initialize it using the static build
method.
A Signer
or a Provider
should be passed depending on the use case of this module:
Signer: when the user wants to use this model in order to send transactions caling the contract functions.
Provider: when the user wants to use this model in order to get information from the contracts or subgraph.
Installation
npm
yarn
Code example
Signer
Using private key(backend)
Using Wagmi(frontend)
Provider
Hierarchy
↳
KVStoreClient
Table of contents
Constructors
Properties
Methods
Constructors
constructor
• new KVStoreClient(signerOrProvider
, networkData
): KVStoreClient
KVStoreClient constructor
Parameters
Returns
Overrides
Defined in
Properties
contract
• Private
contract: KVStore
Defined in
networkData
• networkData: NetworkData
Inherited from
Defined in
signerOrProvider
• Protected
signerOrProvider: Signer
| Provider
Inherited from
BaseEthersClient.signerOrProvider
Defined in
Methods
get
▸ get(address
, key
): Promise
<string
>
This function returns the value for a specified key and address.
Parameters
Returns
Promise
<string
>
Value of the key.
Code example
Need to have available stake.
Defined in
getURL
▸ getURL(address
, urlKey?
): Promise
<string
>
This function returns the URL value for the given entity.
Parameters
Returns
Promise
<string
>
URL value for the given address if exists, and the content is valid
Code example
Defined in
set
▸ set(key
, value
, txOptions?
): Promise
<void
>
This function sets a key-value pair associated with the address that submits the transaction.
Parameters
Returns
Promise
<void
>
Returns void if successful. Throws error if any.
Code example
Need to have available stake.
Defined in
setBulk
▸ setBulk(keys
, values
, txOptions?
): Promise
<void
>
This function sets key-value pairs in bulk associated with the address that submits the transaction.
Parameters
Returns
Promise
<void
>
Returns void if successful. Throws error if any.
Code example
Need to have available stake.
Defined in
setURL
▸ setURL(url
, urlKey?
, txOptions?
): Promise
<void
>
This function sets a URL value for the address that submits the transaction.
Parameters
Returns
Promise
<void
>
Returns void if successful. Throws error if any.
Code example
Defined in
build
▸ build(signerOrProvider
): Promise
<KVStoreClient
>
Creates an instance of KVStoreClient from a Signer or Provider.
Parameters
Returns
Promise
<KVStoreClient
>
An instance of KVStoreClient
Throws
Thrown if the provider does not exist for the provided Signer
Throws
Thrown if the network's chainId is not supported
Defined in
Last updated