How coinchimp/kaspa-krc20-apps works
Project type and purpose
• This is a command-line toolkit (built on Bun + TypeScript) for secure key generation and KRC20 token operations (mint, deploy, transfer) against the Kaspa blockchain.
• It provides three main CLI tools:
• KeyGenerator (mnemonic → private key → address)
• Kaspa Transfer (sign & send KASPA tokens)
• KRC20 Apps (mint.ts, deploy.ts, transfer.ts)
File structure
• Top-level scripts: mint.ts, deploy.ts, transfer.ts, transfer.ts, sendKaspa.ts, keyGeneratorCli.ts
• src/ contains three core modules:
• BalanceChecker/ – queries token balances
• KeyGenerator/ – implements BIP39/BIP32 flows
• TransactionSender/ – builds & broadcasts transactions
• utils/ includes shell helpers, Docker-compose generator, UTXO trackers, status polling.
• Dockerfile & docker-compose support spinning up a local Kaspa node for testing.
Architectural components
a. CLI Frontend
• keyGeneratorCli.ts
• sendKaspa.ts
• mint.ts, deploy.ts, transfer.ts
b. Core Libraries (under src/)
• KeyGenerator module
• TransactionSender module
• BalanceChecker module
c. Runtime & Dependencies
• Bun JS runtime + TypeScript
• Kaspa WASM (nodejs/wasm) for RPC bindings
• BIP39/BIP32 crypto libraries
d. External Services
• Kaspa node (remote or local-docker) via JSON-RPC
• Docker container (localnode) for offline/testing
e. Utility Scripts
• generate-docker-compose.sh → local node setup
• utxo-tracker, mint-status, subscribe-utxo-changes, etc.
Relationships & data flow
1. Developer invokes a Bun CLI script with flags (–privKey, –destination, etc.)
2. CLI calls into the appropriate core module:
• KeyGenerator generates mnemonic/key/address
• TransactionSender builds & signs a JSON-RPC request
• BalanceChecker polls contract state
3. Core module loads Kaspa WASM bindings and communicates over HTTP/WebSocket to the Kaspa node.
4. Node processes the transaction, updates the blockchain.
5. UTXO-tracker and mint-status watchers in utils poll for confirmations and report back.
Architectural patterns & principles
• Modular separation: UI (CLI) vs. domain logic (src/) vs. orchestration (utils/)
• Single-responsibility per script & per module
• Dependency inversion: modules depend on an abstract RPC interface (WASM) rather than a concrete node
• Use of standard cryptographic protocols (BIP39/BIP32)