w3cli
w3cli copied to clipboard
๐พ w3 command line interface
w3cli
๐พ the w3 command line interface.
Getting started
Install the CLI from npm (requires Node 18 or higher):
npm install -g @web3-storage/w3cli
Login with this agent to act on behalf of the account associated with your email address:
w3 login [email protected]
Create a new Space for storing your data and register it:
w3 space create Documents # pick a good name!
If you'd like to learn more about what is going on under the hood with w3up and its use of Spaces, UCANs, and more, check out the w3up-client README here.
Upload a file or directory:
w3 up recipies.txt
โ ๏ธโ Public Data ๐: All data uploaded to w3up is available to anyone who requests it using the correct CID. Do not store any private or sensitive information in an unencrypted form using w3up.
โ ๏ธโ Permanent Data โพ๏ธ: Removing files from w3up will remove them from the file listing for your account, but that doesnโt prevent nodes on the decentralized storage network from retaining copies of the data indefinitely. Do not use w3up for data that may need to be permanently deleted in the future.
Commands
- Basics
w3 loginw3 upw3 lsw3 rmw3 openw3 whoami
- Space management
w3 space addw3 space createw3 space lsw3 space usew3 space info
- Capability management
w3 delegation createw3 delegation lsw3 delegation revokew3 proof addw3 proof ls
- Key management
w3 key create
- UCAN-HTTP Bridge
w3 bridge generate-tokens
- Advanced usage
w3 can space infocoming soon!w3 can space recovercoming soon!w3 can store addw3 can store lsw3 can store rmw3 can upload addw3 can upload lsw3 can upload rm
w3 login <email>
Authenticate this agent with your email address to get access to all capabilities that had been delegated to it.
w3 up <path> [path...]
Upload file(s) to web3.storage. The IPFS Content ID (CID) for your files is calculated on your machine, and sent up along with your files. web3.storage makes your content available on the IPFS network
--no-wrapDon't wrap input files with a directory.-H, --hiddenInclude paths that start with ".".-c, --carFile is a CAR file.--shard-sizeShard uploads into CAR files of approximately this size in bytes.--concurrent-requestsSend up to this many CAR shards concurrently.
w3 ls
List all the uploads registered in the current space.
--jsonFormat as newline delimited JSON--shardsPretty print with shards in output
w3 rm <root-cid>
Remove an upload from the uploads listing. Note that this command does not remove the data from the IPFS network, nor does it remove it from space storage (by default).
--shardsAlso remove all shards referenced by the upload from the store. Use with caution and ensure other uploads do not reference the same shards.
w3 open <cid>
Open a CID on https://w3s.link in your browser. You can also pass a CID and a path.
# opens a browser to https://w3s.link/ipfs/bafybeidluj5ub7okodgg5v6l4x3nytpivvcouuxgzuioa6vodg3xt2uqle
w3 open bafybeidluj5ub7okodgg5v6l4x3nytpivvcouuxgzuioa6vodg3xt2uqle
# opens a browser to https://w3s.link/ipfs/bafybeidluj5ub7okodgg5v6l4x3nytpivvcouuxgzuioa6vodg3xt2uqle/olizilla.png
w3 open bafybeidluj5ub7okodgg5v6l4x3nytpivvcouuxgzuioa6vodg3xt2uqle/olizilla.png
w3 whoami
Print information about the current agent.
w3 space add <proof>
Add a space to the agent. The proof is a CAR encoded UCAN delegating capabilities over a space to this agent.
proof is a filesystem path to a CAR encoded UCAN, as generated by w3 delegation create or a base64 identity CID string as created by w3 delegation create --base64.
w3 space create [name]
Create a new w3 space with an optional name.
w3 space ls
List spaces known to the agent.
w3 space use <did>
Set the current space in use by the agent.
w3 space info
Get information about a space (by default the current space) from the service, including which providers the space is currently registered with.
--spaceThe space to get information about. Defaults to the current space.--jsonFormat as newline delimited JSON
w3 delegation create <audience-did>
Create a delegation to the passed audience for the given abilities with the current space as the resource.
--canA capability to delegate. To specify more than one capability, use this option more than once.--nameHuman readable name for the audience receiving the delegation.--typeType of the audience receiving the delegation, one of: device, app, service.--outputPath of file to write the exported delegation data to.--base64Format as base64 identity CID string. Useful when saving it as an environment variable.
# delegate space/info to did:key:z6M..., output as a CAR
w3 delegation create did:key:z6M... --can space/info --output ./info.ucan
# delegate store/* and upload/* to did:key:z6M..., output as a string
w3 delegation create did:key:z6M... --can 'store/*' --can 'upload/*' --base64
w3 delegation ls
List delegations created by this agent for others.
--jsonFormat as newline delimited JSON
w3 delegation revoke <delegation-cid>
Revoke a delegation by CID.
--proofName of a file containing the delegation and any additional proofs needed to prove authority to revoke
w3 proof add <proof.ucan>
Add a proof delegated to this agent. The proof is a CAR encoded delegation to this agent. Note: you probably want to use w3 space add unless you know the delegation you received targets a resource other than a w3 space.
w3 proof ls
List proofs of delegated capabilities. Proofs are delegations with an audience matching the agent DID.
--jsonFormat as newline delimited JSON
w3 key create
Print a new key pair. Does not change your current signing key
--jsonExport as dag-json
w3 bridge generate-tokens
Generate tokens that can be used as the X-Auth-Secret and Authorization headers required to use the UCAN-HTTP bridge.
See the UCAN Bridge specification for more information on how these are expected to be used.
--canOne or more abilities to delegate.--expirationUnix timestamp (in seconds) when the delegation is no longer valid. Zero indicates no expiration.--jsonIf set, output JSON suitable to splat into theheadersfield of afetchrequest.
w3 can space info <did>
w3 can space recover <email>
w3 can store add <car-path>
Store a CAR file to web3.storage.
w3 can store ls
List CARs in the current space.
--jsonFormat as newline delimited JSON--sizeThe desired number of results to return--cursorAn opaque string included in a prior upload/list response that allows the service to provide the next "page" of results--preIf true, return the page of results preceding the cursor
w3 can store rm <shard-cid>
Remove a CAR from the store.
w3 can upload add <root-cid> <shard-cid> [shard-cid...]
Register an upload - a DAG with the given root data CID that is stored in the given CAR shard(s), identified by CAR CIDs.
w3 can upload ls
List uploads in the current space.
--jsonFormat as newline delimited JSON--shardsPretty print with shards in output--sizeThe desired number of results to return--cursorAn opaque string included in a prior upload/list response that allows the service to provide the next "page" of results--preIf true, return the page of results preceding the cursor
w3 can upload rm <root-cid>
Remove an upload from the current space's upload list. Does not remove CAR from the store.
Environment Variables
W3_PRINCIPAL
Set the key w3 should use to sign ucan invocations. By default w3 will generate a new Ed25519 key on first run and store it. Set it along with a custom W3_STORE_NAME to manage multiple custom keys and profiles. Trying to use an existing store with different keys will fail.
You can generate Ed25519 keys with ucan-key e.g. npx ucan-key ed
Usage
W3_PRINCIPAL=$(npx ucan-key ed --json | jq -r .key) W3_STORE_NAME="other" w3 whoami
did:key:z6Mkf7bvSNgoXk67Ubhie8QMurN9E4yaCCGBzXow78zxnmuB
Default unset, a random Ed25519 key is generated.
W3_STORE_NAME
Allows you to use w3 with different profiles. You could use it to log in with different emails and keep the delegations separate.
w3 stores state to disk using the conf module. W3_STORE_NAME sets the conf configName option.
Default w3cli
W3UP_SERVICE_URL
w3 will use the w3up service at https://up.web3.storage. If you would like
to use a different w3up-compatible service, set W3UP_SERVICE_DID and W3UP_SERVICE_URL environment variables to set the service DID and URL endpoint.
Default https://up.web3.storage
W3UP_SERVICE_DID
w3 will use the w3up did:web:web3.storage as the service did. If you would like
to use a different w3up-compatible service, set W3UP_SERVICE_DID and W3UP_SERVICE_URL environment variables to set the service DID and URL endpoint.
Default did:web:web3.storage
FAQ
Where are my keys and delegations stored?
In the system default user config directory:
- macOS:
~/Library/Preferences/w3access - Windows:
%APPDATA%\w3access\Config(for example,C:\Users\USERNAME\AppData\Roaming\w3access\Config) - Linux:
~/.config/w3access(or$XDG_CONFIG_HOME/w3access)
Contributing
Feel free to join in. All welcome. Please read our contributing guidelines and/or open an issue!
License
Dual-licensed under MIT + Apache 2.0