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

@kyvejs/sdk

v1.3.3

Published

<div align="center"> <h1>@kyvejs/sdk</h1> </div>

Downloads

2,740

Readme

banner

@kyvejs/sdk is a JavaScript library for interacting with the Kyve network blockchain.

Installation

npm

npm install @kyvejs/sdk

yarn

yarn add @kyvejs/sdk

Usage example

    const sdk = new KyveSDK('korellia');
    const client = await sdk.fromMnemonic(mnemonic);
    const transferTx= await client.kyve.base.v1beta1.transfer('kyve1qcual...', '1000000000');
    const receipt = await transferTxPromise.execute()

Full documentation

Table of contents

Configuring an sdk

Instantiate the sdk with the network name. network name can be one of the following:

  • korellia
  • alpha
  • beta
  • local
    const sdk = new KyveSDK('korellia');

Sdk instance can be configured with a network object.

    const network = {
        rpc: "https://rpc.korellia.kyve.network",
        rest: "https://api.korellia.kyve.network",
        chainId: "korellia-2",
        chainName: "Korellia",
   }
    const sdk = new KyveSDK(network);

Initiate client

To initiate a transaction, you need to create a client instance.

    const sdk = new KyveSDK('korellia');
    const client = await sdk.fromMnemonic(mnemonic);

Client instance can be created from a mnemonic or a private key.

    const clientMnenonic = await sdk.fromMnemonic(mnemonic);
    const clientPrivateKey = await sdk.fromPrivateKey(privateKey);

For frontend applications, you can use the following method to create a client instance.

@kyve/sdk has native supports for following cosmos wallets:

  • Keplr
  • Cosmostation
    const keplrClient = await sdk.fromKeplr();
    const cosmostationClient = await sdk.fromCosmostation();

Transactions

Kyve transactions

All kyve transactions can be accessible with kyve property

    const transferTx = await client.kyve.base.v1beta1.transfer('kyve1qcual...', '1000000000');

We are highly recommend to use typescript for better intellisense and type safety.

Pending transactions

Each transaction returns a pending transaction. It's a not executed transaction. It's helpful because you can get the transaction hash before executed.

    const transferTxPending = await client.kyve.base.v1beta1.transfer('kyve1qcual...', '1000000000');
    transferTxPending.txHash // returns transaction hash
    const receipt = await transferTxPending.execute();

Cosmos transactions

@kyve/sdk is a wrapper around Cosmjs, you can access Cosmjs SigningStargateClient instance with nativeClient property.

    const tx = await client.nativeClient.signAndBroadcast(
      wallet.address,
      [msg],
      fee,
      memo
    );

Transactions All

Each transaction returns an incomplete transaction. It gives the ability to execute several messages in one transaction

const multiTransferTxSignedPending = await sdkInstance.kyve.base.v1beta1.multiTransfer([
        'kyve1qcual...',
        'kyve1pfs...'
    ], '1000000000');
    const transferTxSignedPending = await sdkInstance.kyve.base.v1beta1.transfer('kyve1qcua....', '1000000000');
    // combine several messages to one
    const txsAllResultSignedPending = await sdkInstance.kyve.base.v1beta1.txsAll([multiTransferTxSignedPending, transferTxSignedPending]);
    const receipt = await txsAllResultPromise.execute();

You can use txsAll with unsigned pending transactions too.

    const transferTxUnsignedPending1 = sdkInstance.kyve.base.v1beta1.transfer('kyve1qcua....', '1000000000');
    // when you call `await` the transaction will be signed by sdk.
    const transferTxSignedPending2 = await sdkInstance.kyve.base.v1beta1.transfer('kyve1qcua....', '1000000000');
    const txsAllResultSignedPending = await sdkInstance.kyve.base.v1beta1.txsAll([transferTxUnsignedPending1, transferTxSignedPending2]);
    const receipt = await txsAllResultPromise.execute();

Any transaction can be added to the txsAll method. Also, you can pass to txsAll result of another txsAll method.

    const txsAllResultPromise = await sdkInstance.kyve.base.v1beta1.txsAll([await sdkInstance.kyve.base.v1beta1.txsAll([trx1, trx2]), transferTxPending]);
    const receipt = await txsAllResultPromise.execute();

The approach is same like you work with JavaScript Promise object and Promise.all method.

Queries

To interact with the Kyve blockchain rest api, you can use lcdClient.

    const query = await sdk.createLCDClient();
    const pools = query.kyve.query.v1beta1.pools();

We are highly recommend to use typescript for better intellisense and type safety.