Skip to main content

Class: Bee

Defined in: bee-js/src/bee.ts:142

The main component that abstracts operations available on the main Bee API.

Not all methods are always available as it depends in what mode is Bee node launched in. For example gateway mode and light node mode has only limited set of endpoints enabled.

Extended by

Constructors

Constructor

new Bee(url, options?): Bee

Defined in: bee-js/src/bee.ts:168

Parameters

url

string

URL on which is the main API of Bee node exposed

options?

BeeOptions

Returns

Bee

Properties

network

readonly network: "gnosis" | "sepolia"

Defined in: bee-js/src/bee.ts:156

Network on which the Bee node is running


signer?

readonly optional signer: PrivateKey

Defined in: bee-js/src/bee.ts:151

Default Signer object used for signing operations, mainly Feeds.


url

readonly url: string

Defined in: bee-js/src/bee.ts:146

URL on which is the main API of Bee node exposed

Methods

buyStorage()

buyStorage(size, duration, options?, requestOptions?): Promise<BatchId>

Defined in: bee-js/src/bee.ts:1649

Parameters

size

Size

duration

Duration

options?

PostageBatchOptions

requestOptions?

BeeRequestOptions

Returns

Promise<BatchId>


cancelPendingTransaction()

cancelPendingTransaction(transactionHash, gasPrice?, options?): Promise<TransactionId>

Defined in: bee-js/src/bee.ts:1907

Cancel currently pending transaction

Parameters

transactionHash

string | Uint8Array<ArrayBufferLike> | TransactionId

gasPrice?

string | bigint | NumberString

options?

BeeRequestOptions

Returns

Promise<TransactionId>


cashoutLastCheque()

cashoutLastCheque(address, options?, requestOptions?): Promise<TransactionId>

Defined in: bee-js/src/bee.ts:1425

Cashout the last cheque for the peer

Parameters

address

Swarm address of peer

string | PeerAddress

options?

TransactionOptions

requestOptions?

BeeRequestOptions

Returns

Promise<TransactionId>


checkConnection()

checkConnection(options?): Promise<void>

Defined in: bee-js/src/bee.ts:1265

Ping the Bee node to see if there is a live Bee node on the given URL.

Parameters

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<void>

Throws

If connection was not successful throw error


createEnvelope()

createEnvelope(postageBatchId, reference, options?): Promise<EnvelopeWithBatchId>

Defined in: bee-js/src/bee.ts:1241

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

reference

string | Uint8Array<ArrayBufferLike> | Reference

options?

BeeRequestOptions

Returns

Promise<EnvelopeWithBatchId>


createFeedManifest()

createFeedManifest(postageBatchId, topic, owner, options?, requestOptions?): Promise<Reference>

Defined in: bee-js/src/bee.ts:1132

Create feed manifest chunk and return the reference to it.

Feed manifest chunk allows for a feed to be able to be resolved through /bzz endpoint.

Parameters

postageBatchId

Postage BatchId to be used to create the Feed Manifest

string | Uint8Array<ArrayBufferLike> | BatchId

topic

Topic in hex or bytes

string | Uint8Array<ArrayBufferLike> | Topic

owner

Owner's ethereum address in hex or bytes

string | Uint8Array<ArrayBufferLike> | EthAddress

options?

UploadOptions

Options that affects the request behavior

requestOptions?

BeeRequestOptions

Returns

Promise<Reference>

See


createGrantees()

createGrantees(postageBatchId, grantees, requestOptions?): Promise<GranteesResult>

Defined in: bee-js/src/bee.ts:345

Create a grantees list from the given array of public keys.

The grantees list can be obtained with the getGrantees method.

Parameters

postageBatchId

The ID of the postage batch.

string | Uint8Array<ArrayBufferLike> | BatchId

grantees

An array of public keys representing the grantees.

string[] | Uint8Array<ArrayBufferLike>[] | PublicKey[]

requestOptions?

BeeRequestOptions

Optional request options.

Returns

Promise<GranteesResult>

A promise that resolves to a GranteesResult object.


createPostageBatch()

createPostageBatch(amount, depth, options?, requestOptions?): Promise<BatchId>

Defined in: bee-js/src/bee.ts:1609

Creates new postage batch from the funds that the node has available in its Ethereum account.

For better understanding what each parameter means and what are the optimal values please see Bee docs - Keep your data alive / Postage stamps.

WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY

Parameters

amount

Amount that represents the value per chunk, has to be greater or equal zero.

string | bigint | NumberString

depth

number

Logarithm of the number of chunks that can be stamped with the batch.

options?

PostageBatchOptions

Options for creation of postage batch

requestOptions?

BeeRequestOptions

Returns

Promise<BatchId>

Throws

BeeArgumentError when negative amount or depth is specified

Throws

TypeError if non-integer value is passed to amount or depth

See


createTag()

createTag(options?): Promise<Tag>

Defined in: bee-js/src/bee.ts:649

Create a new Tag which is meant for tracking progres of syncing data across network.

Parameters

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<Tag>

See


deleteTag()

deleteTag(tagUid, options?): Promise<void>

Defined in: bee-js/src/bee.ts:701

Delete Tag

Parameters

