.. and press ENTER to ask a question on web5, how to write code and more.

Skip to main content

Web5 CLI

The Web5 CLI is a Rust-based command-line tool for creating and managing Decentralized Identifiers (DIDs) and Verifiable Credentials (VCs).

This guide covers CLI installation and usage for DID and VC management.

note

Alternatively, you can use the Web5 SDK to create DIDs and VCs.

Installation​

To install the Web5 CLI, run:

curl -L https://raw.githubusercontent.com/TBD54566975/web5-rs/main/crates/web5_cli/install.sh | bash -s v0.0.4

Create a DID​

The web5 did create command creates a DID using one of the supported DID methods listed below.

web5 did create <method> [options]

Supported DID methods

Options

  • --no-indent: Output the DID document without indentation.
  • --json-escape: Escape JSON strings in the output.
  • --domain <domain>: For did:web, specify the domain for the DID Web creation.
  • --no-publish: Prevents immediately publishing for did:dht.

Examples

# Create a did:dht without publishing
web5 did create dht --no-publish

# Create a did:jwk with no indent and json escape
web5 did create jwk --no-indent --json-escape

# Create a did:web
web5 did create web --domain https://example.com

Resolve a DID​

The web5 did resolve command resolves a DID to retrieve its DID Document

web5 did resolve <did-uri> [options]

Options

  • --no-indent: Output the DID document without indentation.
  • --json-escape: Escape JSON strings in the output.

Example

web5 did resolve did:dht:bwrh9fphhegh1jn3hhe656zuyfxqdm493so5r4hmpte1yf456w5o

Create a VC​

The web5 vc create command creates a VC. By default, this command creates an unsigned VC in JSON format. If a Portable DID is provided, this command outputs a signed VC in JWT format.

web5 vc create <credential-subject-did-uri> [options]

Options

  • --portable-did <did>: Specifies the DID used to sign the VC. If included, the Portable DID's URI is automatically set as the issuer.
  • --issuer <issuer-did-uri>: Specifies the issuer of the credential.
  • --expiration-date <date>: Set an expiration date for the credential in YYYY-MM-DD format.
  • --no-indent: Output the VC without indentation.
  • --json-escape: Escape JSON strings in the output.

Examples

# Create an unsigned VC with an issuer
web5 vc create did:dht:kfnps1cwyt6dmb5g1q8z9xncx4nmepz4pn6cqck3jswhpg9bp4qo --issuer did:dht:p364ofunt9wu6u8jrt44ka6uz588iuefbnwjhxgbm8fjbmki4fco

# Portable DID that will be used as the issuer and to sign the credential
export PORTABLE_DID=$(web5 did create dht --no-indent)

# Create and sign VC with portable DID
web5 vc create "did:dht:cm1yqfjzfdtauh33nauwf3sqsijqziwrydicr8dbtho3cucb9nno" --portable-did $PORTABLE_DID

# Create and sign VC with an expiration date
web5 vc create "did:dht:cm1yqfjzfdtauh33nauwf3sqsijqziwrydicr8dbtho3cucb9nno" --portable-did $PORTABLE_DID --expiration-date 2025-12-31

Verify a VC​

The web5 vc verify command verifies a VC that is in JWT format.

web5 vc verify <vc-jwt> [options]

Options

  • --no-indent: Outputs the verification result without indentation.
  • --json-escape: Escapes JSON strings in the output.

Example

web5 vc verify eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSIsImtpZCI6ImRpZDpkaHQ6aG84c25hejVkdWpkaXJmNnVja3JuZ3JrcGZpYmoxNHh3enlkNnlpYXRxemU3Z2F4enQ4byMwIn0.eyJ2YyI6eyJAY29udGV4dCI6WyJodHRwczovL3d3dy53My5vcmcvMjAxOC9jcmVkZW50aWFscy92MSJdLCJpZCI6InVybjp2Yzp1dWlkOmJjYWM1MTIxLTg1NzEtNGJjMi04ZjM4LTRjYzVhNmVmYWJjNSIsInR5cGUiOlsiVmVyaWZpYWJsZUNyZWRlbnRpYWwiXSwiaXNzdWVyIjoiZGlkOmRodDpobzhzbmF6NWR1amRpcmY2dWNrcm5ncmtwZmliajE0eHd6eWQ2eWlhdHF6ZTdnYXh6dDhvIiwiaXNzdWFuY2VEYXRlIjoiMjAyNC0wOS0wNVQwMzowMTowNC40NTkwMjArMDA6MDAiLCJleHBpcmF0aW9uRGF0ZSI6bnVsbCwiY3JlZGVudGlhbFN1YmplY3QiOnsiaWQiOiJkaWQ6ZGh0OmNtMXlxZmp6ZmR0YXVoMzNuYXV3ZjNzcXNpanF6aXdyeWRpY3I4ZGJ0aG8zY3VjYjlubm8ifX0sImlzcyI6ImRpZDpkaHQ6aG84c25hejVkdWpkaXJmNnVja3JuZ3JrcGZpYmoxNHh3enlkNnlpYXRxemU3Z2F4enQ4byIsImp0aSI6InVybjp2Yzp1dWlkOmJjYWM1MTIxLTg1NzEtNGJjMi04ZjM4LTRjYzVhNmVmYWJjNSIsInN1YiI6ImRpZDpkaHQ6Y20xeXFmanpmZHRhdWgzM25hdXdmM3Nxc2lqcXppd3J5ZGljcjhkYnRobzNjdWNiOW5ubyIsIm5iZiI6MTcyNTUwNTI2NCwiaWF0IjoxNzI1NTA1MjY0fQ.velYj8w3gTagMtsRUIDZa88RoaLF8xV1S9f2xsaiWn_CX4zuVfZD6H3rNTXXxIP9WmhhzkXVyfScwubon9AXBw

Connect with us on Discord

Submit feedback: Open a GitHub issue

Edit this page: GitHub Repo

Contribute: Contributing Guide