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-cli3description: Use when working with Web5 CLI tool for decentralized identity, CKB wallet, DID management, PDS data operations, account creation, posting, profile updates4---56# Web5 CLI78## Overview9Web5 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.1011## install12```bash13npm install -g web5-cli14```1516## Commands1718| Command | Purpose | Key Subcommands |19|---------|---------|-----------------|20| `keystore` | DID signing key management | new, import, clean, get, sign, verify |21| `wallet` | CKB wallet operations | new, import, clean, get, send-tx, check-tx, balance |22| `did` | DID lifecycle on CKB | build-create-tx, build-destroy-tx, build-update-didkey-tx, build-update-handle-tx, build-transfer-tx, list |23| `pds` | PDS server interactions | check-username, get-did-by-username, create-account, delete-account, login, write, repo, records, blobs, export, import |2425## Quick Reference2627### Key Management28```bash29web5-cli keystore new # Create new keypair30web5-cli keystore import --sk <hex> # Import private key31web5-cli keystore get # Get DID key32web5-cli keystore sign --message <hex> # Sign message33web5-cli keystore verify --message <hex> --signature <hex> # Verify signature34```3536### Wallet Operations37```bash38web5-cli wallet new # Create CKB wallet39web5-cli wallet import --sk <hex> # Import wallet40web5-cli wallet get # Get CKB address41web5-cli wallet balance # Check balance42web5-cli wallet send-tx --tx-path <path> # Send transaction43web5-cli wallet check-tx --tx-hash <hash> # Check tx status44```4546### DID Management47```bash48web5-cli did build-create-tx --username <name> --pds <url> --didkey <key> --output-path <path>49web5-cli did build-destroy-tx --args <args> --output-path <path>50web5-cli did build-update-didkey-tx --args <args> --new-didkey <key> --output-path <path>51web5-cli did list --ckb-addr <address> # List DID cells52```5354### PDS Operations55```bash56web5-cli pds check-username --username <name>57web5-cli pds get-did-by-username --username <name>58web5-cli pds create-account --pds <domain> --username <name> --didkey <key> --did <did> --ckb-address <addr>59web5-cli pds login --pds <domain> --didkey <key> --did <did> --ckb-address <addr>60web5-cli pds write --pds <domain> --accessJwt <jwt> --didkey <key> --did <did> --rkey <key> --data <json>61web5-cli pds repo --pds <domain> --did <did>62web5-cli pds records --pds <domain> --did <did> --collection <nsid> [--limit N] [--cursor <cursor>]63web5-cli pds export --pds <domain> --did <did> --data-file <path> [--since <cid>]64web5-cli pds import --pds <domain> --did <did> --accessJwt <jwt> --data-file <path>65```6667## Configuration6869- **Keystore**: Private key stored at `~/.web5-cli/signkey`70- **Wallet**: Private key stored at `~/.web5-cli/ckb-sk`71- **Account Info**: Stored at `~/.web5-cli/account.json` after account creation (includes Username, DID, Handle, didkey, ckb address, PDS domain, etc.)72- **Network**: Set via `CKB_NETWORK` environment variable (`ckb_testnet` or `ckb`)7374## Output Format7576All commands output JSON format for easy parsing by AI agents and scripts.7778## Notes79* --pds arg no 'https://' or 'http://' prefix, just the hostname80* one account only and always belong to one pds81* only one did and one account in same time82* 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`8384## Workflow Scripts8586Use these Python scripts for common multi-step operations:8788### create account 891. call `web5-cli wallet get` check if wallet exists and get ckb address902. if no wallet, create wallet and get ckb address913. call `web5-cli wallet balance` check if balance > 450 testnet CKB924. if no balance, prompt user to transfer some ckb to ckb address and wait for confirmation935. once have enough balance, call `scripts/create_account.py` to complete account creation (keystore + wallet + DID + PDS)946. 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)9596### destroy account971. 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)982. delete `~/.web5-cli/account.json` after account destroyed99100### update profile1011. get account info from `~/.web5-cli/account.json`, if not exist, notify user to create account first and exit1022. prompt user to input new profile info (like displayName, handle, etc), and construct json data for writing to pds1034. 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 exit1045. 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 105```106{107 $type: 'app.actor.profile'108 displayName: string;109 handle: string;110 [key: string]: any;111}112```113114### post to bbs1151. get account info from `~/.web5-cli/account.json`, if not exist, notify user to create account first and exit1162. 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. 1173. 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 exit1184. 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 119```120{121 $type: 'app.bbs.post'122 section_id: string;123 title: string;124 text: string;125}126```127128129### Script Examples130131```bash132# Create a complete account133python create_account.py alice web5.bbsfans.dev134135# destroy the account136python destroy_account.py alice web5.bbsfans.dev137```138139## Security Notes140141- Private keys are stored in plaintext for this technical validation tool142- Do NOT use in production environments143- This is a proof-of-concept for AI-agent-driven Web5 interactions144145## public information146avliable pds url:147* web5.bbsfans.dev148* web5.ccfdao.dev149150avliable data structure for writing to pds:151* profile of user152```153{154 $type: 'app.actor.profile'155 displayName: string;156 handle: string;157 [key: string]: any;158}159```160* post of bbs161```162{163 $type: 'app.bbs.post'164 section_id: string;165 title: string;166 text: string;167 edited?: string168 created?: string169 is_draft?: boolean170 is_announcement?: boolean171}172```173* comment of bbs174```175{176 $type: 'app.bbs.comment'177 post: string // 原帖uri178 text: string;179 section_id: string;180 edited?: string;181}182```183* like of bbs184```185{186 $type: 'app.bbs.like'187 to: string;188 section_id: string;189}190```191* reply of bbs192```193{194 $type: 'app.bbs.reply'195 post: string196 comment?: string197 to?: string198 text: string199 section_id: string200 edited?: string201}202```203* reply of dao204```205{206 $type: 'app.dao.reply'207 proposal: string208 to?: string209 text: string210 parent?: string211}212```213* proposal of dao214```215{216 $type: 'app.dao.proposal'217 [key: string]: unknown;218}219```220* like of dao221```222{223 $type: 'app.dao.like'224 to: string;225 viewer: string;226}227```