tagUid

UID or tag object to be retrieved

number | Tag

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<void>

Throws

TypeError if tagUid is in not correct format

Throws

BeeResponse error if something went wrong on the Bee node side while deleting the tag.

See


depositStake()

depositStake(amount, options?, requestOptions?): Promise<TransactionId>

Defined in: bee-js/src/bee.ts:1940

Deposits given amount of BZZ token (in PLUR unit).

Be aware that staked BZZ tokens can not be withdrawn.

Parameters

amount

Amount of BZZ token (in PLUR unit) to be staked. Minimum is 100_000_000_000_000_000 PLUR (10 BZZ).

string | bigint | BZZ | NumberString

options?

TransactionOptions

requestOptions?

BeeRequestOptions

Returns

Promise<TransactionId>


depositTokens()

depositTokens(amount, gasPrice?, options?): Promise<TransactionId>

Defined in: bee-js/src/bee.ts:1446

Deposit tokens from overlay address into chequebook

Parameters

amount

Amount of tokens to deposit (must be positive integer)

string | bigint | BZZ | NumberString

gasPrice?

Gas Price in WEI for the transaction call

string | bigint | NumberString

options?

BeeRequestOptions

Returns

Promise<TransactionId>

string Hash of the transaction


diluteBatch()

diluteBatch(postageBatchId, depth, options?): Promise<BatchId>

Defined in: bee-js/src/bee.ts:1786

Dilute given Postage Batch with new depth (that has to be bigger then the original depth), which allows the Postage Batch to be used for more chunks.

For better understanding what each parameter means and what are the optimal values please see Bee docs - Keep your data alive / Postage stamps.

Parameters

postageBatchId

Batch ID

string | Uint8Array<ArrayBufferLike> | BatchId

depth

number

Amount to be added to the batch

options?

BeeRequestOptions

Request options

Returns

Promise<BatchId>

See


downloadChunk()

downloadChunk(reference, options?, requestOptions?): Promise<Uint8Array<ArrayBufferLike>>

Defined in: bee-js/src/bee.ts:321

Download chunk as a byte array

Parameters

reference

Bee chunk reference in hex string (either 64 or 128 chars long) or ENS domain.

string | Uint8Array<ArrayBufferLike> | Reference

options?

DownloadOptions

Options that affects the request behavior

requestOptions?

BeeRequestOptions

Returns

Promise<Uint8Array<ArrayBufferLike>>

Throws

TypeError if some of the input parameters is not expected type

Throws

BeeArgumentError if there is passed ENS domain with invalid unicode characters

See


downloadData()

downloadData(resource, options?, requestOptions?): Promise<Bytes>

Defined in: bee-js/src/bee.ts:243

Download data as a byte array

Parameters

resource

Swarm reference, Swarm CID, or ENS domain

string | Uint8Array<ArrayBufferLike> | Reference

options?

DownloadOptions

Options that affects the request behavior

requestOptions?

BeeRequestOptions

Returns

Promise<Bytes>

Throws

TypeError if some of the input parameters is not expected type

Throws

BeeArgumentError if there is passed ENS domain with invalid unicode characters

See


downloadFile()

downloadFile(resource, path, options?, requestOptions?): Promise<FileData<Bytes>>

Defined in: bee-js/src/bee.ts:468

Download single file.

Parameters

resource

Swarm reference, Swarm CID, or ENS domain

string | Uint8Array<ArrayBufferLike> | Reference

path

string = ''

If reference points to manifest, then this parameter defines path to the file

options?

DownloadOptions

Options that affects the request behavior

requestOptions?

BeeRequestOptions

Returns

Promise<FileData<Bytes>>

Throws

TypeError if some of the input parameters is not expected type

Throws

BeeArgumentError if there is passed ENS domain with invalid unicode characters

See


downloadReadableData()

downloadReadableData(resource, options?, requestOptions?): Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>

Defined in: bee-js/src/bee.ts:265

Download data as a Readable stream

Parameters

resource

Swarm reference, Swarm CID, or ENS domain

string | Uint8Array<ArrayBufferLike> | Reference

options?

DownloadOptions

Options that affects the request behavior

requestOptions?

BeeRequestOptions

Returns

Promise<ReadableStream<Uint8Array<ArrayBufferLike>>>

Throws

TypeError if some of the input parameters is not expected type

Throws

BeeArgumentError if there is passed ENS domain with invalid unicode characters

See


downloadReadableFile()

downloadReadableFile(reference, path, options?, requestOptions?): Promise<FileData<ReadableStream<Uint8Array<ArrayBufferLike>>>>

Defined in: bee-js/src/bee.ts:493

Download single file as a readable stream

Parameters

reference

Bee file reference in hex string (either 64 or 128 chars long), ENS domain or Swarm CID.

string | Uint8Array<ArrayBufferLike> | Reference

path

string = ''

If reference points to manifest / collections, then this parameter defines path to the file

options?

DownloadOptions

Options that affects the request behavior

requestOptions?

BeeRequestOptions

Returns

Promise<FileData<ReadableStream<Uint8Array<ArrayBufferLike>>>>

Throws

TypeError if some of the input parameters is not expected type

Throws

BeeArgumentError if there is passed ENS domain with invalid unicode characters

See


extendStorageDuration()

extendStorageDuration(postageBatchId, duration, options?): Promise<BatchId>

Defined in: bee-js/src/bee.ts:1688

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

duration

Duration

options?

BeeRequestOptions

Returns

Promise<BatchId>


extendStorageSize()

extendStorageSize(postageBatchId, size, options?): Promise<BatchId>

Defined in: bee-js/src/bee.ts:1674

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

size

Size

options?

BeeRequestOptions

Returns

Promise<BatchId>


fetchLatestFeedUpdate()

fetchLatestFeedUpdate(topic, owner, requestOptions?): Promise<FeedPayloadResult>

Defined in: bee-js/src/bee.ts:1194

Parameters

topic

string | Uint8Array<ArrayBufferLike> | Topic

owner

string | Uint8Array<ArrayBufferLike> | EthAddress

requestOptions?

BeeRequestOptions

Returns

Promise<FeedPayloadResult>


getAllBalances()

getAllBalances(options?): Promise<BalanceResponse>

Defined in: bee-js/src/bee.ts:1325

Get the balances with all known peers including prepaid services

Parameters

options?

BeeRequestOptions

Returns

Promise<BalanceResponse>


getAllGlobalPostageBatch()

getAllGlobalPostageBatch(options?): Promise<GlobalPostageBatch[]>

Defined in: bee-js/src/bee.ts:1846

Return all globally available postage batches.

Parameters

options?

BeeRequestOptions

Returns

Promise<GlobalPostageBatch[]>

Deprecated

Use getGlobalPostageBatches instead


getAllPendingTransactions()

getAllPendingTransactions(options?): Promise<TransactionInfo[]>

Defined in: bee-js/src/bee.ts:1870

Return lists of all current pending transactions that the Bee made

Parameters

options?

BeeRequestOptions

Returns

Promise<TransactionInfo[]>


getAllPins()

getAllPins(options?): Promise<Reference[]>

Defined in: bee-js/src/bee.ts:766

Get list of all locally pinned references

Parameters

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<Reference[]>

See

Bee docs - Pinning


getAllPostageBatch()

getAllPostageBatch(options?): Promise<PostageBatch[]>

Defined in: bee-js/src/bee.ts:1838

Return all postage batches that has the node available.

Parameters

options?

BeeRequestOptions

Returns

Promise<PostageBatch[]>

See

Deprecated

Use getPostageBatches instead


getAllSettlements()

getAllSettlements(options?): Promise<AllSettlements>

Defined in: bee-js/src/bee.ts:1506

Get settlements with all known peers and total amount sent or received

Parameters

options?

BeeRequestOptions

Returns

Promise<AllSettlements>


getAllTags()

getAllTags(options?, requestOptions?): Promise<Tag[]>

Defined in: bee-js/src/bee.ts:665

Fetches all tags.

The listing is limited by options.limit. So you have to iterate using options.offset to get all tags.

Parameters

options?

AllTagsOptions

Options that affects the request behavior

requestOptions?

BeeRequestOptions

Returns

Promise<Tag[]>

Throws

TypeError if limit or offset are not numbers or undefined

Throws

BeeArgumentError if limit or offset have invalid options

See


getBlocklist()

getBlocklist(options?): Promise<Peer[]>

Defined in: bee-js/src/bee.ts:1291

Parameters

options?

BeeRequestOptions

Returns

Promise<Peer[]>


getChainState()

getChainState(options?): Promise<ChainState>

Defined in: bee-js/src/bee.ts:1579

Get chain state

Parameters

options?

BeeRequestOptions

Returns

Promise<ChainState>


getChequebookAddress()

getChequebookAddress(options?): Promise<ChequebookAddressResponse>

Defined in: bee-js/src/bee.ts:1371

Get the address of the chequebook contract used.

Warning: The address is returned with 0x prefix unlike all other calls. https://github.com/ethersphere/bee/issues/1443

Parameters

options?

BeeRequestOptions

Returns

Promise<ChequebookAddressResponse>


getChequebookBalance()

getChequebookBalance(options?): Promise<ChequebookBalanceResponse>

Defined in: bee-js/src/bee.ts:1378

Get the balance of the chequebook

Parameters

options?

BeeRequestOptions

Returns

Promise<ChequebookBalanceResponse>


getDurationExtensionCost()

getDurationExtensionCost(postageBatchId, duration, options?): Promise<BZZ>

Defined in: bee-js/src/bee.ts:1736

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

duration

Duration

options?

BeeRequestOptions

Returns

Promise<BZZ>


getExtensionCost()

getExtensionCost(postageBatchId, size, duration, options?): Promise<BZZ>

Defined in: bee-js/src/bee.ts:1700

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

size

Size

duration

Duration

options?

BeeRequestOptions

Returns

Promise<BZZ>


getGlobalPostageBatches()

getGlobalPostageBatches(options?): Promise<GlobalPostageBatch[]>

Defined in: bee-js/src/bee.ts:1863

Return all globally available postage batches.

Parameters

options?

BeeRequestOptions

Returns

Promise<GlobalPostageBatch[]>


getGrantees()

getGrantees(reference, requestOptions?): Promise<GetGranteesResult>

Defined in: bee-js/src/bee.ts:363

Retrieves the grantees for a given reference.

Parameters

reference

The reference.

string | Uint8Array<ArrayBufferLike> | Reference

requestOptions?

BeeRequestOptions

Optional request options.

Returns

Promise<GetGranteesResult>

A promise that resolves to a GetGranteesResult object.


getHealth()

getHealth(options?): Promise<Health>

Defined in: bee-js/src/bee.ts:1520

Get health of node

Parameters

options?

BeeRequestOptions

Returns

Promise<Health>


getLastCashoutAction()

getLastCashoutAction(address, options?): Promise<LastCashoutActionResponse>

Defined in: bee-js/src/bee.ts:1408

Get last cashout action for the peer

Parameters

address

Swarm address of peer

string | PeerAddress

options?

BeeRequestOptions

Returns

Promise<LastCashoutActionResponse>


getLastCheques()

getLastCheques(options?): Promise<LastChequesResponse>

Defined in: bee-js/src/bee.ts:1385

Get last cheques for all peers

Parameters

options?

BeeRequestOptions

Returns

Promise<LastChequesResponse>


getLastChequesForPeer()

getLastChequesForPeer(address, options?): Promise<LastChequesForPeerResponse>

Defined in: bee-js/src/bee.ts:1394

Get last cheques for the peer

Parameters

address

Swarm address of peer

string | PeerAddress

options?

BeeRequestOptions

Returns

Promise<LastChequesForPeerResponse>


getNodeAddresses()

getNodeAddresses(options?): Promise<NodeAddresses>

Defined in: bee-js/src/bee.ts:1287

Parameters

options?

BeeRequestOptions

Returns

Promise<NodeAddresses>


getNodeInfo()

getNodeInfo(options?): Promise<NodeInfo>

Defined in: bee-js/src/bee.ts:1534

Get mode information of node

Parameters

options?

BeeRequestOptions

Returns

Promise<NodeInfo>


getPastDueConsumptionBalances()

getPastDueConsumptionBalances(options?): Promise<BalanceResponse>

Defined in: bee-js/src/bee.ts:1343

Get the past due consumption balances with all known peers

Parameters

options?

BeeRequestOptions

Returns

Promise<BalanceResponse>


getPastDueConsumptionPeerBalance()

getPastDueConsumptionPeerBalance(address, options?): Promise<PeerBalance>

Defined in: bee-js/src/bee.ts:1352

Get the past due consumption balance with a specific peer

Parameters

address

Swarm address of peer

string | PeerAddress

options?

BeeRequestOptions

Returns

Promise<PeerBalance>


getPeerBalance()

getPeerBalance(address, options?): Promise<PeerBalance>

Defined in: bee-js/src/bee.ts:1334

Get the balances with a specific peer including prepaid services

Parameters

address

Swarm address of peer

string | PeerAddress

options?

BeeRequestOptions

Returns

Promise<PeerBalance>


getPeers()

getPeers(options?): Promise<Peer[]>

Defined in: bee-js/src/bee.ts:1298

Get list of peers for this node

Parameters

options?

BeeRequestOptions

Returns

Promise<Peer[]>


getPendingTransaction()

getPendingTransaction(transactionHash, options?): Promise<TransactionInfo>

Defined in: bee-js/src/bee.ts:1878

Return transaction information for specific transaction

Parameters

transactionHash

string | Uint8Array<ArrayBufferLike> | TransactionId

options?

BeeRequestOptions

Returns

Promise<TransactionInfo>


getPin()

getPin(reference, options?): Promise<Pin>

Defined in: bee-js/src/bee.ts:780

Get pinning status of chunk with given reference

Parameters

reference

Bee data reference in hex string (either 64 or 128 chars long) or ENS domain.

string | Uint8Array<ArrayBufferLike> | Reference

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<Pin>

Throws

TypeError if some of the input parameters is not expected type

Throws

BeeArgumentError if there is passed ENS domain with invalid unicode characters

See

Bee docs - Pinning


getPostageBatch()

getPostageBatch(postageBatchId, options?): Promise<PostageBatch>

Defined in: bee-js/src/bee.ts:1805

Return details for specific postage batch.

Parameters

postageBatchId

Batch ID

string | Uint8Array<ArrayBufferLike> | BatchId

options?

BeeRequestOptions

Returns

Promise<PostageBatch>

See


getPostageBatchBuckets()

getPostageBatchBuckets(postageBatchId, options?): Promise<PostageBatchBuckets>

Defined in: bee-js/src/bee.ts:1822

Return detailed information related to buckets for specific postage batch.

Parameters

postageBatchId

Batch ID

string | Uint8Array<ArrayBufferLike> | BatchId

options?

BeeRequestOptions

Returns

Promise<PostageBatchBuckets>

See


getPostageBatches()

getPostageBatches(options?): Promise<PostageBatch[]>

Defined in: bee-js/src/bee.ts:1856

Return all postage batches that belong to the node.

Parameters

options?

BeeRequestOptions

Returns

Promise<PostageBatch[]>

See


getReadiness()

