# @klever/sdk-web

> Kleverchain SDK integration with JS for browser

Latest version **1.5.1** (published 2025-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @klever/sdk-web
pnpm add @klever/sdk-web
yarn add @klever/sdk-web
bun add @klever/sdk-web
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.1 |
| Published | 2025-06-16 |
| First published | 2023-04-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 157.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Klever |
| Maintainers | samufacanha2, yurilozorio, yurimiguel, devsecops-kleverio, klever_nicollas |

## Links

- npm: https://www.npmjs.com/package/@klever/sdk-web
- Repository: https://github.com/klever-io/kleverchain-sdk-web
- Homepage: https://github.com/klever-io/kleverchain-sdk-web#readme
- Issues: https://github.com/klever-io/kleverchain-sdk-web/issues
- npm.io page: https://npm.io/package/@klever/sdk-web

## Dependencies (2)

- [bech32](https://npm.io/package/bech32.md) ^2.0.0
- [@klever/kleverweb](https://npm.io/package/@klever/kleverweb.md) ^1.4.0

## Recent versions

- 1.5.1 (latest) — 2025-06-16
- 1.5.0 — 2025-06-02
- 1.4.3 — 2025-04-28
- 1.4.2 — 2025-03-03
- 1.4.1 — 2025-02-12
- 1.4.0 — 2024-11-12
- 1.3.3 — 2024-09-16
- 1.3.2 — 2024-08-14
- 1.3.0 — 2024-06-27
- 1.2.3 — 2024-05-24
- 1.2.2 — 2024-04-11
- 1.2.1 — 2024-04-08
- 1.2.0 — 2024-03-06
- 1.1.7 — 2024-03-04
- 1.1.6-beta.0 — 2024-03-04
- … 14 more at https://npm.io/package/@klever/sdk-web/versions

## README

## [![npm version](https://badge.fury.io/js/@klever%2Fsdk-web.svg)](https://badge.fury.io/js/@klever%2Fsdk-web)

# Kleverchain SDK library

The SDK module provides a quick and easy interface to make contract calls to the blockchain via the Klever wallet's injected methods.

For a more detailed and organized documentation, please visit the official [Kleverchain SDK Documentation](https://klever.gitbook.io/kleverchain-sdk/) website.

### Installation

```bash
$ npm install @klever/sdk-web
```

or

```bash
$ yarn add @klever/sdk-web
```

<br/>

# Basic usage

```ts
import { web, ITransfer, TransactionType } from "@klever/sdk-web";

const payload: ITransfer = {
  amount: 100 * 10 ** 6,
  receiver: "receiverAddress",
  kda: "KLV",
};

await web.initialize();

const unsignedTx = await web.buildTransaction([
  {
    payload,
    type: TransactionType.Transfer,
  },
]);

const signedTx = await web.signTransaction(unsignedTx);

const response = await web.broadcastTransactions([signedTx]);
```

<hr/>

<br/>

## Execute Code On Account Change

To execute code when the user changes their account, you can use the `onAccountChange` method. This method accepts a callback function that will be executed whenever the account changes.

```ts
import { web } from '@klever/sdk-web';
...
  function accountChangeCallback((accountChangeEvent) {
      if (
        web.isKleverAccount(accountChangeEvent.address, accountChangeEvent.chain)
      ) {
        console.log('Account changed:', accountChangeEvent.address);
        // You can perform any action here, such as updating the UI or fetching new data.
      } else {
        console.error('Not a Klever Account: ', accountChangeEvent.address);
      }
  });

  web.initialize({
    accountChangeCallback
  })
...
```

## Changing Network

The default network is the Kleverchain Mainnet, but if you want to use the Kleverchain Testnet or a local version of the Kleverchain, you can change the kleverWeb provider object by setting it before calling the initialize function.

```ts
import { web, IProvider } from '@klever/sdk-web';
...
  const provider:IProvider = {
      api: 'https://api.testnet.klever.org',
      node: 'https://node.testnet.klever.org'
  };

  window.kleverWeb.provider = provider;

  web.initialize();
...
```

## Transactions

All available transactions:

- `Transfer`
- `Freeze`
- `Unfreeze`
- `Delegate`
- `Undelegate`
- `Claim`
- `Withdraw`
- `CreateAsset`
- `AssetTrigger`
- `ConfigITO`
- `CreateMarketplace`
- `ConfigMarketplace`
- `Sell`
- `Buy`
- `CancelMarketOrder`
- `Proposal`
- `Vote`
- `CreateValidator`
- `ConfigValidator`
- `Unjail`
- `SetAccountName`
- `UpdateAccountPermission`

---
_Source: https://npm.io/package/@klever/sdk-web · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
