一键导入
swarm-act
Guide to Swarm ACT encryption and access control: create grantees, upload protected data, grant/revoke access, and troubleshoot not-found/history issues.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guide to Swarm ACT encryption and access control: create grantees, upload protected data, grant/revoke access, and troubleshoot not-found/history issues.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Install and run a Bee light node for Swarm development on Linux/macOS — system prerequisites (Node.js, curl), Bee and swarm-cli install, funding the node (gift code or xDAI/xBZZ on Gnosis Chain), upgrading ultra-light to light, and buying a first postage stamp. Use when the user has no node, gets connection-refused on localhost:1633, or needs to start or fund Bee.
Build and publish a Swarm blog with a permanent feed-manifest URL, post management workflow, and optional ENS domain mapping.
Scaffold a new Swarm dApp with create-swarm-app or add the bee-js SDK to an existing project (Node.js, TypeScript, or React/Vite). Covers connecting to Bee, upload/download patterns, auto-finding a postage stamp, and node-mode feature compatibility. Use when the user wants to start coding against Swarm or integrate bee-js into an app.
Answer Swarm conceptual questions from official docs with source links; use for APIs, behavior, configuration, and architecture clarifications.
Create and update feeds — a stable Swarm address (owner + topic) that always resolves to the latest content even as the underlying hash changes. Covers feed writers/readers, manifests for permanent URLs, and updates via bee-js or swarm-cli. Use for dynamic or updateable content: websites, blogs, app state, RSS/podcasts, social feeds.
Deploy a static website (a folder with index.html) to Swarm via swarm-cli or bee-js, as a one-time upload or an updateable feed, with optional ENS content-hash setup (eth.limo / bzz.link). Use when the user wants to publish, host, or update a site or single-page app on decentralized storage.
| name | swarm-act |
| description | Guide to Swarm ACT encryption and access control: create grantees, upload protected data, grant/revoke access, and troubleshoot not-found/history issues. |
Guide a developer through encrypting data on Swarm and controlling who can read it. ACT (Access Control Trie) lets you define per-account read permissions using Ethereum public keys.
When presenting to the user, use consistent labels before each code block:
filename: — file contents the user should write to diskAdd a --- horizontal rule before each labeled code block to visually separate it from surrounding text.
Run these checks now and narrate each one in a short line — say what you're checking, run it (don't paste the command), then report the result. Don't pause for confirmation; these are read-only checks.
Say "Checking your Bee node…", then run:
curl -s http://localhost:1633/status | jq .beeMode
Reachable → "✓ Node is up." | Fails → "✗ No Bee node running." and offer to walk through /swarm-setup-bee-interactive.
Say "Checking for a usable postage stamp…", then run:
curl -s http://localhost:1633/stamps | jq '.stamps[] | select(.usable==true) | {batchID, depth, batchTTL}'
Found → "✓ Found a usable stamp." and proceed. | None → "✗ No usable stamp." and route to /swarm-stamps.
npm install -g @ethersphere/swarm-clinpm install @ethersphere/bee-jsswarm-cli upload test.txt --act --stamp <BATCH_ID>
First upload — omit --act-history-address to create a new history. The response returns:
Warning: Save the history reference securely. Losing it means permanent, irrecoverable loss of access to your encrypted data. There is no recovery mechanism.
For subsequent uploads to the same history:
swarm-cli upload test.txt --act --stamp <BATCH_ID> --act-history-address <HISTORY_REF>
swarm-cli download <SWARM_HASH> output.txt \
--act \
--act-history-address <HISTORY_REF> \
--act-publisher <PUBLIC_KEY>
--act-publisher — the uploader's public key (needed for decryption). Get it from swarm-cli addresses → "Public Key:" field.--act-timestamp — optional, defaults to current time. Use to access a specific version.Without the ACT flags, the download will fail with "not found".
Create a JSON file with the public keys of accounts that should have access:
{
"grantees": [
"03ec55e9fb2aefb8600f69142abaad79311516c232b28919d66efb4d41bce15bfa",
"03fdcab22b455ce08a481d929a4cb9f447752545818eded1ad1785c51581e822c6"
]
}
swarm-cli grantee create grantees.json --stamp <BATCH_ID>
Returns a grantee reference and history reference — save both.
Create a patch JSON:
{
"add": ["03fdcab22b455ce08a481d929a4cb9f447752545818eded1ad1785c51581e822c6"],
"revoke": ["03ec55e9fb2aefb8600f69142abaad79311516c232b28919d66efb4d41bce15bfa"]
}
swarm-cli grantee patch grantees-patch.json \
--reference <GRANTEE_REF> \
--history <GRANTEE_HISTORY_REF> \
--stamp <BATCH_ID>
Note: Wait at least 1 second between grantee list updates — updating within the same second causes an error.
swarm-cli grantee get <GRANTEE_REF>
import { Bee } from '@ethersphere/bee-js'
const bee = new Bee('http://localhost:1633')
// Upload a file with ACT encryption enabled
const result = await bee.uploadFile(batchId, 'Secret data', 'secret.txt', {
act: true
})
const historyAddress = result.historyAddress.getOrThrow()
console.log('Encrypted reference:', result.reference.toHex())
console.log('History address:', historyAddress.toHex())
// WARNING: Save both — losing the history address means permanent loss of access to encrypted data
import { Bee } from '@ethersphere/bee-js'
const bee = new Bee('http://localhost:1633')
// Get the publisher's public key (share this with grantees):
const publisherAddresses = await bee.getNodeAddresses()
const publisherPublicKey = publisherAddresses.publicKey // not pssPublicKey
const file = await bee.downloadFile(encryptedReference, 'secret.txt', {
actHistoryAddress: historyAddress,
actPublisher: publisherPublicKey
})
console.log('Decrypted:', file.data.toUtf8())
// Without ACT parameters, this returns "not found"
swarm-cli quirk: in testing,
swarm-cli download <ref> --act --act-history-address <hist> --act-publisher <pk>can return 404 even with correct values, while the equivalent Bee HTTP API call (same headers) returns 200. If the CLI download fails, retry via the API or bee-js.
import { Bee } from '@ethersphere/bee-js'
const bee = new Bee('http://localhost:1633')
// Create grantee list
const granteeResult = await bee.createGrantees(batchId, [
'03ec55e9fb2aefb8600f69142abaad79311516c232b28919d66efb4d41bce15bfa'
])
const granteeReference = granteeResult.ref
const historyReference = granteeResult.historyref
console.log('Grantee ref:', granteeReference.toHex())
console.log('History ref:', historyReference.toHex())
// Get current grantees
const granteesResult = await bee.getGrantees(granteeReference)
console.log('Grantees:', granteesResult.grantees.map(k => k.toCompressedHex()))
// Update access — add and revoke
await bee.patchGrantees(batchId, granteeReference, historyReference, {
add: ['03fdcab22b455ce08a481d929a4cb9f447752545818eded1ad1785c51581e822c6'],
revoke: ['03ec55e9fb2aefb8600f69142abaad79311516c232b28919d66efb4d41bce15bfa']
})
| Error | Fix |
|---|---|
| "not found" on download | Missing ACT flags, wrong history address, or access revoked |
| "act: invalid history" | Wrong history address — double-check reference |
| "stamp not usable" | Wait 2-3 minutes after buying |
| 1-second update error | Wait at least 1 second between grantee list updates |
| Other errors | Route to /swarm-troubleshoot |
For any conceptual or technical question not covered by the steps above, invoke /swarm-docs to find the relevant authoritative source rather than answering from prior knowledge.