@1sat/cli

中文文档
0.1.4发布于 2026/11/07MITES Module近 30 天下载 2603

CLI for 1Sat Ordinals SDK

原始使用文档
文档目录20 节
  1. Quick Start
  2. Install
  3. Authentication
  4. Configuration
  5. Commands
  6. Setup
  7. Wallet
  8. Ordinals
  9. Tokens (BSV21)
  10. Locks
  11. Identity (BAP)
  12. Social
  13. OpNS
  14. Sweep
  15. Transaction Utilities
  16. Generic Action Executor
  17. Global Options
  18. Development
  19. License
  20. Authenticated HTTP requests

1sat CLI

@1sat/cli

Command-line interface for 1Sat Ordinals on BSV.

Runs on Node ≥ 22.13 or Bun ≥ 1.2. With Node:

npm i -g @1sat/cli      # or: npx @1sat/cli <command>

With Bun (the published bin has a node shebang; pass --bun to force Bun when both are installed):

curl -fsSL https://bun.sh/install | bash

Then:

bun add -g @1sat/cli

Or run without installing:

bunx --bun @1sat/cli

Quick Start

# 1. Set up your wallet (interactive)
1sat init

# 2. Check your balance
1sat wallet balance

# 3. List your ordinals
1sat ordinals list

Install

Global install (recommended):

bun add -g @1sat/cli

Run without installing:

bunx @1sat/cli <command>

Binary: The installed binary is named 1sat.


Authentication

The CLI resolves your private key in this order:

  1. PRIVATE_KEY_WIF environment variable — works without a password or any disk state.
  2. ~/.1sat/keys.bep — encrypted keyfile created by 1sat init. Requires a password at runtime via ONESAT_PASSWORD env var or an interactive prompt.
  3. Neither found — exits with an error and tells you to run 1sat init.

Environment variable (CI / scripting):

export PRIVATE_KEY_WIF="<your WIF key>"
1sat wallet balance

Env file (same keys as above; file values override the process environment for this run):

1sat --env-file mint.env wallet balance

Encrypted keyfile (interactive use):

# Set once — creates ~/.1sat/keys.bep
1sat init

# Unlock at runtime via env var
export ONESAT_PASSWORD="your-password"
1sat wallet balance

# Or enter it interactively when prompted
1sat wallet balance

WIF keys start with 5, K, or L on mainnet and c on testnet.


Configuration

All state lives in ~/.1sat/ (mode 0700):

FilePurpose
config.jsonNetwork, data directory, storage settings
keys.bepAES-encrypted private key (mode 0600)
data/Local wallet databases

View current config:

1sat config show

Set a value:

1sat config set chain test
1sat config set remoteStorageUrl https://storage.example.com

Settable keys: chain, dataDir, remoteStorageUrl, storageIdentityKey.

Print config directory:

1sat config path

Commands

Setup

1sat init                          # Interactive wallet setup wizard

init generates or imports a WIF key, encrypts it with a password you choose, selects mainnet or testnet, and writes ~/.1sat/config.json.


Wallet

1sat wallet balance                # Show balance in satoshis and UTXO count
1sat wallet address                # Show deposit address
1sat wallet info                   # Show address, identity key, balance, network
1sat wallet send --to <addr> --sats <amount>
1sat wallet send-all --to <addr>   # Empty the wallet to one address

Ordinals

1sat ordinals list                              # List owned inscriptions
1sat ordinals mint --file <path>                # Inscribe a file (MIME type auto-detected)
1sat ordinals mint --file <path> --type <mime>  # Inscribe with explicit content type
1sat ordinals transfer --outpoint <txid.vout> --to <addr>
1sat ordinals sell --outpoint <txid.vout> --price <sats>
1sat ordinals cancel --outpoint <txid.vout>
1sat ordinals buy --outpoint <txid.vout>

Supported file types for auto-detection: .txt, .html, .css, .js, .json, .svg, .png, .jpg, .gif, .webp, .mp3, .mp4, .pdf, and more.


Tokens (BSV21)

1sat tokens balances                                         # Show balances by token ID
1sat tokens list                                             # List all token UTXOs
1sat tokens list --token-id <id>                             # Filter by token ID
1sat tokens send --token-id <id> --to <addr> --amount <n>
1sat tokens buy --outpoint <txid.vout> --token-id <id> --amount <n>

tokens deploy is not yet available; token deployment will be added once a deploy action lands in @1sat/actions.


Locks

1sat locks info                                 # Show locked amounts and maturity status
1sat locks lock --sats <amount> --blocks <n>    # Lock BSV until block height
1sat locks unlock                               # Unlock all matured locks

Identity (BAP)

1sat identity create                            # Publish a BAP identity on-chain
1sat identity info                              # Show your identity key
1sat identity sign --message <text>             # Sign a message (BSM)

Social

