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?
Returns
Bee
Example
const bee = new Bee('http://localhost:1633')
Properties
balance
readonlybalance:Balance
Defined in: bee-js/src/bee.ts:148
SWAP balance operations. Related to the bandwidth incentives and the chequebook.
cheque
readonlycheque:Cheque
Defined in: bee-js/src/bee.ts:198
Cheque operations (last cheques and cashouts).
chequebook
readonlychequebook:Chequebook
Defined in: bee-js/src/bee.ts:193
Chequebook contract operations (address, balance, deposit, withdraw).
chunk
readonlychunk:Chunk
Defined in: bee-js/src/bee.ts:238
Chunk operations backed by the /chunks endpoint.
collection
readonlycollection:Collection
Defined in: bee-js/src/bee.ts:248
Collection (multi-file) operations backed by the /bzz endpoint.
connectivity
readonlyconnectivity:Connectivity
Defined in: bee-js/src/bee.ts:168
Peer, topology and network connectivity operations.
data
readonlydata:Data
Defined in: bee-js/src/bee.ts:233
Raw data operations backed by the /bytes endpoint.
feed
readonlyfeed:Feed
Defined in: bee-js/src/bee.ts:223
Feed operations.
file
readonlyfile:File
Defined in: bee-js/src/bee.ts:243
Single-file operations backed by the /bzz endpoint.
grantee
readonlygrantee:Grantee
Defined in: bee-js/src/bee.ts:213
Grantee (access control) operations.
messaging
readonlymessaging:Messaging
Defined in: bee-js/src/bee.ts:218
Messaging protocols — PSS and GSOC.
network
readonlynetwork:"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
readonlypin:Pin
Defined in: bee-js/src/bee.ts:208
Local pinning operations.
settlement
readonlysettlement:Settlement
Defined in: bee-js/src/bee.ts:153
Settlement operations. Related to the bandwidth incentives and the chequebook.
signer?
readonlyoptionalsigner: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
readonlysoc:Soc
Defined in: bee-js/src/bee.ts:228
Single owner chunk (SOC) reader/writer operations.
stake
readonlystake:Stake
Defined in: bee-js/src/bee.ts:163
Staking operations.
stamp
readonlystamp:Stamp
Defined in: bee-js/src/bee.ts:183
Low-level postage batch (stamp) operations.
status
readonlystatus:Status
Defined in: bee-js/src/bee.ts:173
Node status, health, version and chain/reserve state operations.
storage
readonlystorage:Storage
Defined in: bee-js/src/bee.ts:188
Ergonomic storage operations expressed in terms of size and duration.
tag
readonlytag:Tag
Defined in: bee-js/src/bee.ts:203
Tag operations for tracking upload and synchronization progress.
transaction
readonlytransaction:Transaction
Defined in: bee-js/src/bee.ts:158
Pending transaction operations for the Bee node's transaction queue.
url
readonlyurl:string
Defined in: bee-js/src/bee.ts:58
Bee node API URL.
Example
`http://localhost:1633`
wallet
readonlywallet: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
address
Returns
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?
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
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
Address of the Content Addressed Chunk
span
Span of the Content Addressed Chunk
payload
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
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?
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
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
a single owner chunk or throws error