UNPKG

@ethersphere/bee-js

Version:
836 lines (835 loc) 47.2 kB
/// <reference types="node" /> import { Readable } from 'stream'; import { Chunk } from './chunk/cac'; import { FeedPayloadResult } from './modules/feed'; import type { AllSettlements, BalanceResponse, BeeOptions, BeeRequestOptions, BeeVersions, ChainState, ChequebookAddressResponse, ChequebookBalanceResponse, CollectionUploadOptions, DebugStatus, DownloadOptions, EnvelopeWithBatchId, FeedReader, FeedWriter, FileData, FileUploadOptions, GetGranteesResult, GlobalPostageBatch, GranteesResult, GsocMessageHandler, GsocSubscription, Health, LastCashoutActionResponse, LastChequesForPeerResponse, LastChequesResponse, NodeAddresses, NodeInfo, NumberString, Peer, PeerBalance, Pin, PingResponse, PostageBatch, PostageBatchBuckets, PssMessageHandler, PssSubscription, Readiness, RedistributionState, RedundantUploadOptions, ReferenceInformation, RemovePeerResponse, ReserveState, SOCReader, SOCWriter, Settlements, Tag, Topology, TransactionInfo, UploadOptions, WalletBalance } from './types'; import { AllTagsOptions, Collection, PostageBatchOptions, TransactionOptions, UploadResult } from './types'; import { Bytes } from './utils/bytes'; import { Duration } from './utils/duration'; import { Size } from './utils/size'; import { BZZ, DAI } from './utils/tokens'; import { BatchId, EthAddress, FeedIndex, Identifier, PeerAddress, PrivateKey, PublicKey, Reference, Topic, TransactionId } from './utils/typed-bytes'; import { UploadProgress } from './utils/upload-progress'; /** * 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. */ export declare class Bee { /** * URL on which is the main API of Bee node exposed */ readonly url: string; /** * Default Signer object used for signing operations, mainly Feeds. */ readonly signer?: PrivateKey; /** * Network on which the Bee node is running */ readonly network: 'gnosis' | 'sepolia'; /** * Options for making requests * @private */ private readonly requestOptions; /** * @param url URL on which is the main API of Bee node exposed * @param options */ constructor(url: string, options?: BeeOptions); /** * Upload data to a Bee node * * @param postageBatchId Postage BatchId to be used to upload the data with * @param data Data to be uploaded * @param options Additional options like tag, encryption, pinning, content-type and request options * * @returns reference is a content hash of the data * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download) * @see [Bee API reference - `POST /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes/post) */ uploadData(postageBatchId: BatchId | Uint8Array | string, data: string | Uint8Array, options?: RedundantUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>; /** * Requests content length for a `/bytes` reference * * @see [Bee API reference - `HEAD /bytes/`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1%7Breference%7D/head) */ probeData(reference: Reference | Uint8Array | string, options?: BeeRequestOptions): Promise<ReferenceInformation>; /** * Download data as a byte array * * @param resource Swarm reference, Swarm CID, or ENS domain * @param options Options that affects the request behavior * @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 - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download) * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get) */ downloadData(resource: Reference | string | Uint8Array, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<Bytes>; /** * Download data as a Readable stream * * @param resource Swarm reference, Swarm CID, or ENS domain * @param options Options that affects the request behavior * @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 - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download) * @see [Bee API reference - `GET /bytes`](https://docs.ethswarm.org/api/#tag/Bytes/paths/~1bytes~1{reference}/get) */ downloadReadableData(resource: Reference | Uint8Array | string, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<ReadableStream<Uint8Array>>; /** * Upload chunk to a Bee node * * @param postageBatchId Postage BatchId to be used to upload the chunk with * @param data Raw chunk to be uploaded * @param options Additional options like tag, encryption, pinning, content-type and request options * * @returns reference is a content hash of the data * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download) * @see [Bee API reference - `POST /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks/post) */ uploadChunk(stamp: EnvelopeWithBatchId | BatchId | Uint8Array | string, data: Uint8Array | Chunk, options?: UploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>; /** * Download chunk as a byte array * * @param reference Bee chunk reference in hex string (either 64 or 128 chars long) or ENS domain. * @param options Options that affects the request behavior * @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 - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download) * @see [Bee API reference - `GET /chunks`](https://docs.ethswarm.org/api/#tag/Chunk/paths/~1chunks~1{address}/get) */ downloadChunk(reference: Reference | Uint8Array | string, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<Uint8Array>; /** * Create a grantees list from the given array of public keys. * * The grantees list can be obtained with the `getGrantees` method. * * @param postageBatchId - The ID of the postage batch. * @param grantees - An array of public keys representing the grantees. * @param requestOptions - Optional request options. * @returns A promise that resolves to a `GranteesResult` object. */ createGrantees(postageBatchId: BatchId | Uint8Array | string, grantees: PublicKey[] | Uint8Array[] | string[], requestOptions?: BeeRequestOptions): Promise<GranteesResult>; /** * Retrieves the grantees for a given reference. * * @param reference - The reference. * @param requestOptions - Optional request options. * @returns A promise that resolves to a `GetGranteesResult` object. */ getGrantees(reference: Reference | Uint8Array | string, requestOptions?: BeeRequestOptions): Promise<GetGranteesResult>; /** * Updates the grantees of a specific reference and history. * * @param reference - The reference. * @param history - The history. * @param postageBatchId - The ID of the postage batch. * @param grantees - The grantees. * @param requestOptions - Optional request options. * @returns A Promise that resolves to to a `GranteesResult` object. */ patchGrantees(postageBatchId: BatchId | Uint8Array | string, reference: Reference | Uint8Array | string, history: Reference | Uint8Array | string, grantees: { add?: PublicKey[] | Uint8Array[] | string[]; revoke?: PublicKey[] | Uint8Array[] | string[]; }, requestOptions?: BeeRequestOptions): Promise<GranteesResult>; /** * Upload single file to a Bee node. * * @param postageBatchId Postage BatchId to be used to upload the data with * @param data Data or file to be uploaded * @param name Optional name of the uploaded file * @param options Additional options like tag, encryption, pinning, content-type and request options * * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive) * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download) * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post) * @returns reference is a content hash of the file */ uploadFile(postageBatchId: BatchId | Uint8Array | string, data: string | Uint8Array | Readable | File, name?: string, options?: FileUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>; /** * Download single file. * * @param resource Swarm reference, Swarm CID, or ENS domain * @param path If reference points to manifest, then this parameter defines path to the file * @param options Options that affects the request behavior * @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 Data * @see [Bee docs - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download) * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get) */ downloadFile(resource: Reference | Uint8Array | string, path?: string, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<FileData<Bytes>>; /** * Download single file as a readable stream * * @param reference Bee file reference in hex string (either 64 or 128 chars long), ENS domain or Swarm CID. * @param path If reference points to manifest / collections, then this parameter defines path to the file * @param options Options that affects the request behavior * @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 - Upload and download](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download) * @see [Bee API reference - `GET /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz~1%7Breference%7D~1%7Bpath%7D/get) */ downloadReadableFile(reference: Reference | Uint8Array | string, path?: string, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<FileData<ReadableStream<Uint8Array>>>; /** * 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 * * @param postageBatchId Postage BatchId to be used to upload the data with * @param fileList list of files to be uploaded * @param options Additional options like tag, encryption, pinning and request options * * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive) * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download#upload-a-directory) * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post) */ uploadFiles(postageBatchId: BatchId | Uint8Array | string, fileList: FileList | File[], options?: CollectionUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>; hashDirectory(dir: string): Promise<Reference>; streamDirectory(postageBatchId: BatchId | Uint8Array | string, dir: string, onUploadProgress?: (progress: UploadProgress) => void, options?: CollectionUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>; streamFiles(postageBatchId: BatchId | Uint8Array | string, files: File[] | FileList, onUploadProgress?: (progress: UploadProgress) => void, options?: UploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>; /** * 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 * * @param postageBatchId * @param collection * @param options Collections and request options */ uploadCollection(postageBatchId: BatchId | Uint8Array | string, collection: Collection, options?: CollectionUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>; /** * 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 * * @param postageBatchId Postage BatchId to be used to upload the data with * @param dir the path of the files to be uploaded * @param options Additional options like tag, encryption, pinning and request options * * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive) * @see [Bee docs - Upload directory](https://docs.ethswarm.org/docs/develop/access-the-swarm/upload-and-download#upload-a-directory) * @see [Bee API reference - `POST /bzz`](https://docs.ethswarm.org/api/#tag/BZZ/paths/~1bzz/post) */ uploadFilesFromDirectory(postageBatchId: BatchId | Uint8Array | string, dir: string, options?: CollectionUploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>; /** * Create a new Tag which is meant for tracking progres of syncing data across network. * * @param options Options that affects the request behavior * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing) * @see [Bee API reference - `POST /tags`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/post) */ createTag(options?: BeeRequestOptions): Promise<Tag>; /** * Fetches all tags. * * The listing is limited by options.limit. So you have to iterate using options.offset to get all tags. * * @param options Options that affects the request behavior * @throws TypeError if limit or offset are not numbers or undefined * @throws BeeArgumentError if limit or offset have invalid options * * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing) * @see [Bee API reference - `GET /tags`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags/get) */ getAllTags(options?: AllTagsOptions, requestOptions?: BeeRequestOptions): Promise<Tag[]>; /** * Retrieve tag information from Bee node * * @param tagUid UID or tag object to be retrieved * @param options Options that affects the request behavior * @throws TypeError if tagUid is in not correct format * * @see [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing) * @see [Bee API reference - `GET /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/get) * */ retrieveTag(tagUid: number | Tag, options?: BeeRequestOptions): Promise<Tag>; /** * Delete Tag * * @param tagUid UID or tag object to be retrieved * @param options Options that affects the request behavior * @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 [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing) * @see [Bee API reference - `DELETE /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/delete) */ deleteTag(tagUid: number | Tag, options?: BeeRequestOptions): Promise<void>; /** * 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. * * @param tagUid UID or tag object to be retrieved * @param reference The root reference that contains all the chunks to be counted * @param options Options that affects the request behavior * @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 [Bee docs - Syncing / Tags](https://docs.ethswarm.org/docs/develop/access-the-swarm/syncing) * @see [Bee API reference - `PATCH /tags/{uid}`](https://docs.ethswarm.org/api/#tag/Tag/paths/~1tags~1{uid}/patch) */ updateTag(tagUid: number | Tag, reference: Reference | string, options?: BeeRequestOptions): Promise<void>; /** * Pin local data with given reference * * @param reference Data reference * @param options Options that affects the request behavior * @throws TypeError if reference is in not correct format * * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning) */ pin(reference: Reference | Uint8Array | string, options?: BeeRequestOptions): Promise<void>; /** * Unpin local data with given reference * * @param reference Data reference * @param options Options that affects the request behavior * @throws TypeError if reference is in not correct format * * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning) */ unpin(reference: Reference | Uint8Array | string, options?: BeeRequestOptions): Promise<void>; /** * Get list of all locally pinned references * * @param options Options that affects the request behavior * @see [Bee docs - Pinning](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning) */ getAllPins(options?: BeeRequestOptions): Promise<Reference[]>; /** * Get pinning status of chunk with given reference * * @param reference Bee data reference in hex string (either 64 or 128 chars long) or ENS domain. * @param options Options that affects the request behavior * @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](https://docs.ethswarm.org/docs/develop/access-the-swarm/pinning) */ getPin(reference: Reference | Uint8Array | string, options?: BeeRequestOptions): Promise<Pin>; /** * Instructs the Bee node to reupload a locally pinned data into the network. * * @param reference Bee data reference to be re-uploaded in hex string (either 64 or 128 chars long) or ENS domain. * @param options Options that affects the request behavior * @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`](https://docs.ethswarm.org/api/#tag/Stewardship/paths/~1stewardship~1{reference}/put) */ reuploadPinnedData(postageBatchId: BatchId | Uint8Array | string, reference: Reference | Uint8Array | string, options?: BeeRequestOptions): Promise<void>; /** * Checks if content specified by reference is retrievable from the network. * * @param reference Bee data reference to be checked in hex string (either 64 or 128 chars long) or ENS domain. * @param options Options that affects the request behavior * @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`](https://docs.ethswarm.org/api/#tag/Stewardship/paths/~1stewardship~1{reference}/get) */ isReferenceRetrievable(reference: Reference | Uint8Array | string, options?: BeeRequestOptions): Promise<boolean>; /** * 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. * * @param type * @param owner * @param topic * @param index * @param options */ isFeedRetrievable(owner: EthAddress | Uint8Array | string, topic: Topic | Uint8Array | string, index?: FeedIndex, options?: DownloadOptions, requestOptions?: BeeRequestOptions): Promise<boolean>; /** * 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. * * @param postageBatchId Postage BatchId that will be assigned to sent message * @param topic Topic name * @param target 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. * @param data Message to be sent * @param recipient Recipient public key * @param options Options that affects the request behavior * @throws TypeError if `data`, `batchId`, `target` or `recipient` are in invalid format * * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss) * @see [Bee API reference - `POST /pss`](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1send~1{topic}~1{targets}/post) */ pssSend(postageBatchId: BatchId | Uint8Array | string, topic: Topic, target: string, data: string | Uint8Array, recipient?: string | PublicKey, options?: BeeRequestOptions): Promise<void>; /** * 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. * * @param topic Topic name * @param handler Message handler interface * * @returns Subscription to a given topic * * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss) * @see [Bee API reference - `GET /pss`](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1subscribe~1{topic}/get) */ pssSubscribe(topic: Topic, handler: PssMessageHandler): PssSubscription; /** * 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. * * @param topic Topic name * @param timeoutMsec Timeout in milliseconds * * @returns Message in byte array * * @see [Bee docs - PSS](https://docs.ethswarm.org/docs/develop/tools-and-features/pss) * @see [Bee API reference - `GET /pss`](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1subscribe~1{topic}/get) */ pssReceive(topic: Topic, timeoutMsec?: number): Promise<Bytes>; gsocMine(targetOverlay: PeerAddress | Uint8Array | string, identifier: Identifier | Uint8Array | string, proximity?: number): PrivateKey; gsocSend(postageBatchId: BatchId | Uint8Array | string, signer: PrivateKey | Uint8Array | string, identifier: Identifier | Uint8Array | string, data: string | Uint8Array, options?: UploadOptions, requestOptions?: BeeRequestOptions): Promise<UploadResult>; gsocSubscribe(address: EthAddress | Uint8Array | string, identifier: Identifier | Uint8Array | string, handler: GsocMessageHandler): GsocSubscription; /** * 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. * * @param postageBatchId Postage BatchId to be used to create the Feed Manifest * @param topic Topic in hex or bytes * @param owner Owner's ethereum address in hex or bytes * @param options Options that affects the request behavior * * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds) * @see [Bee API reference - `POST /feeds`](https://docs.ethswarm.org/api/#tag/Feed/paths/~1feeds~1{owner}~1{topic}/post) */ createFeedManifest(postageBatchId: BatchId | Uint8Array | string, topic: Topic | Uint8Array | string, owner: EthAddress | Uint8Array | string, options?: UploadOptions, requestOptions?: BeeRequestOptions): Promise<Reference>; /** * Make a new feed reader for downloading feed updates. * * @param topic Topic in hex or bytes * @param owner Owner's ethereum address in hex or bytes * @param options Options that affects the request behavior * * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds) */ makeFeedReader(topic: Topic | Uint8Array | string, owner: EthAddress | Uint8Array | string, options?: BeeRequestOptions): FeedReader; /** * Make a new feed writer for updating feeds * * @param topic Topic in hex or bytes * @param signer The signer's private key or a Signer instance that can sign data * @param options Options that affects the request behavior * * @see [Bee docs - Feeds](https://docs.ethswarm.org/docs/develop/tools-and-features/feeds) */ makeFeedWriter(topic: Topic | Uint8Array | string, signer?: PrivateKey | Uint8Array | string, options?: BeeRequestOptions): FeedWriter; fetchLatestFeedUpdate(topic: Topic | Uint8Array | string, owner: EthAddress | Uint8Array | string, requestOptions?: BeeRequestOptions): Promise<FeedPayloadResult>; /** * Returns an object for reading single owner chunks * * @param ownerAddress The ethereum address of the owner * @param options Options that affects the request behavior * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/develop/tools-and-features/chunk-types#single-owner-chunks) */ makeSOCReader(ownerAddress: EthAddress | Uint8Array | string, options?: BeeRequestOptions): SOCReader; /** * Returns an object for reading and writing single owner chunks * * @param signer The signer's private key or a Signer instance that can sign data * @param options Options that affects the request behavior * @see [Bee docs - Chunk Types](https://docs.ethswarm.org/docs/develop/tools-and-features/chunk-types#single-owner-chunks) */ makeSOCWriter(signer?: PrivateKey | Uint8Array | string, options?: BeeRequestOptions): SOCWriter; createEnvelope(postageBatchId: BatchId | Uint8Array | string, reference: Reference | Uint8Array | string, options?: BeeRequestOptions): Promise<EnvelopeWithBatchId>; /** * Get reserve commitment hash duration seconds */ rchash(depth: number, anchor1: string, anchor2: string, options?: BeeRequestOptions): Promise<number>; /** * Ping the Bee node to see if there is a live Bee node on the given URL. * * @param options Options that affects the request behavior * @throws If connection was not successful throw error */ checkConnection(options?: BeeRequestOptions): Promise<void> | never; /** * Ping the Bee node to see if there is a live Bee node on the given URL. * * @param options Options that affects the request behavior * @returns true if successful, false on error */ isConnected(options?: BeeRequestOptions): Promise<boolean>; /** * Checks the `/gateway` endpoint to see if the remote API is a gateway. * * Do note that this is not a standard way to check for gateway nodes, * but some of the gateway tooling expose this endpoint. * * @param options */ isGateway(options?: BeeRequestOptions): Promise<boolean>; getNodeAddresses(options?: BeeRequestOptions): Promise<NodeAddresses>; getBlocklist(options?: BeeRequestOptions): Promise<Peer[]>; /** * Get list of peers for this node */ getPeers(options?: BeeRequestOptions): Promise<Peer[]>; removePeer(peer: PeerAddress | string, options?: BeeRequestOptions): Promise<RemovePeerResponse>; getTopology(options?: BeeRequestOptions): Promise<Topology>; pingPeer(peer: PeerAddress | string, options?: BeeRequestOptions): Promise<PingResponse>; /** * Get the balances with all known peers including prepaid services */ getAllBalances(options?: BeeRequestOptions): Promise<BalanceResponse>; /** * Get the balances with a specific peer including prepaid services * * @param address Swarm address of peer */ getPeerBalance(address: PeerAddress | string, options?: BeeRequestOptions): Promise<PeerBalance>; /** * Get the past due consumption balances with all known peers */ getPastDueConsumptionBalances(options?: BeeRequestOptions): Promise<BalanceResponse>; /** * Get the past due consumption balance with a specific peer * * @param address Swarm address of peer */ getPastDueConsumptionPeerBalance(address: PeerAddress | string, options?: BeeRequestOptions): Promise<PeerBalance>; /** * 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 */ getChequebookAddress(options?: BeeRequestOptions): Promise<ChequebookAddressResponse>; /** * Get the balance of the chequebook */ getChequebookBalance(options?: BeeRequestOptions): Promise<ChequebookBalanceResponse>; /** * Get last cheques for all peers */ getLastCheques(options?: BeeRequestOptions): Promise<LastChequesResponse>; /** * Get last cheques for the peer * * @param address Swarm address of peer */ getLastChequesForPeer(address: PeerAddress | string, options?: BeeRequestOptions): Promise<LastChequesForPeerResponse>; /** * Get last cashout action for the peer * * @param address Swarm address of peer */ getLastCashoutAction(address: PeerAddress | string, options?: BeeRequestOptions): Promise<LastCashoutActionResponse>; /** * Cashout the last cheque for the peer * * @param address Swarm address of peer * @param options * @param options.gasPrice Gas price for the cashout transaction in WEI * @param options.gasLimit Gas limit for the cashout transaction in WEI */ cashoutLastCheque(address: PeerAddress | string, options?: TransactionOptions, requestOptions?: BeeRequestOptions): Promise<TransactionId>; /** * Deposit tokens from node wallet into chequebook * * @param amount Amount of tokens to deposit (must be positive integer) * @param gasPrice Gas Price in WEI for the transaction call * @return string Hash of the transaction * @deprecated Use `depositBZZToChequebook` instead. */ depositTokens(amount: BZZ | NumberString | string | bigint, gasPrice?: NumberString | string | bigint, options?: BeeRequestOptions): Promise<TransactionId>; /** * Deposit tokens from node wallet into chequebook * * @param amount Amount of tokens to deposit (must be positive integer) * @param gasPrice Gas Price in WEI for the transaction call * @return string Hash of the transaction */ depositBZZToChequebook(amount: BZZ | NumberString | string | bigint, gasPrice?: NumberString | string | bigint, options?: BeeRequestOptions): Promise<TransactionId>; /** * Withdraw tokens from the chequebook to the node wallet * * @param amount Amount of tokens to withdraw (must be positive integer) * @param gasPrice Gas Price in WEI for the transaction call * @return string Hash of the transaction * @deprecated Use `withdrawBZZFromChequebook` instead. */ withdrawTokens(amount: BZZ | NumberString | string | bigint, gasPrice?: NumberString | string | bigint, options?: BeeRequestOptions): Promise<TransactionId>; /** * Withdraw tokens from the chequebook to the node wallet * * @param amount Amount of tokens to withdraw (must be positive integer) * @param gasPrice Gas Price in WEI for the transaction call * @return string Hash of the transaction */ withdrawBZZFromChequebook(amount: BZZ | NumberString | string | bigint, gasPrice?: NumberString | string | bigint, options?: BeeRequestOptions): Promise<TransactionId>; withdrawBZZToExternalWallet(amount: BZZ | NumberString | string | bigint, address: EthAddress | Uint8Array | string, options?: BeeRequestOptions): Promise<TransactionId>; withdrawDAIToExternalWallet(amount: DAI | NumberString | string | bigint, address: EthAddress | Uint8Array | string, options?: BeeRequestOptions): Promise<TransactionId>; /** * Get amount of sent and received from settlements with a peer * * @param address Swarm address of peer */ getSettlements(address: PeerAddress | string, options?: BeeRequestOptions): Promise<Settlements>; /** * Get settlements with all known peers and total amount sent or received */ getAllSettlements(options?: BeeRequestOptions): Promise<AllSettlements>; /** * Get status of node */ getStatus(options?: BeeRequestOptions): Promise<DebugStatus>; /** * Get health of node */ getHealth(options?: BeeRequestOptions): Promise<Health>; /** * Get readiness of node */ getReadiness(options?: BeeRequestOptions): Promise<Readiness>; /** * Get mode information of node */ getNodeInfo(options?: BeeRequestOptions): Promise<NodeInfo>; /** * Connects to a node and checks if its version matches with the one that bee-js supports. * * @param options */ isSupportedExactVersion(options?: BeeRequestOptions): Promise<boolean> | never; /** * * 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. * * @param options */ isSupportedApiVersion(options?: BeeRequestOptions): Promise<boolean> | never; /** * 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*`). * * @param options */ getVersions(options?: BeeRequestOptions): Promise<BeeVersions> | never; /** * Get reserve state */ getReserveState(options?: BeeRequestOptions): Promise<ReserveState>; /** * Get chain state */ getChainState(options?: BeeRequestOptions): Promise<ChainState>; /** * Get wallet balances for DAI and BZZ of the Bee node * * @param options */ getWalletBalance(options?: BeeRequestOptions): Promise<WalletBalance>; /** * 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](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction#keep-your-data-alive). * * **WARNING: THIS CREATES TRANSACTIONS THAT SPENDS MONEY** * * @param amount Amount that represents the value per chunk, has to be greater or equal zero. * @param depth Logarithm of the number of chunks that can be stamped with the batch. * @param options Options for creation of postage batch * @throws BeeArgumentError when negative amount or depth is specified * @throws TypeError if non-integer value is passed to amount or depth * * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive) * @see [Bee Debug API reference - `POST /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1{amount}~1{depth}/post) */ createPostageBatch(amount: NumberString | string | bigint, depth: number, options?: PostageBatchOptions, requestOptions?: BeeRequestOptions): Promise<BatchId>; buyStorage(size: Size, duration: Duration, options?: PostageBatchOptions, requestOptions?: BeeRequestOptions): Promise<BatchId>; getStorageCost(size: Size, duration: Duration, options?: BeeRequestOptions): Promise<BZZ>; extendStorageSize(postageBatchId: BatchId | Uint8Array | string, size: Size, options?: BeeRequestOptions): Promise<BatchId>; extendStorageDuration(postageBatchId: BatchId | Uint8Array | string, duration: Duration, options?: BeeRequestOptions): Promise<BatchId>; getExtensionCost(postageBatchId: BatchId | Uint8Array | string, size: Size, duration: Duration, options?: BeeRequestOptions): Promise<BZZ>; getSizeExtensionCost(postageBatchId: BatchId | Uint8Array | string, size: Size, options?: BeeRequestOptions): Promise<BZZ>; getDurationExtensionCost(postageBatchId: BatchId | Uint8Array | string, duration: Duration, options?: BeeRequestOptions): Promise<BZZ>; /** * 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](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive). * * @param postageBatchId Batch ID * @param amount Amount to be added to the batch * @param options Request options * * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive) * @see [Bee Debug API reference - `PATCH /stamps/topup/${id}/${amount}`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1topup~1{batch_id}~1{amount}/patch) */ topUpBatch(postageBatchId: BatchId | Uint8Array | string, amount: NumberString | string | bigint, options?: BeeRequestOptions): Promise<BatchId>; /** * 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](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive). * * @param postageBatchId Batch ID * @param depth Amount to be added to the batch * @param options Request options * * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive) * @see [Bee Debug API reference - `PATCH /stamps/topup/${id}/${amount}`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1dilute~1%7Bbatch_id%7D~1%7Bdepth%7D/patch) */ diluteBatch(postageBatchId: BatchId | Uint8Array | string, depth: number, options?: BeeRequestOptions): Promise<BatchId>; /** * Return details for specific postage batch. * * @param postageBatchId Batch ID * * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive) * @see [Bee Debug API reference - `GET /stamps/${id}`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1%7Bbatch_id%7D/get) */ getPostageBatch(postageBatchId: BatchId | Uint8Array | string, options?: BeeRequestOptions): Promise<PostageBatch>; /** * Return detailed information related to buckets for specific postage batch. * * @param postageBatchId Batch ID * * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive) * @see [Bee Debug API reference - `GET /stamps/${id}/buckets`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1%7Bbatch_id%7D~1buckets/get) */ getPostageBatchBuckets(postageBatchId: BatchId | Uint8Array | string, options?: BeeRequestOptions): Promise<PostageBatchBuckets>; /** * Return all postage batches that has the node available. * * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive) * @see [Bee Debug API reference - `GET /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps/get) * @deprecated Use `getPostageBatches` instead */ getAllPostageBatch(options?: BeeRequestOptions): Promise<PostageBatch[]>; /** * Return all globally available postage batches. * @deprecated Use `getGlobalPostageBatches` instead */ getAllGlobalPostageBatch(options?: BeeRequestOptions): Promise<GlobalPostageBatch[]>; /** * Return all postage batches that belong to the node. * * @see [Bee docs - Keep your data alive / Postage stamps](https://docs.ethswarm.org/docs/develop/access-the-swarm/introduction/#keep-your-data-alive) * @see [Bee Debug API reference - `GET /stamps`](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps/get) */ getPostageBatches(options?: BeeRequestOptions): Promise<PostageBatch[]>; /** * Return all globally available postage batches. */ getGlobalPostageBatches(options?: BeeRequestOptions): Promise<GlobalPostageBatch[]>; /** * Return lists of all current pending transactions that the Bee made */ getAllPendingTransactions(options?: BeeRequestOptions): Promise<TransactionInfo[]>; /** * Return transaction information for specific transaction * @param transactionHash */ getPendingTransaction(transactionHash: TransactionId | Uint8Array | string, options?: BeeRequestOptions): Promise<TransactionInfo>; /** * Rebroadcast already created transaction. * This is mainly needed when your transaction fall off mempool from other reason is not incorporated into block. * * @param transactionHash */ rebroadcastPendingTransaction(transactionHash: TransactionId | Uint8Array | string, options?: BeeRequestOptions): Promise<TransactionId>; /** * Cancels a currently pending transaction * @param transactionHash * @param gasPrice */ cancelPendingTransaction(transactionHash: TransactionId | Uint8Array | string, gasPrice?: NumberString | string | bigint, options?: BeeRequestOptions): Promise<TransactionId>; /** * Gets the amount of staked BZZ * * @param options HTTP request options, such as `headers` or `timeout` */ getStake(options?: BeeRequestOptions): Promise<BZZ>; /** * Gets the amount of withdrawable staked BZZ. * * @param options HTTP request options, such as `headers` or `timeout` */ getWithdrawableStake(options?: BeeRequestOptions): Promise<BZZ>; /** * Withdraws ALL surplus staked BZZ to the node wallet. * * Use the `getWithdrawableStake` method to check how much surplus stake is available. * * @param options HTTP request options, such as `headers` or `timeout` */ withdrawSurplusStake(options?: BeeRequestOptions): Promise<TransactionId>; /** * Withdraws all staked BZZ to the node wallet. * * **Only available when the staking contract is paused and is in the process of being migrated to a new contract!** * * @param options HTTP request options, such as `headers` or `timeout` */ migrateStake(options?: BeeRequestOptions): Promise<TransactionId>; /** * Stakes the given amount of BZZ. Initial deposit must be at least 10 BZZ. * * Be aware that staked BZZ tokens can **not** be withdrawn. * * @param amount Amount of BZZ tokens to be staked. If not providing a `BZZ` instance, the amount is denoted in PLUR. * @param options HTTP request options, such as `headers` or `timeout` */ depositStake(amount: BZZ | NumberString | string | bigint, options?: TransactionOptions, requestOptions?: BeeRequestOptions): Promise<TransactionId>; /** * Gets current status of node in redistribution game * * @param options HTTP request options, such as `headers` or `timeout` */ getRedistributionState(options?: BeeRequestOptions): Promise<RedistributionState>; private waitForUsablePostageStamp; protected getRequestOptionsForCall(options?: BeeRequestOptions): BeeRequestOptions; }