0.0.10 • Published 2 months ago

@ssv-labs/bapps-sdk v0.0.10

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
github
Last release
2 months ago

⚠️ Development Notice: This SDK is currently under active development and testing. It is not recommended for production use at this time. For updates and documentation, please refer to our official documentation.

Overview

The Based Apps SDK is a TypeScript library for managing Based Applications on the SSV Network.

Core Modules

The SDK consists of three main modules:

  • BasedAppManager: Register BApps, manage tokens, risk levels, created and edit strategies, delegations, deposits
  • API: Access Based Apps data, query states, and retrieve operational information
  • Utils: Helper functions for calculating Participants' Weights and other miscellaneous tasks

Installation

# Using npm
npm i @ssv-labs/bapps-sdk

# Using yarn
yarn add @ssv-labs/bapps-sdk

# Using pnpm
pnpm install @ssv-labs/bapps-sdk

Quick Start

Initialize the SDK

import { BasedAppsSDK } from "@ssv-labs/bapps-sdk";
import { createPublicClient, createWalletClient, http } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'

// Setup viem clients
const chain = chains.mainnet // or chains.holesky
const transport = http()

const publicClient = createPublicClient({
  chain,
  transport,
})

const account = privateKeyToAccount('0x...')
const walletClient = createWalletClient({
  account,
  chain,
  transport,
})

const sdk = new BasedAppsSDK({
   beaconchainUrl: 'https://example.com/beacon',
   publicClient,
   walletClient,
 })

Based App Manager Contract Call example

const receipt = await sdk.core.contracts.bapp.write.delegateBalance({
    args: {
      account: "0xA4831B989972605A62141a667578d742927Cbef9",
      percentage: 10,
    },
  }).then((tx) => tx.wait())

API Example

// get validator balance of a given account
const validatorBalance = await sdk.api.getValidatorsBalance({
    account: '0x77fc6e8b24a623725d935bc88057098d0bca6eb3',
});

console.log('response:', validatorBalance)

Utils example

const strategiesWeights = await sdk.utils.getParticipantWeights({
  bAppId: '0x64714cf5db177398729e37627be0fc08f43b17a6',
})

console.log('response:', strategyTokenWeights)

Documentation

For detailed documentation and examples, visit our official documentation.

0.0.10

2 months ago

0.0.9

2 months ago

0.0.8

3 months ago

0.0.7

3 months ago

0.0.6

3 months ago

0.0.5

4 months ago

0.0.4

4 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago