Skip to main content

Class: Bee

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

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

Instantiate with new Bee(url, options) where url is the Bee node URL and options are optional parameters.

Example​

const bee = new Bee('http://localhost:1633')

Constructors​

Constructor​

new Bee(url, options?): Bee

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

Parameters​

url​

string

URL on which is the main API of Bee node exposed

options?​

BeeOptions

Returns​

Bee

Example​

const bee = new Bee('http://localhost:1633')

Properties​

balance​

readonly balance: Balance

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

SWAP balance operations. Related to the bandwidth incentives and the chequebook.


cheque​

readonly cheque: Cheque

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

Cheque operations (last cheques and cashouts).


chequebook​

readonly chequebook: Chequebook

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

Chequebook contract operations (address, balance, deposit, withdraw).


chunk​

readonly chunk: Chunk

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

Chunk operations backed by the /chunks endpoint.


collection​

readonly collection: Collection

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

Collection (multi-file) operations backed by the /bzz endpoint.


connectivity​

readonly connectivity: Connectivity

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

Peer, topology and network connectivity operations.


data​

readonly data: Data

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

Raw data operations backed by the /bytes endpoint.


feed​

readonly feed: Feed

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

Feed operations.


file​

readonly file: File

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

Single-file operations backed by the /bzz endpoint.


grantee​

readonly grantee: Grantee

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

Grantee (access control) operations.


messaging​

readonly messaging: Messaging

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

Messaging protocols — PSS and GSOC.


network​

readonly network: "gnosis" | "sepolia"

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

Network on which the Bee node is running.

This is currently used to determine block time for postage batch time-to-live (TTL) calculations. The block time for gnosis is 5 seconds, and for sepolia it is 15 seconds.

Default​

'gnosis'

pin​

readonly pin: Pin

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

Local pinning operations.


settlement​

readonly settlement: Settlement

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

Settlement operations. Related to the bandwidth incentives and the chequebook.


signer?​

readonly optional signer: PrivateKey

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

Default signer (a private key) used for signing.

Mainly used in single-owner chunk (SOC) related operations, and consequently in feeds.

If not provided, methods such as makeFeedWriter and makeSOCWriter must be provided with a private key in their respective function calls.


soc​

readonly soc: Soc

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

Single owner chunk (SOC) reader/writer operations.


stake​

readonly stake: Stake

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

Staking operations.


stamp​

readonly stamp: Stamp

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

Low-level postage batch (stamp) operations.


status​

readonly status: Status

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

Node status, health, version and chain/reserve state operations.


storage​

readonly storage: Storage

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

Ergonomic storage operations expressed in terms of size and duration.


tag​

readonly tag: Tag

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

Tag operations for tracking upload and synchronization progress.


transaction​

readonly transaction: Transaction

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

Pending transaction operations for the Bee node's transaction queue.


url​

readonly url: string

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

Bee node API URL.

Example​

`http://localhost:1633`

wallet​

readonly wallet: Wallet

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

Node wallet operations (balances and external withdrawals).

Methods​

calculateSingleOwnerChunkAddress()​

calculateSingleOwnerChunkAddress(identifier, address): Reference

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

Calculates the address of a Single Owner Chunk based on its identifier and owner address.

Parameters​

identifier​

Identifier

address​

EthAddress

Returns​

Reference


createEnvelope()​

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

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

Creates the postage batch signature for a specific chunk address.

This is for advanced usage, where a pre-signed chunk can be uploaded through a different Bee node.

Parameters​

postageBatchId​

string | Uint8Array<ArrayBufferLike> | BatchId

reference​

string | Uint8Array<ArrayBufferLike> | Reference

requestOptions?​

BeeRequestOptions

Options for making requests, such as timeouts, custom HTTP agents, headers, etc.

Returns​

Promise<EnvelopeWithBatchId>

Example​

const envelope = await bee.createEnvelope(batchId, chunk.address)
await bee.chunk.upload(envelope, chunk)

makeContentAddressedChunk()​

makeContentAddressedChunk(rawPayload, span?): Chunk

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

Creates a Content Addressed Chunk.

To be uploaded with the uploadChunk method.

Payload size must be between 1 and 4096 bytes.

Parameters​

rawPayload​

Data to be stored in the chunk. If the data is a string, it will be converted to UTF-8 bytes.

string | Uint8Array<ArrayBufferLike> | Bytes

span?​

Optional span for the chunk. If not provided, it will be set to the length of the payload.

bigint | Span

Returns​

Chunk


makeSingleOwnerChunk()​

makeSingleOwnerChunk(address, span, payload, identifier, signer): SingleOwnerChunk

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

Creates a Single Owner Chunk.

To be uploaded with the uploadChunk method.

Identical to chaining makeContentAddressedChunk and toSingleOwnerChunk.

Payload size must be between 1 and 4096 bytes.

Parameters​

address​

Reference

Address of the Content Addressed Chunk

span​

Span

Span of the Content Addressed Chunk

payload​

Bytes

Payload of the Content Addressed Chunk

identifier​

The identifier of the chunk

string | Uint8Array<ArrayBufferLike> | Identifier

signer​

The signer interface for signing the chunk

string | Uint8Array<ArrayBufferLike> | PrivateKey

Returns​

SingleOwnerChunk


rchash()​

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

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

Gets reserve commitment hash duration seconds.

To be able to participe in the storage incentives and not get frozen, this should ideally run under 5 minutes.

This is a CPU intensice operation, as roughly 2^22 chunks are hashed in the process.

Parameters​

depth​

number

anchor1​

string

anchor2​

string

requestOptions?​

BeeRequestOptions

Options for making requests, such as timeouts, custom HTTP agents, headers, etc.

Returns​

Promise<number>

Example​

const addresses = await bee.connectivity.getNodeAddresses()
const topology = await bee.connectivity.getTopology()
const result = await bee.rchash(topology.depth, addresses.overlay.toHex(), addresses.overlay.toHex())
// result is a number of seconds

unmarshalContentAddressedChunk()​

unmarshalContentAddressedChunk(data): Chunk

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

Attempts to unmarshal arbitrary data into a Content Addressed Chunk. Throws an error if the data is not a valid CAC.

Parameters​

data​

The chunk data (span and payload)

Uint8Array<ArrayBufferLike> | Bytes

Returns​

Chunk


unmarshalSingleOwnerChunk()​

unmarshalSingleOwnerChunk(data, address): SingleOwnerChunk

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

Attempts to unmarshal arbitrary data into a Single Owner Chunk. Throws an error if the data is not a valid SOC.

Parameters​

data​

The chunk data

Uint8Array<ArrayBufferLike> | Bytes

address​

The address of the single owner chunk

string | Uint8Array<ArrayBufferLike> | Reference

Returns​

SingleOwnerChunk

a single owner chunk or throws error

💬 Get Help