init
The blocklet init command is an interactive utility that scaffolds a new Blocklet project in the current working directory. It walks you through a series of prompts to generate a blocklet.yml metadata file and creates the essential files and directories needed to get started.
This command is ideal when you want to start a new project from scratch. If you prefer to start from a pre-built template, consider using the blocklet create command instead. For a deeper dive into the files generated, refer to the Project Structure documentation.
How It Works#
The init command follows a clear process to set up your project:
Usage#
To start the interactive initialization process, simply run the command in your project's root directory:
blocklet initInteractive Prompts#
If you run the command without any flags, it will prompt you for the following information:
Prompt | Description | Default Source |
|---|---|---|
| The human-readable name of your blocklet. | The current directory's name. |
| A short summary of what your blocklet does. | The |
| The type of blocklet you are creating (e.g., |
|
| The main file that starts your blocklet (e.g., | Varies based on the selected group. |
Command Options#
You can modify the behavior of init using the following command-line options:
Option | Description |
|---|---|
| Skips all interactive prompts and uses the default values. This is useful for automated scripts. |
| Similar to |
| Provides a pre-existing DID for the blocklet, skipping the wallet-based DID generation step. |
| Specifies a custom Blocklet Store URL to use for generating a new DID. Defaults to the official store. |
| A special-purpose flag that only generates a DID with the given name and prints it, then exits. It does not initialize a project. |
Generated Files and Directories#
Upon successful completion, blocklet init creates the following structure in your project directory:
File / Directory | Description |
|---|---|
| The core metadata file that defines your blocklet's properties. |
| A Markdown file for your blocklet's detailed description and documentation. |
| A directory to store screenshots of your blocklet's user interface. |
| A default placeholder logo for your blocklet. |
| A standard |
| A basic entrypoint file is created depending on the blocklet group ( |
Examples#
Interactive Initialization#
Run the command and answer the prompts to create your blocklet.yml.
$ blocklet init
This utility will walk you through create such files and folders(if not exists):
- blocklet.yml
- blocklet.md
- screenshots/
It only covers common items, if you want to check all items, please visit:
https://github.com/ArcBlock/blocklets#keyinfo-blockletjson
Press ^C to quit.
? blocklet title: My First Blocklet
? Please write concise description:: A simple blocklet to demonstrate the init command.
? What's the group of the blocklet? dapp
? What's the entry point of the blocklet? index.js
... (DID generation with Wallet) ...
✔ Meta file blocklet.yml was created
✔ Doc file blocklet.md was created
✔ Screenshots dir screenshots/ was created
✔ logo.png was created
✔ index.js was createdNon-Interactive Initialization#
Use the --yes flag to accept all default values and create the project files automatically.
blocklet init --yesUsing a Pre-existing DID#
If you already have a DID you wish to assign to the blocklet, you can provide it directly.
blocklet init --yes --did z8iZpky...uN7hG9kAfter initializing your project, you have a basic structure ready for development. The next step is to add your application logic and run it locally. For guidance on this, proceed to the Develop a Blocklet guide.