⚠️ 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.
The Based Apps SDK is a TypeScript library for managing Based Applications on the SSV Network.
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
# Using npm
npm i @ssv-labs/bapps-sdk
# Using yarn
yarn add @ssv-labs/bapps-sdk
# Using pnpm
pnpm install @ssv-labs/bapps-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,
})
const receipt = await sdk.core.contracts.bapp.write
.delegateBalance({
args: {
account: '0xA4831B989972605A62141a667578d742927Cbef9',
percentage: 10,
},
})
.then((tx) => tx.wait())
// get validator balance of a given account
const validatorBalance = await sdk.api.getValidatorsBalance({
account: '0x77fc6e8b24a623725d935bc88057098d0bca6eb3',
})
console.log('response:', validatorBalance)
const strategiesWeights = await sdk.utils.getParticipantWeights({
bAppId: '0x64714cf5db177398729e37627be0fc08f43b17a6',
})
console.log('response:', strategyTokenWeights)
For detailed documentation and examples, visit our official documentation.