Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions docs/documentation/buying-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ import { Bee, Size } from "@ethersphere/bee-js"
const bee = new Bee('http://localhost:1633')

// Request all local postage batches
const batches = await bee.getAllPostageBatch()
const batches = await bee.getPostageBatches()

const batchId = batches[0].batchID

Expand All @@ -133,7 +133,7 @@ import { Bee, Size } from "@ethersphere/bee-js"
const bee = new Bee('http://localhost:1633')

// Request all local postage batches
const batches = await bee.getAllPostageBatch()
const batches = await bee.getPostageBatches()

// Print results to the terminal
console.log(batches)
Expand Down Expand Up @@ -195,7 +195,7 @@ import { Bee, Duration } from "@ethersphere/bee-js"
const bee = new Bee('http://localhost:1633')

// Request all local postage batches
const batches = await bee.getAllPostageBatch()
const batches = await bee.getPostageBatches()

// Select the batch ID of the first batch in the list
const batchId = batches[0].batchID
Expand All @@ -221,7 +221,7 @@ import { Bee, Duration } from "@ethersphere/bee-js"
const bee = new Bee('http://localhost:1633')

// Request all local postage batches
const batches = await bee.getAllPostageBatch()
const batches = await bee.getPostageBatches()

// Select the batch ID of the first batch in the list
const batchId = batches[0].batchID
Expand Down Expand Up @@ -281,7 +281,7 @@ import { Bee, Size, Duration } from "@ethersphere/bee-js"
const bee = new Bee('http://localhost:1633')

// Request all local postage batches
const batches = await bee.getAllPostageBatch()
const batches = await bee.getPostageBatches()

// Choose a batch to extend
const batchId = batches[0].batchID
Expand Down Expand Up @@ -312,7 +312,7 @@ If you're happy with the cost, you can then proceed to extend the **size** and *

### Checking Batch Status

You can check the status of purchased batches using the `bee.getAllPostageBatch` method:
You can check the status of purchased batches using the `bee.getPostageBatches` method:


```javascript
Expand All @@ -321,7 +321,7 @@ import { Bee } from "@ethersphere/bee-js"
const bee = new Bee('http://localhost:1633')

// Request all local postage batches
const batches = await bee.getAllPostageBatch()
const batches = await bee.getPostageBatches()

// Print results to the terminal
console.log(batches)
Expand Down Expand Up @@ -382,7 +382,7 @@ import { Bee } from '@ethersphere/bee-js'
const bee = new Bee('http://localhost:1633')

export async function getBatch(bee, criteriaFn) {
const batches = await bee.getAllPostageBatch()
const batches = await bee.getPostageBatches()
const matchingBatch = batches.find(criteriaFn)

if (!matchingBatch) {
Expand All @@ -409,7 +409,7 @@ function isUsableWithFreeSpace(batch) {
const batchId = getBatch(bee, isUsableWithFreeSpace)
```

