Skip to main content

Blobber SDK Methods

In this section, we will learn about all the available Blobber methods provided by the SDK.

Prerequisites​

  1. Initialize the SDK before using wallet methods. See the Quick Start Guide for details.
  2. All methods require a wallet. Refer to createWallet for more information.
  3. All methods require a domain parameter, which is the network domain where your wallet and providers such as blobbers, sharders, miners, and validators are deployed. GoSDK will send requests to this domain.

Blobber Methods​

The blobber methods allow you to retrieve information, manage and interact with blobbers.

getBlobbers​

Gets a list of active blobbers.

Parameters​

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the blobbers
walletActiveWalletActive wallet details
stakablebooleanFlag to get only stakable blobbers

Return Type​

Promise<Blobber[]>

Example​

import { getBlobbers } from '@zerochain/sdk'

// Get all blobbers
const allBlobbers = await getBlobbers({
domain: 'mainnet.zus.network',
wallet: activeWallet,
stakable: false
})

// Get only stakable blobbers
const stakableBlobbers = await getBlobbers({
domain: 'mainnet.zus.network',
wallet: activeWallet,
stakable: true
})

getBlobberIds​

Retrieves blobber IDs for the given list of blobber URLs.

Parameters​

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the blobbers
walletActiveWalletActive Wallet details
blobberUrlsstring[]List of blobber URLs for which IDs need to be retrieved

Return Type​

Promise<string[]>

Example​

import { getBlobberIds } from '@zerochain/sdk'

const blobberIds = await getBlobberIds({
domain: 'mainnet.zus.network',
wallet: activeWallet,
blobberUrls: ['https://mainnet.zus.network/blobber01/', 'https://my-domain.com/blobber01/']
})

getAllocationBlobbers​

Retrieves a list of blobber IDs that match your allocation terms.

Parameters​

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the allocation
walletActiveWalletActive wallet details
preferredBlobberURLsstring[]List of preferred blobber URLs[]
dataShardsnumberNumber of data shards
parityShardsnumberNumber of parity shards
sizenumberSize of the allocation in bytes
minReadPricenumberMinimum read price
maxReadPricenumberMaximum read price
minWritePricenumberMinimum write price
maxWritePricenumberMaximum write price
restrictedLevelnumberSpecifies the type of blobbers to query:
- 0: Use all blobbers (both restricted and non-restricted).
- 1: Use only restricted blobbers (require permission for allocation creation).
- 2: Use only non-restricted blobbers (do not require permission for allocation creation).
forcebooleanDeprecated. For internal use only.false
note

To determine minReadPrice, maxReadPrice, minWritePrice, and maxWritePrice, use the makeSCRestAPICall SDK method to call the /storage-config endpoint of the sharder smart contract.

warning

The force parameter is deprecated and should not be used.

Return Type​

Promise<string[]>

Example​

import { getAllocationBlobbers } from '@zerochain/sdk'

const blobberIds = await getAllocationBlobbers({
domain: 'mainnet.zus.network',
wallet: activeWallet,
preferredBlobberURLs: ['https://mainnet.zus.network/blobber01/', 'https://my-domain.com/blobber01/'],
dataShards: 4,
parityShards: 2,
size: 2147483648, // 2 GB
minReadPrice: 0,
maxReadPrice: 100,
minWritePrice: 0.001,
maxWritePrice: 100,
restrictedLevel: 0
})

updateBlobberSettings​

Updates the settings for a blobber.

Parameters​

NameTypeDescriptionDefault value
domainNetworkDomainNetwork domain for the blobber
walletActiveWalletActive Wallet details
blobberSettingsBlobberThe new settings to apply to the blobber

Return Type​

Promise<Transaction>

Example​

import { updateBlobberSettings } from '@zerochain/sdk'

const updatedBlobber = await updateBlobberSettings({
domain: 'mainnet.zus.network',
wallet: activeWallet,
blobberSettings: {
...blobberData,
is_restricted: isBlobberRestricted,
stake_pool_settings: {
...blobberData.stake_pool_settings,
num_delegates: noOfDelegates,
service_charge: serviceCharge / 100,
},
terms: {
...blobberData.terms,
write_price: zcnToSasToken(writePrice),
},
}
})

getContainers​

Returns all the running containers in a given domain exposing the {requestDomain}/endpoints/{endpointID}/docker/containers/json endpoint. The request is authenticated using the provided username and password by first creating an auth token and then issuing the request.

Parameters​

NameTypeDescriptionDefault value
walletActiveWalletActive Wallet details
domainNetworkDomainNetwork domain for the request
usernamestringUsername to authenticate with
passwordstringPassword to authenticate with
requestDomainstringDomain to issue the request to

Return Type​

List of containers

Promise<Array<Record<string, any>>>

Example​

import { getContainers } from '@zerochain/sdk'

const containers = await getContainers({
wallet: activeWallet,
domain: 'mainnet.zus.network',
username: 'admin',
password: 'password123',
requestDomain: 'https://my-chimney-domain.com'
})

searchContainer​

Searches for a container with a given name in a given domain exposing the {requestDomain}/endpoints/{endpointID}/docker/containers/json endpoint. The request is authenticated using the provided username and password by first creating an auth token and then issuing the request. The response is a list of containers in JSON format that match the given name.

Parameters​

NameTypeDescriptionDefault value
walletActiveWalletActive Wallet details
domainNetworkDomainNetwork domain for the request
usernamestringUsername to authenticate with
passwordstringPassword to authenticate with
requestDomainstringDomain to issue the request to
namestringName of the container to search for

Return Type​

List of containers matching the name

Promise<Array<Record<string, any>>>

Example​

import { searchContainer } from '@zerochain/sdk'

const containers = await searchContainer({
wallet: activeWallet,
domain: 'mainnet.zus.network',
username: 'admin',
password: 'password123',
requestDomain: 'https://my-chimney-domain.com',
name: 'my-container'
})

updateContainer​

Updates the given container ID with a new image ID in a given domain. The domain should expose the docker API endpoints under {requestDomain}/endpoints/{endpointID}/docker. The request should be authenticated with the given username and password, by first creating an auth token then issuing the request.

Parameters​

NameTypeDescriptionDefault value
walletActiveWalletActive Wallet details
domainNetworkDomainNetwork domain for the request
usernamestringUsername to authenticate with
passwordstringPassword to authenticate with
requestDomainstringDomain to issue the request to
containerIDstringContainer ID to update
newImageIDstringNew Image ID to update the container with

Return Type​

A map containing the response from the update operation.

Promise<Record<string, any>>

Example​

import { updateContainer } from '@zerochain/sdk'

const response = await updateContainer({
wallet: activeWallet,
domain: 'mainnet.zus.network',
username: 'admin',
password: 'password123',
requestDomain: 'https://my-chimney-domain.com',
containerID: 'my-container',
newImageID: 'new-image-id'
})