getReadiness(options?): Promise<Readiness>

Defined in: bee-js/src/bee.ts:1527

Get readiness of node

Parameters

options?

BeeRequestOptions

Returns

Promise<Readiness>


getRedistributionState()

getRedistributionState(options?): Promise<RedistributionState>

Defined in: bee-js/src/bee.ts:1960

Get current status of node in redistribution game

Parameters

options?

BeeRequestOptions

Returns

Promise<RedistributionState>


getRequestOptionsForCall()

protected getRequestOptionsForCall(options?): BeeRequestOptions

Defined in: bee-js/src/bee.ts:1983

Parameters

options?

BeeRequestOptions

Returns

BeeRequestOptions


getReserveState()

getReserveState(options?): Promise<ReserveState>

Defined in: bee-js/src/bee.ts:1572

Get reserve state

Parameters

options?

BeeRequestOptions

Returns

Promise<ReserveState>


getSettlements()

getSettlements(address, options?): Promise<Settlements>

Defined in: bee-js/src/bee.ts:1497

Get amount of sent and received from settlements with a peer

Parameters

address

Swarm address of peer

string | PeerAddress

options?

BeeRequestOptions

Returns

Promise<Settlements>


getSizeExtensionCost()

getSizeExtensionCost(postageBatchId, size, options?): Promise<BZZ>

Defined in: bee-js/src/bee.ts:1717

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

size

Size

options?

BeeRequestOptions

Returns

Promise<BZZ>


getStake()

getStake(options?): Promise<BZZ>

Defined in: bee-js/src/bee.ts:1928

Gets the staked amount of BZZ (in PLUR unit) as number string.

Parameters

options?

BeeRequestOptions

Returns

Promise<BZZ>


getStatus()

getStatus(options?): Promise<DebugStatus>

Defined in: bee-js/src/bee.ts:1513

Get status of node

Parameters

options?

BeeRequestOptions

Returns

Promise<DebugStatus>


getStorageCost()

getStorageCost(size, duration, options?): Promise<BZZ>

Defined in: bee-js/src/bee.ts:1666

Parameters

size

Size

duration

Duration

options?

BeeRequestOptions

Returns

Promise<BZZ>


getTopology()

getTopology(options?): Promise<Topology>

Defined in: bee-js/src/bee.ts:1308

Parameters

options?

BeeRequestOptions

Returns

Promise<Topology>


getVersions()

getVersions(options?): Promise<BeeVersions>

Defined in: bee-js/src/bee.ts:1565

Returns object with all versions specified by the connected Bee node (properties prefixed with bee*) and versions that bee-js supports (properties prefixed with supported*).

Parameters

options?

BeeRequestOptions

Returns

Promise<BeeVersions>


getWalletBalance()

getWalletBalance(options?): Promise<WalletBalance>

Defined in: bee-js/src/bee.ts:1588

Get wallet balances for xDai and BZZ of the Bee node

Parameters

options?

BeeRequestOptions

Returns

Promise<WalletBalance>


gsocMine()

gsocMine(targetOverlay, identifier, proximity): PrivateKey

Defined in: bee-js/src/bee.ts:1034

Parameters

targetOverlay

string | Uint8Array<ArrayBufferLike> | PeerAddress

identifier

string | Uint8Array<ArrayBufferLike> | Identifier

proximity

number = 12

Returns

PrivateKey


gsocSend()

