Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 6bfa4dd

Browse files
author
Alan Shaw
authored
docs: add code example for creating your own peer ID (#1770)
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
1 parent 483a0c8 commit 6bfa4dd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,14 @@ Instead of a boolean, you may provide an object with custom initialization optio
250250
- `emptyRepo` (boolean) Whether to remove built-in assets, like the instructional tour and empty mutable file system, from the repo. (Default: `false`)
251251
- `bits` (number) Number of bits to use in the generated key pair. (Default: `2048`)
252252
- `privateKey` (string/PeerId) A pre-generated private key to use. Can be either a base64 string or a [PeerId](https://github.com/libp2p/js-peer-id) instance. **NOTE: This overrides `bits`.**
253+
```js
254+
// Generating a Peer ID:
255+
const PeerId = require('peer-id')
256+
PeerId.create({ bits: 2048 }, (err, peerId) => {
257+
// Generates a new Peer ID, complete with public/private keypair
258+
// See https://github.com/libp2p/js-peer-id
259+
})
260+
```
253261
- `pass` (string) A passphrase to encrypt keys. You should generally use the [top-level `pass` option](#optionspass) instead of the `init.pass` option (this one will take its value from the top-level option if not set).
254262

255263
##### `options.start`

0 commit comments

Comments
 (0)