Skip to main content

Class: Storage

Defined in: bee-js/src/modules/storage.ts:16

Ergonomic storage operations expressed in terms of size and duration.

Accessed as bee.storage. Wraps the low-level bee.stamp operations.

Constructors​

Constructor​

new Storage(context): Storage

Defined in: bee-js/src/modules/storage.ts:17

Parameters​

context​

BeeContext

Returns​

Storage

Methods​

buy()​

buy(size, duration, options?, requestOptions?, encryption?, erasureCodeLevel?): Promise<BatchId>

Defined in: bee-js/src/modules/storage.ts:35

Creates a postage batch sized for a certain size and duration on the Swarm network.

Use getCost to calculate the cost beforehand.

Parameters​

size​

Size

duration​

Duration

options?​

PostageBatchOptions

requestOptions?​

BeeRequestOptions

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

encryption?​

boolean

erasureCodeLevel?​

RedundancyLevel

Returns​

Promise<BatchId>


extend()​

extend(postageBatchId, size, duration, requestOptions?, encryption?, erasureCodeLevel?): Promise<BatchId | TransactionId>

Defined in: bee-js/src/modules/storage.ts:89

Extends the storage of a postage batch by either increasing its size, duration or both.

The size is ABSOLUTE, while the duration is RELATIVE to the current duration of the postage batch.

Parameters​

postageBatchId​

Batch ID of the postage batch to extend.

string | Uint8Array<ArrayBufferLike> | BatchId

size​

Size

Absolute size to extend the postage batch to.

duration​

Duration

Relative duration to extend the postage batch by.

requestOptions?​

BeeRequestOptions

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

encryption?​

boolean

Assume the future uploaded data is encrypted, which skews the capacity of the postage batch.

erasureCodeLevel?​

RedundancyLevel

Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.

Returns​

Promise<BatchId | TransactionId>


extendDuration()​

extendDuration(postageBatchId, duration, requestOptions?): Promise<BatchId>

Defined in: bee-js/src/modules/storage.ts:165

Extends the duration of a postage batch.

Parameters​

postageBatchId​

string | Uint8Array<ArrayBufferLike> | BatchId

duration​

Duration

Relative duration to extend the postage batch by.

requestOptions?​

BeeRequestOptions

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

Returns​

Promise<BatchId>


extendSize()​

extendSize(postageBatchId, size, requestOptions?, encryption?, erasureCodeLevel?): Promise<BatchId>

Defined in: bee-js/src/modules/storage.ts:136

Extends the storage size of a postage batch by increasing its depth.

Parameters​

postageBatchId​

string | Uint8Array<ArrayBufferLike> | BatchId

size​

Size

Absolute size to extend the postage batch to.

requestOptions?​

BeeRequestOptions

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

encryption?​

boolean

Assume the future uploaded data is encrypted, which skews the capacity of the postage batch.

erasureCodeLevel?​

RedundancyLevel

Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.

Returns​

Promise<BatchId>


getCost()​

getCost(size, duration, requestOptions?, encryption?, erasureCodeLevel?): Promise<BZZ>

Defined in: bee-js/src/modules/storage.ts:63

Calculates the estimated BZZ cost for creating a postage batch for the given size and duration.

Parameters​

size​

Size

Size of the data to be stored.

duration​

Duration

Duration for which the data should be stored.

requestOptions?​

BeeRequestOptions

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

encryption?​

boolean

Assume the future uploaded data is encrypted, which skews the capacity of the postage batch.

erasureCodeLevel?​

RedundancyLevel

Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.

Returns​

Promise<BZZ>


getDurationExtensionCost()​

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

Defined in: bee-js/src/modules/storage.ts:246

Calculates the cost of extending the duration of a postage batch.

Parameters​

postageBatchId​

string | Uint8Array<ArrayBufferLike> | BatchId

duration​

Duration

requestOptions?​

BeeRequestOptions

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

Returns​

Promise<BZZ>


getExtensionCost()​

getExtensionCost(postageBatchId, size, duration, requestOptions?, encryption?, erasureCodeLevel?): Promise<BZZ>

Defined in: bee-js/src/modules/storage.ts:187

Calculates the cost of extending both the duration and the capacity of a postage batch.

Parameters​

postageBatchId​

string | Uint8Array<ArrayBufferLike> | BatchId

size​

Size

Absolute size to extend the postage batch to.

duration​

Duration

Relative duration to extend the postage batch by.

requestOptions?​

BeeRequestOptions

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

encryption?​

boolean

Assume the future uploaded data is encrypted, which skews the capacity of the postage batch.

erasureCodeLevel?​

RedundancyLevel

Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.

Returns​

Promise<BZZ>


getSizeExtensionCost()​

getSizeExtensionCost(postageBatchId, size, requestOptions?, encryption?, erasureCodeLevel?): Promise<BZZ>

Defined in: bee-js/src/modules/storage.ts:216

Calculates the cost of extending the size of a postage batch.

Parameters​

postageBatchId​

string | Uint8Array<ArrayBufferLike> | BatchId

size​

Size

requestOptions?​

BeeRequestOptions

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

encryption?​

boolean

Assume the future uploaded data is encrypted, which skews the capacity of the postage batch.

erasureCodeLevel?​

RedundancyLevel

Assume the future uploaded data is erasure coded, which skews the capacity of the postage batch.

Returns​

Promise<BZZ>


rename()​

rename(postageBatchId, newLabel, requestOptions?): Promise<void>

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

Renames a storage. Convenience wrapper over bee.stamp.updateLabel.

Parameters​

postageBatchId​

Batch ID of the postage batch to update.

string | Uint8Array<ArrayBufferLike> | BatchId

newLabel​

string

New name for the storage.

requestOptions?​

BeeRequestOptions

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

Returns​

Promise<void>

💬 Get Help