Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: docs/example #560

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
20 changes: 10 additions & 10 deletions packages/ipns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,18 @@ const helia = await createHelia()
const name = ipns(helia)

// create a public key to publish as an IPNS name
const keyInfo = await helia.libp2p.services.keychain.createKey('my-key')
const keyInfo = await helia.libp2p.services.keychain.createKey('my-key', 'Ed25519')
const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)

// store some data to publish
const fs = unixfs(helia)
const cid = await fs.add(Uint8Array.from([0, 1, 2, 3, 4]))
const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))

// publish the name
await name.publish(peerId, cid)

// resolve the name
const result = name.resolve(peerId)
const result = await name.resolve(peerId)

console.info(result.cid, result.path)
```
Expand All @@ -75,18 +75,18 @@ const helia = await createHelia()
const name = ipns(helia)

// create a public key to publish as an IPNS name
const keyInfo = await helia.libp2p.services.keychain.createKey('my-key')
const keyInfo = await helia.libp2p.services.keychain.createKey('my-key', 'Ed25519')
const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)

// store some data to publish
const fs = unixfs(helia)
const cid = await fs.add(Uint8Array.from([0, 1, 2, 3, 4]))
const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))

// publish the name
await name.publish(peerId, cid)

// create another public key to re-publish the original record
const recursiveKeyInfo = await helia.libp2p.services.keychain.createKey('my-recursive-key')
const recursiveKeyInfo = await helia.libp2p.services.keychain.createKey('my-recursive-key', 'Ed25519')
const recursivePeerId = await helia.libp2p.services.keychain.exportPeerId(recursiveKeyInfo.name)

// publish the recursive name
Expand All @@ -110,12 +110,12 @@ const helia = await createHelia()
const name = ipns(helia)

// create a public key to publish as an IPNS name
const keyInfo = await helia.libp2p.services.keychain.createKey('my-key')
const keyInfo = await helia.libp2p.services.keychain.createKey('my-key', 'Ed25519')
const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)

// store some data to publish
const fs = unixfs(helia)
const fileCid = await fs.add(Uint8Array.from([0, 1, 2, 3, 4]))
const fileCid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))

// store the file in a directory
const dirCid = await fs.mkdir()
Expand Down Expand Up @@ -166,12 +166,12 @@ const name = ipns(helia, {
})

// create a public key to publish as an IPNS name
const keyInfo = await helia.libp2p.services.keychain.createKey('my-key')
const keyInfo = await helia.libp2p.services.keychain.createKey('my-key', 'Ed25519')
const peerId = await helia.libp2p.services.keychain.exportPeerId(keyInfo.name)

// store some data to publish
const fs = unixfs(helia)
const cid = await fs.add(Uint8Array.from([0, 1, 2, 3, 4]))
const cid = await fs.addBytes(Uint8Array.from([0, 1, 2, 3, 4]))

// publish the name
await name.publish(peerId, cid)
Expand Down
Loading