
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
@kyvejs/sdk
Advanced tools
@kyvejs/sdk is a JavaScript library for interacting with the Kyve network blockchain.
npm
npm install @kyvejs/sdk
yarn
yarn add @kyvejs/sdk
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()
Instantiate the sdk with the network name. network name can be one of the following:
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",
chainName: "Korellia",
}
const sdk = new KyveSDK(network);
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:
const keplrClient = await sdk.fromKeplr();
const cosmostationClient = await sdk.fromCosmostation();
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.
Each transaction returns a transaction promise. It's a not execute transaction. It's helpful because you can get the transaction hash before executed.
const transferTxPromise = await client.kyve.base.v1beta1.transfer('kyve1qcual...', '1000000000');
transferTxPromise.txHash // returns transaction hash
const receipt = await transferTxPromise.execute();
@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
);
Each transaction returns an incomplete transaction. It gives the ability to execute several messages in one transaction
const multiTransferTxPromise = await sdkInstance.kyve.base.v1beta1.multiTransfer([
'kyve1qcual...',
'kyve1pfs...'
], '1000000000');
const transferTxPromise = await sdkInstance.kyve.base.v1beta1.transfer('kyve1qcua....', '1000000000');
// combine several messages to one
const txsAllResultPromise = await sdkInstance.txsAll([multiTransferTxPromise, transferTxPromise]);
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.txsAll([await sdkInstance.txsAll([trx1, trx2]), transferTxPromise]);
const receipt = await txsAllResultPromise.execute();
The approach is same like you work with JavaScript Promise
and Promise.all
methods.
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.
FAQs
@kyvejs/sdk
The npm package @kyvejs/sdk receives a total of 834 weekly downloads. As such, @kyvejs/sdk popularity was classified as not popular.
We found that @kyvejs/sdk demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.