If you need a batch with specific characteristics (such as a batch with at least 10 GB remaining space or a mutable batch), then you should [inspect](/docs/storage/#checking-batch-status) your postage batches' status using `bee.getAllPostageBatch` in order to check if a batch with your desired characteristics exists and return its id.
If you need a batch with specific characteristics (such as a batch with at least 10 GB remaining space or a mutable batch), then you should [inspect](/docs/storage/#checking-batch-status) your postage batches' status using `bee.getPostageBatches` in order to check if a batch with your desired characteristics exists and return its id.

### Batch Size Breakpoints

Expand Down Expand Up @@ -473,7 +473,7 @@ The class also includes three *instance* methods for getting the value from an e

sizeB.toBytes() // → 5000000000
sizeB.toGigabytes() // → 5
sizeB.toFormattedString() // → '5.00 GB'
sizeB.toFormattedString() // → '5.000 GB'
```


Expand Down
16 changes: 12 additions & 4 deletions docs/documentation/chequebook.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ To use the example scripts below, you need:
Deposits a specified amount of BZZ into the chequebook from your node wallet. This ensures that your node can issue cheques for transactions.

```javascript
const amount = new BZZ.fromDecimalString('1') // Deposit 1 BZZ
import { Bee, BZZ } from '@ethersphere/bee-js'

const transactionHash = await bee.depositTokens(amount)
const bee = new Bee('http://localhost:1633')

const amount = BZZ.fromDecimalString('1') // Deposit 1 BZZ

const transactionHash = await bee.depositBZZToChequebook(amount)
console.log('Deposit transaction hash:', transactionHash.toHex())
```

Expand Down Expand Up @@ -56,9 +60,13 @@ Chequebook Balance: {
Withdraws a specified amount of BZZ from the chequebook to the node wallet. You may need to withdraw if you want to transfer BZZ to another account or for other uses.

```javascript
const amountToWithdraw = new BZZ.fromDecimalString('1') // Withdraw 1 BZZ
import { Bee, BZZ } from '@ethersphere/bee-js'

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

const amountToWithdraw = BZZ.fromDecimalString('1') // Withdraw 1 BZZ

const withdrawalHash = await bee.withdrawTokens(amountToWithdraw)
const withdrawalHash = await bee.withdrawBZZFromChequebook(amountToWithdraw)
console.log('Withdraw transaction hash:', withdrawalHash.toHex())
```

Expand Down
9 changes: 5 additions & 4 deletions docs/documentation/gsoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ The `Overlay` should be saved and shared with sender nodes.
This must be run on a full node. It mines a key that lands within its own neighborhood and starts listening.

```js
import { Bee, Identifier, NULL_IDENTIFIER } from '@ethersphere/bee-js'
import { Bee, NULL_IDENTIFIER } from '@ethersphere/bee-js'

const bee = new Bee('http://localhost:1633')
const identifier = Identifier.fromString(NULL_IDENTIFIER)
const identifier = NULL_IDENTIFIER

async function listen() {
const { overlay } = await bee.getNodeAddresses()
Expand All @@ -109,6 +109,7 @@ async function listen() {
// A callback function is used to handle incoming updates - you can include your application logic here
onMessage: message => console.log('Received:', message.toUtf8()),
onError: error => console.error('Subscription error:', error),
onClose: () => console.log('Subscription closed.'),
})

console.log('Listening for GSOC updates...')
Expand All @@ -122,12 +123,12 @@ listen()
The sending node must have a ***usable postage batch id*** and also know the ***target overlay address*** and ***identifier*** in order to send a message:

```js
import { Bee, Identifier, NULL_IDENTIFIER } from '@ethersphere/bee-js'
import { Bee, NULL_IDENTIFIER } from '@ethersphere/bee-js'

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

// The identifier is initialized using the same data as the receiving node
const identifier = Identifier.fromString(NULL_IDENTIFIER)
const identifier = NULL_IDENTIFIER
const batchId = '6c84b6d3f5273b969c3df875cde7ccd9920f5580122929aedaf440bfe4484405'

const recipientOverlay = '1e2054bec3e681aeb0b365a1f9a574a03782176bd3ec0bcf810ebcaf551e4070'
Expand Down
6 changes: 3 additions & 3 deletions docs/documentation/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ Each `bee-js` method corresponds to a particular endpoint from the API. The char
| `getLastChequesForPeer` | `GET /chequebook/cheque/:peer` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1cheque~1%7Bpeer-id%7D/get) | ❌✅✅ |
| `getLastCashoutAction` | `GET /chequebook/cashout/:peer` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1cashout~1%7Bpeer-id%7D/get) | ❌✅✅ |
| `cashoutLastCheque` | `POST /chequebook/cashout/:peer` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1cashout~1%7Bpeer-id%7D/post) | ❌✅✅ |
| `depositTokens` | `POST /chequebook/deposit` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1deposit/post) | ❌✅✅ |
| `withdrawTokens` | `POST /chequebook/withdraw` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1withdraw/post) | ❌✅✅ |
| `depositBZZToChequebook` | `POST /chequebook/deposit` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1deposit/post) | ❌✅✅ |
| `withdrawBZZFromChequebook` | `POST /chequebook/withdraw` [🔗](https://docs.ethswarm.org/api/#tag/Chequebook/paths/~1chequebook~1withdraw/post) | ❌✅✅ |
| `getAllPendingTransactions` | `GET /transactions` [🔗](https://docs.ethswarm.org/api/#tag/Transaction/paths/~1transactions/get) | ❌✅✅ |
| `getPendingTransaction` | `GET /transactions/:id` [🔗](https://docs.ethswarm.org/api/#tag/Transaction/paths/~1transactions~1%7BtxHash%7D/get) | ❌✅✅ |
| `rebroadcastTransaction` | `POST /transactions/:id` [🔗](https://docs.ethswarm.org/api/#tag/Transaction/paths/~1transactions~1%7BtxHash%7D/post) | ❌✅✅ |
Expand All @@ -148,7 +148,7 @@ Each `bee-js` method corresponds to a particular endpoint from the API. The char
| `pssSend` | `POST /pss/send/:topic/:target` [🔗](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1send~1%7Btopic%7D~1%7Btargets%7D/post) | ❌✅✅ |
| `pssSubscribe` _Websocket_ | `GET /pss/subscribe/:topic` [🔗](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1subscribe~1%7Btopic%7D/get) | ❌❌✅ |
| `pssReceive` | `GET /pss/subscribe/:topic` [🔗](https://docs.ethswarm.org/api/#tag/Postal-Service-for-Swarm/paths/~1pss~1subscribe~1%7Btopic%7D/get) | ❌❌✅ |
| `getAllPostageBatch` | `GET /stamps` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps/get) | ❌✅✅ |
| `getPostageBatches` | `GET /stamps` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps/get) | ❌✅✅ |
| `getGlobalPostageBatches` | `GET /batches` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1batches/get) | ❌✅✅ |
| `getPostageBatch` | `GET /stamps/:batchId` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1%7Bbatch_id%7D/get) | ❌✅✅ |
| `getPostageBatchBuckets` | `GET /stamps/:batchId/buckets` [🔗](https://docs.ethswarm.org/api/#tag/Postage-Stamps/paths/~1stamps~1%7Bbatch_id%7D~1buckets/get) | ❌✅✅ |
Expand Down
1 change: 1 addition & 0 deletions docs/documentation/pss.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ console.log('Subscribing to topic:', topic.toHex())
bee.pssSubscribe(topic, {
onMessage: msg => console.log('Received via subscription:', msg.toUtf8()),
onError: err => console.error('Subscription error:', err.message),
onClose: () => console.log('Subscription closed.'),
})

// One-time receive (3 hour timeout)
Expand Down
14 changes: 7 additions & 7 deletions docs/documentation/soc-and-feeds.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ Interactions with SOC and feeds require the following:
You can use the `PrivateKey` class to generate a dedicated publisher key for signing SOC and feed updates:

```js
const crypto = require('crypto');
const { PrivateKey } = require('@ethersphere/bee-js');
import crypto from 'node:crypto'
import { PrivateKey } from '@ethersphere/bee-js'

// Generate 32 random bytes and construct a private key
const hexKey = '0x' + crypto.randomBytes(32).toString('hex');
const privateKey = new PrivateKey(hexKey);
const hexKey = '0x' + crypto.randomBytes(32).toString('hex')
const privateKey = new PrivateKey(hexKey)

console.log('Private key:', privateKey.toHex());
console.log('Public address:', privateKey.publicKey().address().toHex());
console.log('Private key:', privateKey.toHex())
console.log('Public address:', privateKey.publicKey().address().toHex())
````

Example output:
Expand Down Expand Up @@ -152,7 +152,7 @@ Unlike uploads using content addressed chunks which are retrieved by their Swarm
:::

```js
import { Bee, Size, NULL_IDENTIFIER } from "@ethersphere/bee-js"
import { Bee, NULL_IDENTIFIER } from "@ethersphere/bee-js"

// Initialize Bee client pointing to the Swarm node
const bee = new Bee('http://localhost:1633')
Expand Down