gsocSend(postageBatchId, signer, identifier, data, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/bee.ts:1054

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

signer

string | Uint8Array<ArrayBufferLike> | PrivateKey

identifier

string | Uint8Array<ArrayBufferLike> | Identifier

data

string | Uint8Array<ArrayBufferLike>

options?

UploadOptions

requestOptions?

BeeRequestOptions

Returns

Promise<UploadResult>


gsocSubscribe()

gsocSubscribe(address, identifier, handler): GsocSubscription

Defined in: bee-js/src/bee.ts:1072

Parameters

address

string | Uint8Array<ArrayBufferLike> | EthAddress

identifier

string | Uint8Array<ArrayBufferLike> | Identifier

handler

GsocMessageHandler

Returns

GsocSubscription


hashDirectory()

hashDirectory(dir): Promise<Reference>

Defined in: bee-js/src/bee.ts:541

Parameters

dir

string

Returns

Promise<Reference>


isConnected()

isConnected(options?): Promise<boolean>

Defined in: bee-js/src/bee.ts:1275

Ping the Bee node to see if there is a live Bee node on the given URL.

Parameters

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<boolean>

true if successful, false on error


isFeedRetrievable()

isFeedRetrievable(owner, topic, index?, options?, requestOptions?): Promise<boolean>

Defined in: bee-js/src/bee.ts:842

Functions that validates if feed is retrievable in the network.

If no index is passed then it check for "latest" update, which is a weaker guarantee as nobody can be really sure what is the "latest" update.

If index is passed then it validates all previous sequence index chunks if they are available as they are required to correctly resolve the feed upto the given index update.

Parameters

owner

string | Uint8Array<ArrayBufferLike> | EthAddress

topic

string | Uint8Array<ArrayBufferLike> | Topic

index?

FeedIndex

options?

DownloadOptions

requestOptions?

BeeRequestOptions

Returns

Promise<boolean>


isReferenceRetrievable()

isReferenceRetrievable(reference, options?): Promise<boolean>

Defined in: bee-js/src/bee.ts:818

Checks if content specified by reference is retrievable from the network.

Parameters

reference

Bee data reference to be checked in hex string (either 64 or 128 chars long) or ENS domain.

string | Uint8Array<ArrayBufferLike> | Reference

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<boolean>

Throws

TypeError if some of the input parameters is not expected type

Throws

BeeArgumentError if there is passed ENS domain with invalid unicode characters

See

Bee API reference - GET /stewardship


isSupportedApiVersion()

isSupportedApiVersion(options?): Promise<boolean>

Defined in: bee-js/src/bee.ts:1555

Connects to a node and checks if its Main API version matches with the one that bee-js supports.

This should be the main way how to check compatibility for your app and Bee node.

Parameters

options?

BeeRequestOptions

Returns

Promise<boolean>


isSupportedExactVersion()

isSupportedExactVersion(options?): Promise<boolean>

Defined in: bee-js/src/bee.ts:1543

Connects to a node and checks if its version matches with the one that bee-js supports.

Parameters

options?

BeeRequestOptions

Returns

Promise<boolean>


makeFeedReader()

makeFeedReader(topic, owner, options?): FeedReader

Defined in: bee-js/src/bee.ts:1159

Make a new feed reader for downloading feed updates.

Parameters

topic

Topic in hex or bytes

string | Uint8Array<ArrayBufferLike> | Topic

owner

Owner's ethereum address in hex or bytes

string | Uint8Array<ArrayBufferLike> | EthAddress

options?

BeeRequestOptions

Options that affects the request behavior

Returns

FeedReader

See

Bee docs - Feeds


makeFeedWriter()

makeFeedWriter(topic, signer?, options?): FeedWriter

Defined in: bee-js/src/bee.ts:1179

Make a new feed writer for updating feeds

Parameters

topic

Topic in hex or bytes

string | Uint8Array<ArrayBufferLike> | Topic

signer?

The signer's private key or a Signer instance that can sign data

string | Uint8Array<ArrayBufferLike> | PrivateKey

options?

BeeRequestOptions

Options that affects the request behavior

Returns

FeedWriter

See

Bee docs - Feeds


makeSOCReader()

makeSOCReader(ownerAddress, options?): SOCReader

Defined in: bee-js/src/bee.ts:1212

Returns an object for reading single owner chunks

Parameters

ownerAddress

The ethereum address of the owner

string | Uint8Array<ArrayBufferLike> | EthAddress

options?

BeeRequestOptions

Options that affects the request behavior

Returns

SOCReader

See

Bee docs - Chunk Types


makeSOCWriter()

makeSOCWriter(signer?, options?): SOCWriter

Defined in: bee-js/src/bee.ts:1228

Returns an object for reading and writing single owner chunks

Parameters

signer?

The signer's private key or a Signer instance that can sign data

string | Uint8Array<ArrayBufferLike> | PrivateKey

options?

BeeRequestOptions

Options that affects the request behavior

Returns

SOCWriter

See

Bee docs - Chunk Types


patchGrantees()

patchGrantees(postageBatchId, reference, history, grantees, requestOptions?): Promise<GranteesResult>

Defined in: bee-js/src/bee.ts:382

Updates the grantees of a specific reference and history.

Parameters

postageBatchId

The ID of the postage batch.

string | Uint8Array<ArrayBufferLike> | BatchId

reference

The reference.

string | Uint8Array<ArrayBufferLike> | Reference

history

The history.

string | Uint8Array<ArrayBufferLike> | Reference

grantees

The grantees.

add?

string[] | Uint8Array<ArrayBufferLike>[] | PublicKey[]

revoke?

string[] | Uint8Array<ArrayBufferLike>[] | PublicKey[]

requestOptions?

BeeRequestOptions

Optional request options.

Returns

Promise<GranteesResult>

A Promise that resolves to to a GranteesResult object.


pin()

pin(reference, options?): Promise<void>

Defined in: bee-js/src/bee.ts:739

Pin local data with given reference

Parameters

reference

Data reference

string | Uint8Array<ArrayBufferLike> | Reference

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<void>

Throws

TypeError if reference is in not correct format

See

Bee docs - Pinning


pingPeer()

pingPeer(peer, options?): Promise<PingResponse>

Defined in: bee-js/src/bee.ts:1312

Parameters

peer

string | PeerAddress

options?

BeeRequestOptions

Returns

Promise<PingResponse>


probeData()

probeData(reference, options?): Promise<ReferenceInformation>

Defined in: bee-js/src/bee.ts:224

Requests content length for a /bytes reference

Parameters

reference

string | Uint8Array<ArrayBufferLike> | Reference

options?

BeeRequestOptions

Returns

Promise<ReferenceInformation>

See

Bee API reference - HEAD /bytes/


pssReceive()

pssReceive(topic, timeoutMsec): Promise<Bytes>

Defined in: bee-js/src/bee.ts:1005

Receive message with Postal Service for Swarm

Because sending a PSS message is slow and CPU intensive, it is not supposed to be used for general messaging but most likely for setting up an encrypted communication channel by sending an one-off message.

This is a helper function to wait for exactly one message to arrive and then cancel the subscription. Additionally a timeout can be provided for the message to arrive or else an error will be thrown.

Warning! If connected Bee node is a light node, then he will never receive any message! This is because light nodes does not fully participate in the data exchange in Swarm network and hence the message won't arrive to them.

Parameters

topic

Topic

Topic name

timeoutMsec

number = 0

Timeout in milliseconds

Returns

Promise<Bytes>

Message in byte array

See


pssSend()

pssSend(postageBatchId, topic, target, data, recipient?, options?): Promise<void>

Defined in: bee-js/src/bee.ts:904

Send data to recipient or target with Postal Service for Swarm.

Because sending a PSS message is slow and CPU intensive, it is not supposed to be used for general messaging but most likely for setting up an encrypted communication channel by sending an one-off message.

Warning! If the recipient Bee node is a light node, then he will never receive the message! This is because light nodes does not fully participate in the data exchange in Swarm network and hence the message won't arrive to them.

Parameters

postageBatchId

Postage BatchId that will be assigned to sent message

string | Uint8Array<ArrayBufferLike> | BatchId

topic

Topic

Topic name

target

string

Target message address prefix. Has a limit on length. Recommend to use Utils.Pss.makeMaxTarget() to get the most specific target that Bee node will accept.

data

Message to be sent

string | Uint8Array<ArrayBufferLike>

recipient?

Recipient public key

string | PublicKey

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<void>

Throws

TypeError if data, batchId, target or recipient are in invalid format

See


pssSubscribe()

pssSubscribe(topic, handler): PssSubscription

Defined in: bee-js/src/bee.ts:938

Subscribe to messages for given topic with Postal Service for Swarm

Warning! If connected Bee node is a light node, then he will never receive any message! This is because light nodes does not fully participate in the data exchange in Swarm network and hence the message won't arrive to them.

Parameters

topic

Topic

Topic name

handler

PssMessageHandler

Message handler interface

Returns

PssSubscription

Subscription to a given topic

See


rchash()

rchash(depth, anchor1, anchor2, options?): Promise<number>

Defined in: bee-js/src/bee.ts:1255

Get reserve commitment hash duration seconds

Parameters

depth

number

anchor1

string

anchor2

string

options?

BeeRequestOptions

Returns

Promise<number>


rebroadcastPendingTransaction()

rebroadcastPendingTransaction(transactionHash, options?): Promise<TransactionId>

Defined in: bee-js/src/bee.ts:1893

Rebroadcast already created transaction. This is mainly needed when your transaction fall off mempool from other reason is not incorporated into block.

Parameters

transactionHash

string | Uint8Array<ArrayBufferLike> | TransactionId

options?

BeeRequestOptions

Returns

Promise<TransactionId>


removePeer()

removePeer(peer, options?): Promise<RemovePeerResponse>

Defined in: bee-js/src/bee.ts:1302

Parameters

peer

string | PeerAddress

options?

BeeRequestOptions

Returns

Promise<RemovePeerResponse>


retrieveTag()

retrieveTag(tagUid, options?): Promise<Tag>

Defined in: bee-js/src/bee.ts:684

Retrieve tag information from Bee node

Parameters

tagUid

UID or tag object to be retrieved

number | Tag

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<Tag>

Throws

TypeError if tagUid is in not correct format

See


reuploadPinnedData()

reuploadPinnedData(postageBatchId, reference, options?): Promise<void>

Defined in: bee-js/src/bee.ts:797

Instructs the Bee node to reupload a locally pinned data into the network.

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

reference

Bee data reference to be re-uploaded in hex string (either 64 or 128 chars long) or ENS domain.

string | Uint8Array<ArrayBufferLike> | Reference

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<void>

Throws

BeeArgumentError if the reference is not locally pinned

Throws

TypeError if some of the input parameters is not expected type

Throws

BeeArgumentError if there is passed ENS domain with invalid unicode characters

See

Bee API reference - PUT /stewardship


streamDirectory()

streamDirectory(postageBatchId, dir, onUploadProgress?, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/bee.ts:545

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

dir

string

onUploadProgress?

(progress) => void

options?

UploadOptions

requestOptions?

BeeRequestOptions

Returns

Promise<UploadResult>


streamFiles()

streamFiles(postageBatchId, files, onUploadProgress?, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/bee.ts:564

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

files

File[] | FileList

onUploadProgress?

(progress) => void

options?

UploadOptions

requestOptions?

BeeRequestOptions

Returns

Promise<UploadResult>


topUpBatch()

topUpBatch(postageBatchId, amount, options?): Promise<BatchId>

Defined in: bee-js/src/bee.ts:1761

Topup a fresh amount of BZZ to given Postage Batch.

For better understanding what each parameter means and what are the optimal values please see Bee docs - Keep your data alive / Postage stamps.

Parameters

postageBatchId

Batch ID

string | Uint8Array<ArrayBufferLike> | BatchId

amount

Amount to be added to the batch

string | bigint | NumberString

options?

BeeRequestOptions

Request options

Returns

Promise<BatchId>

See


unpin()

unpin(reference, options?): Promise<void>

Defined in: bee-js/src/bee.ts:754

Unpin local data with given reference

Parameters

reference

Data reference

string | Uint8Array<ArrayBufferLike> | Reference

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<void>

Throws

TypeError if reference is in not correct format

See

Bee docs - Pinning


updateTag()

updateTag(tagUid, reference, options?): Promise<void>

Defined in: bee-js/src/bee.ts:722

Update tag's total chunks count.

This is important if you are uploading individual chunks with a tag. Then upon finishing the final root chunk, you can use this method to update the total chunks count for the tag.

Parameters

tagUid

UID or tag object to be retrieved

number | Tag

reference

The root reference that contains all the chunks to be counted

string | Reference

options?

BeeRequestOptions

Options that affects the request behavior

Returns

Promise<void>

Throws

TypeError if tagUid is in not correct format

Throws

BeeResponse error if something went wrong on the Bee node side while deleting the tag.

See


uploadChunk()

uploadChunk(stamp, data, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/bee.ts:288

Upload chunk to a Bee node

Parameters

stamp

string | Uint8Array<ArrayBufferLike> | BatchId | EnvelopeWithBatchId

data

Raw chunk to be uploaded

Uint8Array<ArrayBufferLike> | Chunk

options?

UploadOptions

Additional options like tag, encryption, pinning, content-type and request options

requestOptions?

BeeRequestOptions

Returns

Promise<UploadResult>

reference is a content hash of the data

See


uploadCollection()

uploadCollection(postageBatchId, collection, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/bee.ts:593

Upload Collection that you can assembly yourself.

The returned UploadResult.tag might be undefined if called in CORS-enabled environment. This will be fixed upon next Bee release. https://github.com/ethersphere/bee-js/issues/406

Parameters

postageBatchId

string | Uint8Array<ArrayBufferLike> | BatchId

collection

Collection

options?

CollectionUploadOptions

Collections and request options

requestOptions?

BeeRequestOptions

Returns

Promise<UploadResult>


uploadData()

uploadData(postageBatchId, data, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/bee.ts:203

Upload data to a Bee node

Parameters

postageBatchId

Postage BatchId to be used to upload the data with

string | Uint8Array<ArrayBufferLike> | BatchId

data

Data to be uploaded

string | Uint8Array<ArrayBufferLike>

options?

RedundantUploadOptions

Additional options like tag, encryption, pinning, content-type and request options

requestOptions?

BeeRequestOptions

Returns

Promise<UploadResult>

reference is a content hash of the data

See


uploadFile()

uploadFile(postageBatchId, data, name?, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/bee.ts:420

Upload single file to a Bee node.

Parameters

postageBatchId

Postage BatchId to be used to upload the data with

string | Uint8Array<ArrayBufferLike> | BatchId

data

Data or file to be uploaded

string | Uint8Array<ArrayBufferLike> | File | Readable

name?

string

Optional name of the uploaded file

options?

FileUploadOptions

Additional options like tag, encryption, pinning, content-type and request options

requestOptions?

BeeRequestOptions

Returns

Promise<UploadResult>

reference is a content hash of the file

See


uploadFiles()

uploadFiles(postageBatchId, fileList, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/bee.ts:524

Upload collection of files to a Bee node

Uses the FileList API from the browser.

The returned UploadResult.tag might be undefined if called in CORS-enabled environment. This will be fixed upon next Bee release. https://github.com/ethersphere/bee-js/issues/406

Parameters

postageBatchId

Postage BatchId to be used to upload the data with

string | Uint8Array<ArrayBufferLike> | BatchId

fileList

list of files to be uploaded

File[] | FileList

options?

CollectionUploadOptions

Additional options like tag, encryption, pinning and request options

requestOptions?

BeeRequestOptions

Returns

Promise<UploadResult>

See


uploadFilesFromDirectory()

uploadFilesFromDirectory(postageBatchId, dir, options?, requestOptions?): Promise<UploadResult>

Defined in: bee-js/src/bee.ts:625

Upload collection of files.

Available only in Node.js as it uses the fs module.

The returned UploadResult.tag might be undefined if called in CORS-enabled environment. This will be fixed upon next Bee release. https://github.com/ethersphere/bee-js/issues/406

Parameters

postageBatchId

Postage BatchId to be used to upload the data with

string | Uint8Array<ArrayBufferLike> | BatchId

dir

string

the path of the files to be uploaded

options?

CollectionUploadOptions

Additional options like tag, encryption, pinning and request options

requestOptions?

BeeRequestOptions

Returns

Promise<UploadResult>

See


withdrawTokens()

withdrawTokens(amount, gasPrice?, options?): Promise<TransactionId>

Defined in: bee-js/src/bee.ts:1470

Withdraw tokens from the chequebook to the overlay address

Parameters

amount

Amount of tokens to withdraw (must be positive integer)

string | bigint | BZZ | NumberString

gasPrice?

Gas Price in WEI for the transaction call

string | bigint | NumberString

options?

BeeRequestOptions

Returns

Promise<TransactionId>

string Hash of the transaction

💬 Get Help