# @0xobelisk/sov-client

> Sovereign Typescript SDK

Latest version **0.2.8** (published 2024-09-05) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @0xobelisk/sov-client
pnpm add @0xobelisk/sov-client
yarn add @0xobelisk/sov-client
bun add @0xobelisk/sov-client
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.8 |
| Published | 2024-09-05 |
| First published | 2024-08-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 13 |
| Unpacked size | 477.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Obelisk Labs |
| Maintainers | vladilenaksana, web3henry |

## Links

- npm: https://www.npmjs.com/package/@0xobelisk/sov-client
- Homepage: https://www.sovereign.xyz
- npm.io page: https://npm.io/package/@0xobelisk/sov-client

## Dependencies (13)

- [bs58](https://npm.io/package/bs58.md) ^6.0.0
- [borsh](https://npm.io/package/borsh.md) ^1.0.0
- [bech32](https://npm.io/package/bech32.md) ^2.0.0
- [valibot](https://npm.io/package/valibot.md) ^0.25.0
- [gql.tada](https://npm.io/package/gql.tada.md) ^1.7.0
- [tweetnacl](https://npm.io/package/tweetnacl.md) ^1.0.3
- [@scure/base](https://npm.io/package/@scure/base.md) ^1.1.7
- [@scure/bip32](https://npm.io/package/@scure/bip32.md) ^1.3.1
- [@scure/bip39](https://npm.io/package/@scure/bip39.md) ^1.2.1
- [@noble/curves](https://npm.io/package/@noble/curves.md) ^1.1.0
- [@noble/hashes](https://npm.io/package/@noble/hashes.md) ^1.3.1
- [@suchipi/femver](https://npm.io/package/@suchipi/femver.md) ^1.0.0
- [@0xobelisk/sov-wasm](https://npm.io/package/@0xobelisk/sov-wasm.md) 0.2.8

## Recent versions

- 0.2.8 (latest) — 2024-09-05
- 0.2.7 — 2024-09-05
- 0.2.6 — 2024-09-03
- 0.2.5 — 2024-09-03
- 0.2.4 — 2024-09-02
- 0.2.3 — 2024-09-02
- 0.2.2 — 2024-09-02
- 0.2.1 — 2024-09-02
- 0.2.0 — 2024-08-30
- 0.1.9 — 2024-08-29
- 0.1.8 — 2024-08-29
- 0.1.7 — 2024-08-29
- 0.1.5 — 2024-08-26
- 0.1.4 — 2024-08-26
- 0.1.2 — 2024-08-26
- … 11 more at https://npm.io/package/@0xobelisk/sov-client/versions

## README

# @0xobelisk/sov-client

This is an early experimental client used to communicate with the sequencer

## Install (TODO: Need release to [npmjs](https://www.npmjs.com/))

```typescript
pnpm i @0xobelisk/sov-client
```

## How to use

### Account

```typescript
import {Ed25519Keypair, getFullnodeUrl, SovereignClient} from "@0xobelisk/sov-client"

const main = async () => {
	// import an Ed25519 account
	const test_private_key: Uint8Array = new Uint8Array([
		117, 251, 248, 217, 135, 70, 194, 105, 46, 80, 41, 66, 185, 56, 200, 35,
		121, 253, 9, 234, 159, 91, 96, 212, 211, 158, 135, 225, 180, 36, 104,
		253,
	]);
	const importKeypair = Ed25519Keypair.fromSecretKey(test_private_key, {
		skipValidation: true,
	});
  
	// generate a new Ed25519 account
	const keypair = new Ed25519Keypair();

	console.log(keypair.getPublicKey());
	console.log(keypair.getSecretKey());
	console.log(keypair.toAddress());

	console.log();

	// generate a new Secp256k1 account
	const ethKey = new Secp256k1Keypair();
	console.log(ethKey.getPublicKey());
	console.log(ethKey.getSecretKey());
};

main();
```

### Submit Transaction

> dev in localnet tips: don't forget start the local sov node.

```typescript
import { Ed25519Keypair, Secp256k1Keypair, SovereignClient, getFullnodeUrl } from '@0xobelisk/sov-client';

const main = async () => {
  const nodeApi = getFullnodeUrl('localnet');
  const client = new SovereignClient(nodeApi);

	// call bank.Freeze func
  	const callPayload: any = {
		bank: {
			Freeze: {
				token_id:
					'token_1rwrh8gn2py0dl4vv65twgctmlwck6esm2as9dftumcw89kqqn3nqrduss6',
			},
		},
	};

	// sign and submit tx
  	await client.signAndExecuteTransaction({
		callPayload,
		signer: keypair
	})
};

main();
```


### Call RPC 

> dev in localnet tips: don't forget start the local sov node.

```typescript
import { Ed25519Keypair, Secp256k1Keypair, SovereignClient, getFullnodeUrl } from '@0xobelisk/sov-client';

const main = async () => {
  const nodeApi = getFullnodeUrl('localnet');
  const client = new SovereignClient(nodeApi);

	const params = {
    	user_address:
    		'sov15vspj48hpttzyvxu8kzq5klhvaczcpyxn6z6k0hwpwtzs4a6wkvqwr57gc',
    	token_id:
    		'token_1zdwj8thgev2u3yyrrlekmvtsz4av4tp3m7dm5mx5peejnesga27ss0lusz',
    };
    const balance = await client.query('bank_balanceOf', params);
    console.log(balance);
};

main();
```


### Query Module State

> dev in localnet tips: don't forget start the local sov node.

```typescript
import { Ed25519Keypair, Secp256k1Keypair, SovereignClient, getFullnodeUrl } from '@0xobelisk/sov-client';

const main = async () => {
  const nodeApi = getFullnodeUrl('localnet');
  const client = new SovereignClient(nodeApi);


	const state = await client.get('/xxxx', []);
    console.log(state);
};

main();
```


## How to build `sov-client`

**Clone sov-clone repo**
```bash
git clone https://github.com/Sovereign-Labs/sov-client

cd sov-client
```


**compile sov-client**
```
pnpm i
ts-node scripts/index.ts
```

---
_Source: https://npm.io/package/@0xobelisk/sov-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
