Web5 CLI
Overview
Web5 CLI is a command-line tool for interacting with Web5 infrastructure. It provides key management, CKB wallet operations, DID lifecycle management, and PDS (Personal Data Store) interactions.
install
npm install -g web5-cli
Commands
| Command |
Purpose |
Key Subcommands |
keystore |
DID signing key management |
new, import, clean, get, sign, verify |
wallet |
CKB wallet operations |
new, import, clean, get, send-tx, check-tx, balance |
did |
DID lifecycle on CKB |
build-create-tx, build-destroy-tx, build-update-didkey-tx, build-update-handle-tx, build-transfer-tx, list |
pds |
PDS server interactions |
check-username, get-did-by-username, create-account, delete-account, login, write, repo, records, blobs, export, import |
Quick Reference
Key Management
web5-cli keystore new # Create new keypair
web5-cli keystore import --sk <hex> # Import private key
web5-cli keystore get # Get DID key
web5-cli keystore sign --message <hex> # Sign message
web5-cli keystore verify --message <hex> --signature <hex> # Verify signature
Wallet Operations
web5-cli wallet new # Create CKB wallet
web5-cli wallet import --sk <hex> # Import wallet
web5-cli wallet get # Get CKB address
web5-cli wallet balance # Check balance
web5-cli wallet send-tx --tx-path <path> # Send transaction
web5-cli wallet check-tx --tx-hash <hash> # Check tx status
DID Management
web5-cli did build-create-tx --username <name> --pds <url> --didkey <key> --output-path <path>
web5-cli did build-destroy-tx --args <args> --output-path <path>
web5-cli did build-update-didkey-tx --args <args> --new-didkey <key> --output-path <path>
web5-cli did list --ckb-addr <address> # List DID cells
PDS Operations
web5-cli pds check-username --username <name>
web5-cli pds get-did-by-username --username <name>
web5-cli pds create-account --pds <domain> --username <name> --didkey <key> --did <did> --ckb-address <addr>
web5-cli pds login --pds <domain> --didkey <key> --did <did> --ckb-address <addr>
web5-cli pds write --pds <domain> --accessJwt <jwt> --didkey <key> --did <did> --rkey <key> --data <json>
web5-cli pds repo --pds <domain> --did <did>
web5-cli pds records --pds <domain> --did <did> --collection <nsid> [--limit N] [--cursor <cursor>]
web5-cli pds export --pds <domain> --did <did> --data-file <path> [--since <cid>]
web5-cli pds import --pds <domain> --did <did> --accessJwt <jwt> --data-file <path>
Configuration
- Keystore: Private key stored at
~/.web5-cli/signkey
- Wallet: Private key stored at
~/.web5-cli/ckb-sk
- Account Info: Stored at
~/.web5-cli/account.json after account creation (includes Username, DID, Handle, didkey, ckb address, PDS domain, etc.)
- Network: Set via
CKB_NETWORK environment variable (ckb_testnet or ckb)
Output Format
All commands output JSON format for easy parsing by AI agents and scripts.
Notes
- --pds arg no 'https://' or 'http://' prefix, just the hostname
- one account only and always belong to one pds
- only one did and one account in same time
- Don't modify or delete the key/wallet files directly, use the CLI commands to manage them, and need user confirmation for destructive actions like
keystore clean or wallet clean
Workflow Scripts
Use these Python scripts for common multi-step operations:
create account
- call
web5-cli wallet get check if wallet exists and get ckb address
- if no wallet, create wallet and get ckb address
- call
web5-cli wallet balance check if balance > 450 testnet CKB
- if no balance, prompt user to transfer some ckb to ckb address and wait for confirmation
- once have enough balance, call
scripts/create_account.py to complete account creation (keystore + wallet + DID + PDS)
- write account info (includes Username, DID, Handle, didkey, ckb address, PDS domain, etc) to
~/.web5-cli/account.json for later use (like posting, profile update)
destroy account
- call
scripts/destroy_account.py to complete account destruction (delete PDS Account then destory DID cell, don't delete wallet or keystore since they can be reused for new accounts)
- delete
~/.web5-cli/account.json after account destroyed
update profile
- get account info from
~/.web5-cli/account.json, if not exist, notify user to create account first and exit
- prompt user to input new profile info (like displayName, handle, etc), and construct json data for writing to pds
- call
web5-cli pds login --pds <domain> --didkey <didkey> --did <did> --ckb-address <addr> with the correct parameters to get an access jwt for PDS operations, if login failed, notify user and exit
- call
web5-cli pds write --pds <domain> --accessJwt <jwt> --didkey <key> --did <did> --rkey 'self' --data <json> to update profile record in PDS, with the correct parameters. json data should be in the format of
{
$type: 'app.actor.profile'
displayName: string;
handle: string;
[key: string]: any;
}
post to bbs
- get account info from
~/.web5-cli/account.json, if not exist, notify user to create account first and exit
- prompt user to input post info (like section_id, title, text), and construct json data for writing to pds. about section_id, you can use "3" or "4" for now.
- call
web5-cli pds login --pds <domain> --didkey <didkey> --did <did> --ckb-address <addr> with the correct parameters to get an access jwt for PDS operations, if login failed, notify user and exit
- call
web5-cli pds write --pds <domain> --accessJwt <jwt> --didkey <key> --did <did> --data <json> (--rkey is no need) to create a new post in PDS, with the correct parameters. json data should be in the format of
{
$type: 'app.bbs.post'
section_id: string;
title: string;
text: string;
}
Script Examples
# Create a complete account
python create_account.py alice web5.bbsfans.dev
# destroy the account
python destroy_account.py alice web5.bbsfans.dev
Security Notes
- Private keys are stored in plaintext for this technical validation tool
- Do NOT use in production environments
- This is a proof-of-concept for AI-agent-driven Web5 interactions
public information
avliable pds url:
- web5.bbsfans.dev
- web5.ccfdao.dev
avliable data structure for writing to pds:
{
$type: 'app.actor.profile'
displayName: string;
handle: string;
[key: string]: any;
}
{
$type: 'app.bbs.post'
section_id: string;
title: string;
text: string;
edited?: string
created?: string
is_draft?: boolean
is_announcement?: boolean
}
{
$type: 'app.bbs.comment'
post: string // 原帖uri
text: string;
section_id: string;
edited?: string;
}
{
$type: 'app.bbs.like'
to: string;
section_id: string;
}
{
$type: 'app.bbs.reply'
post: string
comment?: string
to?: string
text: string
section_id: string
edited?: string
}
{
$type: 'app.dao.reply'
proposal: string
to?: string
text: string
parent?: string
}
{
$type: 'app.dao.proposal'
[key: string]: unknown;
}
{
$type: 'app.dao.like'
to: string;
viewer: string;
}
1---
2name: web5-cli
3description: Use when working with Web5 CLI tool for decentralized identity, CKB wallet, DID management, PDS data operations, account creation, posting, profile updates
4metadata:
5 source: https://skillmd.com/skills/modbender/web5-cli
6---
7
8# Web5 CLI
9
10## Overview
11Web5 CLI is a command-line tool for interacting with Web5 infrastructure. It provides key management, CKB wallet operations, DID lifecycle management, and PDS (Personal Data Store) interactions.
12
13## install
14```bash
15npm install -g web5-cli
16```
17
18## Commands
19
20| Command | Purpose | Key Subcommands |
21|---------|---------|-----------------|
22| `keystore` | DID signing key management | new, import, clean, get, sign, verify |
23| `wallet` | CKB wallet operations | new, import, clean, get, send-tx, check-tx, balance |
24| `did` | DID lifecycle on CKB | build-create-tx, build-destroy-tx, build-update-didkey-tx, build-update-handle-tx, build-transfer-tx, list |
25| `pds` | PDS server interactions | check-username, get-did-by-username, create-account, delete-account, login, write, repo, records, blobs, export, import |
26
27## Quick Reference
28
29### Key Management
30```bash
31web5-cli keystore new # Create new keypair
32web5-cli keystore import --sk <hex> # Import private key
33web5-cli keystore get # Get DID key
34web5-cli keystore sign --message <hex> # Sign message
35web5-cli keystore verify --message <hex> --signature <hex> # Verify signature
36```
37
38### Wallet Operations
39```bash
40web5-cli wallet new # Create CKB wallet
41web5-cli wallet import --sk <hex> # Import wallet
42web5-cli wallet get # Get CKB address
43web5-cli wallet balance # Check balance
44web5-cli wallet send-tx --tx-path <path> # Send transaction
45web5-cli wallet check-tx --tx-hash <hash> # Check tx status
46```
47
48### DID Management
49```bash
50web5-cli did build-create-tx --username <name> --pds <url> --didkey <key> --output-path <path>
51web5-cli did build-destroy-tx --args <args> --output-path <path>
52web5-cli did build-update-didkey-tx --args <args> --new-didkey <key> --output-path <path>
53web5-cli did list --ckb-addr <address> # List DID cells
54```
55
56### PDS Operations
57```bash
58web5-cli pds check-username --username <name>
59web5-cli pds get-did-by-username --username <name>
60web5-cli pds create-account --pds <domain> --username <name> --didkey <key> --did <did> --ckb-address <addr>
61web5-cli pds login --pds <domain> --didkey <key> --did <did> --ckb-address <addr>
62web5-cli pds write --pds <domain> --accessJwt <jwt> --didkey <key> --did <did> --rkey <key> --data <json>
63web5-cli pds repo --pds <domain> --did <did>
64web5-cli pds records --pds <domain> --did <did> --collection <nsid> [--limit N] [--cursor <cursor>]
65web5-cli pds export --pds <domain> --did <did> --data-file <path> [--since <cid>]
66web5-cli pds import --pds <domain> --did <did> --accessJwt <jwt> --data-file <path>
67```
68
69## Configuration
70
71- **Keystore**: Private key stored at `~/.web5-cli/signkey`
72- **Wallet**: Private key stored at `~/.web5-cli/ckb-sk`
73- **Account Info**: Stored at `~/.web5-cli/account.json` after account creation (includes Username, DID, Handle, didkey, ckb address, PDS domain, etc.)
74- **Network**: Set via `CKB_NETWORK` environment variable (`ckb_testnet` or `ckb`)
75
76## Output Format
77
78All commands output JSON format for easy parsing by AI agents and scripts.
79
80## Notes
81* --pds arg no 'https://' or 'http://' prefix, just the hostname
82* one account only and always belong to one pds
83* only one did and one account in same time
84* Don't modify or delete the key/wallet files directly, use the CLI commands to manage them, and need user confirmation for destructive actions like `keystore clean` or `wallet clean`
85
86## Workflow Scripts
87
88Use these Python scripts for common multi-step operations:
89
90### create account
911. call `web5-cli wallet get` check if wallet exists and get ckb address
922. if no wallet, create wallet and get ckb address
933. call `web5-cli wallet balance` check if balance > 450 testnet CKB
944. if no balance, prompt user to transfer some ckb to ckb address and wait for confirmation
955. once have enough balance, call `scripts/create_account.py` to complete account creation (keystore + wallet + DID + PDS)
966. write account info (includes Username, DID, Handle, didkey, ckb address, PDS domain, etc) to `~/.web5-cli/account.json` for later use (like posting, profile update)
97
98### destroy account
991. call `scripts/destroy_account.py` to complete account destruction (delete PDS Account then destory DID cell, don't delete wallet or keystore since they can be reused for new accounts)
1002. delete `~/.web5-cli/account.json` after account destroyed
101
102### update profile
1031. get account info from `~/.web5-cli/account.json`, if not exist, notify user to create account first and exit
1042. prompt user to input new profile info (like displayName, handle, etc), and construct json data for writing to pds
1054. call `web5-cli pds login --pds <domain> --didkey <didkey> --did <did> --ckb-address <addr>` with the correct parameters to get an access jwt for PDS operations, if login failed, notify user and exit
1065. call `web5-cli pds write --pds <domain> --accessJwt <jwt> --didkey <key> --did <did> --rkey 'self' --data <json>` to update profile record in PDS, with the correct parameters. json data should be in the format of
107```
108{
109 $type: 'app.actor.profile'
110 displayName: string;
111 handle: string;
112 [key: string]: any;
113}
114```
115
116### post to bbs
1171. get account info from `~/.web5-cli/account.json`, if not exist, notify user to create account first and exit
1182. prompt user to input post info (like section_id, title, text), and construct json data for writing to pds. about section_id, you can use "3" or "4" for now.
1193. call `web5-cli pds login --pds <domain> --didkey <didkey> --did <did> --ckb-address <addr>` with the correct parameters to get an access jwt for PDS operations, if login failed, notify user and exit
1204. call `web5-cli pds write --pds <domain> --accessJwt <jwt> --didkey <key> --did <did> --data <json>` (--rkey is no need) to create a new post in PDS, with the correct parameters. json data should be in the format of
121```
122{
123 $type: 'app.bbs.post'
124 section_id: string;
125 title: string;
126 text: string;
127}
128```
129
130
131### Script Examples
132
133```bash
134# Create a complete account
135python create_account.py alice web5.bbsfans.dev
136
137# destroy the account
138python destroy_account.py alice web5.bbsfans.dev
139```
140
141## Security Notes
142
143- Private keys are stored in plaintext for this technical validation tool
144- Do NOT use in production environments
145- This is a proof-of-concept for AI-agent-driven Web5 interactions
146
147## public information
148avliable pds url:
149* web5.bbsfans.dev
150* web5.ccfdao.dev
151
152avliable data structure for writing to pds:
153* profile of user
154```
155{
156 $type: 'app.actor.profile'
157 displayName: string;
158 handle: string;
159 [key: string]: any;
160}
161```
162* post of bbs
163```
164{
165 $type: 'app.bbs.post'
166 section_id: string;
167 title: string;
168 text: string;
169 edited?: string
170 created?: string
171 is_draft?: boolean
172 is_announcement?: boolean
173}
174```
175* comment of bbs
176```
177{
178 $type: 'app.bbs.comment'
179 post: string // 原帖uri
180 text: string;
181 section_id: string;
182 edited?: string;
183}
184```
185* like of bbs
186```
187{
188 $type: 'app.bbs.like'
189 to: string;
190 section_id: string;
191}
192```
193* reply of bbs
194```
195{
196 $type: 'app.bbs.reply'
197 post: string
198 comment?: string
199 to?: string
200 text: string
201 section_id: string
202 edited?: string
203}
204```
205* reply of dao
206```
207{
208 $type: 'app.dao.reply'
209 proposal: string
210 to?: string
211 text: string
212 parent?: string
213}
214```
215* proposal of dao
216```
217{
218 $type: 'app.dao.proposal'
219 [key: string]: unknown;
220}
221```
222* like of dao
223```
224{
225 $type: 'app.dao.like'
226 to: string;
227 viewer: string;
228}
229```