1sat social post --content <text>              # Create an on-chain BSocial post
1sat social post --content <text> --app <name> # Post with a custom app tag

OpNS

OpNS (Ordinals Name System) binds your BAP identity to an on-chain name inscription.

1sat opns lookup                               # List OpNS names in your wallet
1sat opns register --id <id> --domain <host>   # Bind your identity to a name
1sat opns deregister --outpoint <txid.vout>    # Remove the identity binding

Sweep

Import assets from an external private key (legacy P2PKH / Yours backup WIF) into the BRC-100 wallet.

1sat sweep scan --wif <key>
1sat sweep import --wif <key> --dry-run
1sat sweep import --wif <key>
1sat sweep import --wif <key> --only opns,bsv20
1sat sweep import --wif <key> --skip bsv21

scan is the full inventory. import --dry-run is the same plan after --only / --skip. import with no class flags attempts every class that can move into BRC-100:

ClassDestination
bsvFunding
ordinals1sat basket
opnsopns basket
bsv20bsv20 basket (ticker identity)
bsv21bsv21 basket (deploy-outpoint identity)

Listed OrdLocks cancel into the destination in the same transaction. Time-locks and RUN outputs stay as leftover. --only and --skip take bsv,ordinals,opns,bsv20,bsv21. Confirm when prompted, or pass --yes.


Transaction Utilities

1sat tx decode <hex>            # Decode a raw transaction hex string

Generic Action Executor

Every action registered in @1sat/actions is available by name:

1sat action                     # List all registered actions grouped by category
1sat action <name>              # Run an action with no input
1sat action <name> '<json>'     # Run an action with JSON input

Example:

1sat action sendBsv '{"requests":[{"address":"1A1zP1eP5QGefi2DMPTfTL5SLmv7Divf","satoshis":1000}]}'

This executor gives scripting access to all 30+ actions without waiting for dedicated CLI subcommands to be added.


Global Options

These options work with every command:

FlagDescription
--jsonPrint output as JSON (machine-readable)
--quiet, -qSuppress all output
--yes, -ySkip confirmation prompts
--chain <main|test>Network selection (default: main)
--help, -hShow help
--version, -vShow version

JSON output example:

1sat wallet balance --json
# {"satoshis":123456,"utxos":3}

1sat ordinals list --json
# [...array of outputs...]

Scripting with --yes:

1sat wallet send --to 1A1z... --sats 1000 --yes

Development

Run from source inside the monorepo:

cd /path/to/1sat-sdk

# Install dependencies
bun install

# Run the CLI directly (no compile step)
bun run packages/cli/src/cli.ts <command>

# Or use the dev script from the cli package
cd packages/cli
bun dev <command>

# Build a self-contained binary
bun run build
# Output: packages/cli/bin/1sat

The CLI is pure Bun with no framework. Arg parsing is manual (src/args.ts). Bun executes TypeScript directly, so you can run from source without a compile step.


License

MIT

Authenticated HTTP requests

1sat authfetch <method> <url> [--body <json|@file>] [--header 'K: V'] uses the SDK's BRC-104 AuthFetch with CLI wallet keys. If the SDK reports missing response authentication headers, only GET and HEAD may retry using plain fetch for public reads. Other methods fail with an unknown-outcome warning: verify activity before retrying, since the server may already have executed the request.

A 402 response requires interactive payment confirmation or explicit --yes. Without --yes and a terminal on both stdin and stdout, the command returns approval_required with exit status 1 and makes no payment retry. Use --json for structured output; satoshis is included only when the public payment header is a nonnegative safe integer of at most 16 decimal digits. Review the payment before rerunning with --yes; this authorizes the existing SDK payment flow. It does not impose a spending cap. --quiet suppresses output as usual.

版本与发布记录

@1sat/cli 共发布 132 个版本,首次发布于 2026/03/17;过去 12 个月发布了 132 个版本。

版本发布日期距今
0.1.4latest2026/11/07今天
0.1.32026/11/062 天前
0.1.22026/11/062 天前
0.1.12026/10/2711 天前
0.1.02026/10/2216 天前
0.0.1332026/10/1425 天前

关于 @1sat/cli 的常见问题

@1sat/cli 是什么?

CLI for 1Sat Ordinals SDK

如何安装 @1sat/cli?

在项目目录运行 npm install @1sat/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 1sat,可以用 npx 1sat 直接运行。

@1sat/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/1sat__cli 是否存在。

@1sat/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@1sat/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.13。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@1sat/cli 可以商用吗?

@1sat/cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@1sat/cli 的下载量有多少?

根据 npm 官方下载统计,@1sat/cli 在 2026/10/05 – 2026/11/03 这 30 天内被下载 2,603 次,日均约 87 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@1sat/cli 还在维护吗?

最新版本 0.1.4 发布于 2026/11/07(今天);至今共发布 132 个版本,其中过去 12 个月发布了 132 个;首次发布于 2026/03/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。