solforge 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. package/.agi/agi.sqlite +0 -0
  2. package/.claude/settings.local.json +9 -0
  3. package/.github/workflows/release-binaries.yml +133 -0
  4. package/.tmp/.787ebcdbf7b8fde8-00000000.hm +0 -0
  5. package/.tmp/.bffe6efebdf8aedc-00000000.hm +0 -0
  6. package/AGENTS.md +271 -0
  7. package/CLAUDE.md +106 -0
  8. package/PROJECT_STRUCTURE.md +124 -0
  9. package/README.md +367 -393
  10. package/SOLANA_KIT_GUIDE.md +251 -0
  11. package/SOLFORGE.md +119 -0
  12. package/biome.json +34 -0
  13. package/bun.lock +743 -0
  14. package/docs/bun-single-file-executable.md +585 -0
  15. package/docs/cli-plan.md +154 -0
  16. package/docs/data-indexing-plan.md +214 -0
  17. package/docs/gui-roadmap.md +202 -0
  18. package/drizzle/0000_friendly_millenium_guard.sql +53 -0
  19. package/drizzle/0001_stale_sentinels.sql +2 -0
  20. package/drizzle/meta/0000_snapshot.json +329 -0
  21. package/drizzle/meta/0001_snapshot.json +345 -0
  22. package/drizzle/meta/_journal.json +20 -0
  23. package/drizzle.config.ts +12 -0
  24. package/index.ts +21 -0
  25. package/mint.sh +47 -0
  26. package/package.json +45 -69
  27. package/postcss.config.js +6 -0
  28. package/rpc-server.ts.backup +519 -0
  29. package/server/index.ts +5 -0
  30. package/server/lib/base58.ts +33 -0
  31. package/server/lib/faucet.ts +110 -0
  32. package/server/lib/spl-token.ts +57 -0
  33. package/server/methods/TEMPLATE.md +117 -0
  34. package/server/methods/account/get-account-info.ts +90 -0
  35. package/server/methods/account/get-balance.ts +27 -0
  36. package/server/methods/account/get-multiple-accounts.ts +83 -0
  37. package/server/methods/account/get-parsed-account-info.ts +21 -0
  38. package/server/methods/account/index.ts +12 -0
  39. package/server/methods/account/parsers/index.ts +52 -0
  40. package/server/methods/account/parsers/loader-upgradeable.ts +66 -0
  41. package/server/methods/account/parsers/spl-token.ts +237 -0
  42. package/server/methods/account/parsers/system.ts +4 -0
  43. package/server/methods/account/request-airdrop.ts +219 -0
  44. package/server/methods/admin/adopt-mint-authority.ts +94 -0
  45. package/server/methods/admin/clone-program-accounts.ts +55 -0
  46. package/server/methods/admin/clone-program.ts +152 -0
  47. package/server/methods/admin/clone-token-accounts.ts +117 -0
  48. package/server/methods/admin/clone-token-mint.ts +82 -0
  49. package/server/methods/admin/create-mint.ts +114 -0
  50. package/server/methods/admin/create-token-account.ts +137 -0
  51. package/server/methods/admin/helpers.ts +70 -0
  52. package/server/methods/admin/index.ts +10 -0
  53. package/server/methods/admin/list-mints.ts +21 -0
  54. package/server/methods/admin/load-program.ts +52 -0
  55. package/server/methods/admin/mint-to.ts +278 -0
  56. package/server/methods/block/get-block-height.ts +5 -0
  57. package/server/methods/block/get-block.ts +35 -0
  58. package/server/methods/block/get-blocks-with-limit.ts +23 -0
  59. package/server/methods/block/get-latest-blockhash.ts +12 -0
  60. package/server/methods/block/get-slot.ts +5 -0
  61. package/server/methods/block/index.ts +6 -0
  62. package/server/methods/block/is-blockhash-valid.ts +23 -0
  63. package/server/methods/epoch/get-cluster-nodes.ts +17 -0
  64. package/server/methods/epoch/get-epoch-info.ts +16 -0
  65. package/server/methods/epoch/get-epoch-schedule.ts +15 -0
  66. package/server/methods/epoch/get-highest-snapshot-slot.ts +9 -0
  67. package/server/methods/epoch/get-leader-schedule.ts +8 -0
  68. package/server/methods/epoch/get-max-retransmit-slot.ts +9 -0
  69. package/server/methods/epoch/get-max-shred-insert-slot.ts +9 -0
  70. package/server/methods/epoch/get-slot-leader.ts +6 -0
  71. package/server/methods/epoch/get-slot-leaders.ts +9 -0
  72. package/server/methods/epoch/get-stake-activation.ts +9 -0
  73. package/server/methods/epoch/get-stake-minimum-delegation.ts +9 -0
  74. package/server/methods/epoch/get-vote-accounts.ts +19 -0
  75. package/server/methods/epoch/index.ts +13 -0
  76. package/server/methods/epoch/minimum-ledger-slot.ts +5 -0
  77. package/server/methods/fee/get-fee-calculator-for-blockhash.ts +12 -0
  78. package/server/methods/fee/get-fee-for-message.ts +8 -0
  79. package/server/methods/fee/get-fee-rate-governor.ts +16 -0
  80. package/server/methods/fee/get-fees.ts +14 -0
  81. package/server/methods/fee/get-recent-prioritization-fees.ts +22 -0
  82. package/server/methods/fee/index.ts +5 -0
  83. package/server/methods/get-address-lookup-table.ts +31 -0
  84. package/server/methods/index.ts +265 -0
  85. package/server/methods/performance/get-recent-performance-samples.ts +25 -0
  86. package/server/methods/performance/get-transaction-count.ts +5 -0
  87. package/server/methods/performance/index.ts +2 -0
  88. package/server/methods/program/get-block-commitment.ts +9 -0
  89. package/server/methods/program/get-block-production.ts +14 -0
  90. package/server/methods/program/get-block-time.ts +21 -0
  91. package/server/methods/program/get-blocks.ts +11 -0
  92. package/server/methods/program/get-first-available-block.ts +9 -0
  93. package/server/methods/program/get-genesis-hash.ts +6 -0
  94. package/server/methods/program/get-identity.ts +6 -0
  95. package/server/methods/program/get-inflation-governor.ts +15 -0
  96. package/server/methods/program/get-inflation-rate.ts +10 -0
  97. package/server/methods/program/get-inflation-reward.ts +12 -0
  98. package/server/methods/program/get-largest-accounts.ts +8 -0
  99. package/server/methods/program/get-parsed-program-accounts.ts +12 -0
  100. package/server/methods/program/get-parsed-token-accounts-by-delegate.ts +12 -0
  101. package/server/methods/program/get-parsed-token-accounts-by-owner.ts +12 -0
  102. package/server/methods/program/get-program-accounts.ts +221 -0
  103. package/server/methods/program/get-supply.ts +13 -0
  104. package/server/methods/program/get-token-account-balance.ts +64 -0
  105. package/server/methods/program/get-token-accounts-by-delegate.ts +81 -0
  106. package/server/methods/program/get-token-accounts-by-owner.ts +390 -0
  107. package/server/methods/program/get-token-largest-accounts.ts +80 -0
  108. package/server/methods/program/get-token-supply.ts +38 -0
  109. package/server/methods/program/index.ts +21 -0
  110. package/server/methods/solforge/index.ts +155 -0
  111. package/server/methods/system/get-health.ts +5 -0
  112. package/server/methods/system/get-minimum-balance-for-rent-exemption.ts +13 -0
  113. package/server/methods/system/get-version.ts +9 -0
  114. package/server/methods/system/index.ts +3 -0
  115. package/server/methods/transaction/get-confirmed-transaction.ts +11 -0
  116. package/server/methods/transaction/get-parsed-transaction.ts +21 -0
  117. package/server/methods/transaction/get-signature-statuses.ts +72 -0
  118. package/server/methods/transaction/get-signatures-for-address.ts +45 -0
  119. package/server/methods/transaction/get-transaction.ts +428 -0
  120. package/server/methods/transaction/index.ts +7 -0
  121. package/server/methods/transaction/send-transaction.ts +232 -0
  122. package/server/methods/transaction/simulate-transaction.ts +56 -0
  123. package/server/rpc-server.ts +474 -0
  124. package/server/types.ts +74 -0
  125. package/server/ws-server.ts +171 -0
  126. package/sf.config.json +38 -0
  127. package/src/cli/bootstrap.ts +67 -0
  128. package/src/cli/commands/airdrop.ts +37 -0
  129. package/src/cli/commands/config.ts +39 -0
  130. package/src/cli/commands/mint.ts +187 -0
  131. package/src/cli/commands/program-clone.ts +124 -0
  132. package/src/cli/commands/program-load.ts +64 -0
  133. package/src/cli/commands/rpc-start.ts +46 -0
  134. package/src/cli/commands/token-adopt-authority.ts +37 -0
  135. package/src/cli/commands/token-clone.ts +113 -0
  136. package/src/cli/commands/token-create.ts +81 -0
  137. package/src/cli/main.ts +130 -0
  138. package/src/cli/run-solforge.ts +98 -0
  139. package/src/cli/setup-utils.ts +54 -0
  140. package/src/cli/setup-wizard.ts +256 -0
  141. package/src/cli/utils/args.ts +15 -0
  142. package/src/config/index.ts +130 -0
  143. package/src/db/index.ts +83 -0
  144. package/src/db/schema/accounts.ts +23 -0
  145. package/src/db/schema/address-signatures.ts +31 -0
  146. package/src/db/schema/index.ts +5 -0
  147. package/src/db/schema/meta-kv.ts +9 -0
  148. package/src/db/schema/transactions.ts +29 -0
  149. package/src/db/schema/tx-accounts.ts +33 -0
  150. package/src/db/tx-store.ts +229 -0
  151. package/src/gui/public/app.css +1 -0
  152. package/src/gui/public/index.html +19 -0
  153. package/src/gui/server.ts +297 -0
  154. package/src/gui/src/api.ts +127 -0
  155. package/src/gui/src/app.tsx +390 -0
  156. package/src/gui/src/components/airdrop-mint-form.tsx +216 -0
  157. package/src/gui/src/components/clone-program-modal.tsx +183 -0
  158. package/src/gui/src/components/clone-token-modal.tsx +211 -0
  159. package/src/gui/src/components/modal.tsx +127 -0
  160. package/src/gui/src/components/programs-panel.tsx +112 -0
  161. package/src/gui/src/components/status-panel.tsx +122 -0
  162. package/src/gui/src/components/tokens-panel.tsx +116 -0
  163. package/src/gui/src/hooks/use-interval.ts +17 -0
  164. package/src/gui/src/index.css +529 -0
  165. package/src/gui/src/main.tsx +17 -0
  166. package/src/migrations-bundled.ts +17 -0
  167. package/src/rpc/start.ts +44 -0
  168. package/tailwind.config.js +27 -0
  169. package/test-client.ts +120 -0
  170. package/tmp/inspect-html.ts +4 -0
  171. package/tmp/response-test.ts +5 -0
  172. package/tmp/test-html.ts +5 -0
  173. package/tmp/test-server.ts +13 -0
  174. package/tsconfig.json +24 -23
  175. package/LICENSE +0 -21
  176. package/scripts/postinstall.cjs +0 -103
  177. package/src/api-server-entry.ts +0 -109
  178. package/src/commands/add-program.ts +0 -337
  179. package/src/commands/init.ts +0 -122
  180. package/src/commands/list.ts +0 -136
  181. package/src/commands/mint.ts +0 -336
  182. package/src/commands/start.ts +0 -878
  183. package/src/commands/status.ts +0 -99
  184. package/src/commands/stop.ts +0 -406
  185. package/src/config/manager.ts +0 -157
  186. package/src/index.ts +0 -188
  187. package/src/services/api-server.ts +0 -532
  188. package/src/services/port-manager.ts +0 -177
  189. package/src/services/process-registry.ts +0 -154
  190. package/src/services/program-cloner.ts +0 -317
  191. package/src/services/token-cloner.ts +0 -809
  192. package/src/services/validator.ts +0 -295
  193. package/src/types/config.ts +0 -110
  194. package/src/utils/shell.ts +0 -110
package/README.md CHANGED
@@ -1,549 +1,523 @@
1
- # SolForge
1
+ # SolForge – Lightning-Fast Solana Development Server
2
2
 
3
- [![npm version](https://badge.fury.io/js/solforge.svg)](https://badge.fury.io/js/solforge)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
3
+ A blazing-fast, drop-in replacement for `solana-test-validator` built on LiteSVM. Get a full Solana development environment running in under 1 second with comprehensive RPC support and zero configuration.
5
4
 
6
- **SolForge** is a powerful Solana localnet orchestration tool that simplifies the process of setting up and managing local Solana development environments. It allows you to clone mainnet programs and tokens to your local validator, making it easy to develop and test Solana applications with real-world data.
5
+ ## 🚀 Why SolForge?
7
6
 
8
- ## Features
9
-
10
- - 🚀 **One-command setup** - Initialize and start a localnet with a single command
11
- - 🔄 **Mainnet cloning** - Clone tokens and programs from Solana mainnet to your localnet
12
- - 🎯 **Multi-validator support** - Run multiple validators simultaneously with different configurations
13
- - 💰 **Token management** - Mint tokens with custom amounts and distribute to specific wallets
14
- - 🔧 **Program deployment** - Deploy and manage Solana programs on your localnet
15
- - 📊 **Process management** - Monitor, start, stop, and manage validator processes
16
- - 🌐 **Port management** - Automatic port allocation and conflict resolution
17
- - 📝 **Configuration-driven** - JSON-based configuration for reproducible environments
18
- - 🎨 **Beautiful CLI** - Colorful, intuitive command-line interface
19
- - 🌐 **REST API** - Background API server for programmatic access to validator operations
7
+ | Feature | solana-test-validator | SolForge |
8
+ | ----------------- | --------------------- | ---------------- |
9
+ | **Startup Time** | 10-30 seconds | < 1 second |
10
+ | **Memory Usage** | 500MB+ | ~50MB |
11
+ | **Configuration** | Complex setup | Zero config |
12
+ | **Airdrops** | Rate limited | Unlimited |
13
+ | **Database** | Full ledger | Ephemeral SQLite |
20
14
 
21
- ## 📦 Installation
15
+ ## Features
22
16
 
23
- ### Prerequisites
17
+ - ⚡ **Sub-second startup** with LiteSVM in-memory execution
18
+ - 🔄 **Drop-in replacement** for solana-test-validator
19
+ - 💧 **Unlimited airdrops** via real faucet transfers
20
+ - 🗃️ **Smart persistence** with ephemeral SQLite + Drizzle
21
+ - 🔌 **WebSocket support** for signature subscriptions
22
+ - 🧰 **Universal compatibility** with Solana CLI, Anchor, @solana/kit, web3.js
23
+ - 📊 **Rich RPC coverage** (90+ methods implemented)
24
+ - 🖥️ **Built-in GUI dashboard** for airdrops, mints, and asset management
25
+ - 🎯 **CLI tools** for tokens, programs, and accounts
24
26
 
25
- - [Solana CLI tools](https://docs.solana.com/cli/install-solana-cli-tools) installed and configured
26
- - Node.js 18+ or [Bun](https://bun.sh) runtime
27
+ ## 📦 Installation & Quick Start
27
28
 
28
- ### Install from npm (Recommended)
29
+ ### Option 1: From Source (Recommended)
29
30
 
30
31
  ```bash
31
- # Install globally with npm
32
- npm install -g solforge
33
-
34
- # Or with bun
35
- bun install -g solforge
32
+ # Clone and install
33
+ git clone https://github.com/nitishxyz/solforge
34
+ cd solforge
35
+ bun install
36
36
 
37
- # Or with yarn
38
- yarn global add solforge
37
+ # Start the server
38
+ bun start
39
+ # or with debug logging
40
+ DEBUG_RPC_LOG=1 bun start
39
41
  ```
40
42
 
41
- ### Install from Source
43
+ ### Option 2: Compiled Binary (Coming Soon)
42
44
 
43
45
  ```bash
44
- # Clone the repository
45
- git clone https://github.com/nitishxyz/solforge.git
46
- cd solforge
47
-
48
- # Install dependencies
49
- bun install
50
-
51
- # Build and install globally
52
- bun run build:npm
53
- npm install -g .
46
+ # Download and run
47
+ curl -L https://github.com/nitishxyz/solforge/releases/latest/download/solforge-$(uname -s)-$(uname -m) -o solforge
48
+ chmod +x solforge
49
+ ./solforge # first run guides you through setup
54
50
  ```
55
51
 
56
- ### Verify Installation
52
+ ### Option 3: CLI Development
57
53
 
58
54
  ```bash
59
- solforge --version
60
- solforge --help
55
+ # Use the CLI directly
56
+ bun src/cli/main.ts start
57
+ bun src/cli/main.ts config init # Create sf.config.json
61
58
  ```
62
59
 
63
- ## 🚀 Quick Start
60
+ ## 🎯 Usage Examples
64
61
 
65
- ### Basic Usage
62
+ ### With Solana CLI
66
63
 
67
- 1. **Initialize a new project**:
64
+ ```bash
65
+ # Connect to SolForge
66
+ solana config set -u http://localhost:8899
68
67
 
69
- ```bash
70
- solforge init
71
- ```
68
+ # Get unlimited airdrops
69
+ solana airdrop 1000
72
70
 
73
- 2. **Start your localnet**:
71
+ # Deploy programs normally
72
+ solana program deploy ./program.so
73
+ ```
74
74
 
75
- ```bash
76
- solforge start
77
- ```
75
+ ### With @solana/kit
78
76
 
79
- 3. **Check status**:
77
+ ```typescript
78
+ import { createSolanaRpc, generateKeyPairSigner, lamports } from "@solana/kit";
80
79
 
81
- ```bash
82
- solforge status
83
- solforge list
84
- ```
80
+ const rpc = createSolanaRpc("http://localhost:8899");
85
81
 
86
- 4. **Stop when done**:
87
- ```bash
88
- solforge stop --all
89
- ```
82
+ // Get account balance
83
+ const { value: balance } = await rpc.getBalance(address).send();
90
84
 
91
- ### API Server
85
+ // Request airdrops (no limits!)
86
+ const signature = await rpc
87
+ .requestAirdrop(
88
+ address,
89
+ lamports(1_000_000_000n), // 1 SOL
90
+ )
91
+ .send();
92
+ ```
92
93
 
93
- SolForge automatically starts a REST API server alongside your validator, providing programmatic access to validator operations:
94
+ ### With web3.js
94
95
 
95
- ```bash
96
- # API server starts automatically with the validator
97
- solforge start
96
+ ```typescript
97
+ import { Connection, PublicKey, LAMPORTS_PER_SOL } from "@solana/web3.js";
98
98
 
99
- # API available at http://127.0.0.1:3000/api
100
- curl http://127.0.0.1:3000/api/health
99
+ const connection = new Connection("http://localhost:8899");
101
100
 
102
- # Mint tokens via API (using mint address)
103
- curl -X POST http://127.0.0.1:3000/api/tokens/EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v/mint \
104
- -H "Content-Type: application/json" \
105
- -d '{"walletAddress": "YOUR_WALLET_ADDRESS", "amount": 1000}'
101
+ // Get account info
102
+ const accountInfo = await connection.getAccountInfo(publicKey);
106
103
 
107
- # Get wallet balances
108
- curl http://127.0.0.1:3000/api/wallet/YOUR_WALLET_ADDRESS/balances
104
+ // Send transaction
105
+ const signature = await connection.sendTransaction(transaction, [keypair]);
109
106
  ```
110
107
 
111
- For complete API documentation, see [API Documentation](docs/API.md).
108
+ ### With Anchor
112
109
 
113
- ## 📖 Documentation
110
+ ```typescript
111
+ // anchor.toml - use default settings
112
+ [provider]
113
+ cluster = \"http://127.0.0.1:8899\"
114
+ wallet = \"~/.config/solana/id.json\"
114
115
 
115
- ### 📚 Additional Documentation
116
+ // Deploy and test normally
117
+ anchor build
118
+ anchor deploy
119
+ anchor test --skip-local-validator # SolForge is already running
120
+ ```
116
121
 
117
- - [API Documentation](docs/API.md) - REST API endpoints and usage examples
118
- - [Configuration Guide](docs/CONFIGURATION.md) - Detailed configuration options and examples
119
- - [Troubleshooting Guide](#-troubleshooting) - Common issues and solutions
122
+ ## 🖥️ GUI Dashboard
120
123
 
121
- ### Commands
124
+ Solforge ships a dark-mode dashboard that starts alongside the RPC server. By default it listens on `http://127.0.0.1:42069` and provides:
122
125
 
123
- #### `solforge init`
126
+ - Quick airdrops and SPL mints via a faucet-aware form.
127
+ - Live RPC metrics (slot, block height, transaction count, blockhash, faucet balance).
128
+ - Tables of cloned programs and token mints with one-click modals to import additional assets.
124
129
 
125
- Initialize a new `sf.config.json` configuration file in the current directory.
130
+ ### Launching the Dashboard
126
131
 
127
132
  ```bash
128
- solforge init
129
- ```
130
-
131
- This command will prompt you for:
132
-
133
- - Project name
134
- - Description
135
- - RPC port (default: 8899)
136
- - Whether to include USDC token
133
+ # Run the interactive CLI (starts RPC + GUI)
134
+ bun src/cli/main.ts
137
135
 
138
- #### `solforge start [options]`
136
+ # Or start directly
137
+ bun src/cli/main.ts start
139
138
 
140
- Start a localnet validator with the current configuration.
141
-
142
- ```bash
143
- solforge start # Start with default settings
144
- solforge start --debug # Start with debug logging
145
- solforge start --network # Make API server accessible over network
146
- solforge start --debug --network # Debug mode + network access
139
+ # Open the dashboard
140
+ open http://127.0.0.1:42069
147
141
  ```
148
142
 
149
- **Options:**
143
+ ### GUI API Endpoints
150
144
 
151
- - `--debug` - Enable debug logging to see detailed command output
152
- - `--network` - Make API server accessible over network (binds to 0.0.0.0 instead of 127.0.0.1)
145
+ The GUI server exposes REST endpoints backed by the same JSON-RPC methods:
153
146
 
154
- #### `solforge list`
147
+ | Method & Path | Description |
148
+ | ------------------------- | ------------------------------------ |
149
+ | `GET /api/status` | Aggregated RPC stats + faucet info |
150
+ | `GET /api/programs` | List the registered programs |
151
+ | `GET /api/tokens` | Detailed SPL mint metadata |
152
+ | `POST /api/airdrop` | Proxy to `requestAirdrop` |
153
+ | `POST /api/mint` | Proxy to `solforgeMintTo` |
154
+ | `POST /api/clone/program` | Proxy to program clone helpers |
155
+ | `POST /api/clone/token` | Proxy to token clone helpers |
155
156
 
156
- List all running validators with detailed information.
157
+ Override the GUI port via `sf.config.json` (`gui.port`) or `SOLFORGE_GUI_PORT`.
157
158
 
158
- ```bash
159
- solforge list
160
- ```
159
+ Run `bun run build:css` before `bun run build:bin` to embed the latest Tailwind styles in the standalone binary.
161
160
 
162
- Shows:
163
161
 
164
- - Validator ID and name
165
- - Process ID (PID)
166
- - RPC and Faucet ports
167
- - Uptime
168
- - Status
169
- - Connection URLs
162
+ ## 🔧 Configuration
170
163
 
171
- #### `solforge stop [validator-id] [options]`
164
+ SolForge works with zero configuration, but can be customized via environment variables or config file.
172
165
 
173
- Stop running validators.
166
+ ### Environment Variables
174
167
 
175
168
  ```bash
176
- solforge stop # Interactive selection
177
- solforge stop <validator-id> # Stop specific validator
178
- solforge stop --all # Stop all validators
179
- solforge stop --kill # Force kill (SIGKILL)
180
- ```
169
+ # Server settings
170
+ export RPC_PORT=8899 # HTTP port (WS uses port+1)
171
+ export DEBUG_RPC_LOG=1 # Log all RPC calls
181
172
 
182
- **Options:**
173
+ # Database
174
+ export SOLFORGE_DB_MODE=ephemeral # or 'persistent'
175
+ export SOLFORGE_DB_PATH=.solforge/db.db
183
176
 
184
- - `--all` - Stop all running validators
185
- - `--kill` - Force kill the validator (SIGKILL instead of SIGTERM)
186
-
187
- #### `solforge kill [validator-id] [options]`
177
+ # Faucet
178
+ export SOLFORGE_FAUCET_LAMPORTS=1000000000000000 # 1M SOL
179
+ ```
188
180
 
189
- Force kill running validators with interactive selection.
181
+ ### Config File (sf.config.json)
190
182
 
191
183
  ```bash
192
- solforge kill # Interactive selection with validator list
193
- solforge kill <validator-id> # Kill specific validator
194
- solforge kill --all # Kill all validators
195
- ```
184
+ # Generate default config
185
+ bun src/cli/main.ts config init
196
186
 
197
- **Interactive Mode:**
198
- When run without arguments, `solforge kill` will:
187
+ # Edit configuration
188
+ bun src/cli/main.ts config set server.rpcPort 9000
189
+ bun src/cli/main.ts config get server.db.mode
190
+ ```
199
191
 
200
- - Display a table of all running validators
201
- - Allow you to select which validator to kill using arrow keys
202
- - Provide options to kill individual validators, all validators, or cancel
203
- - No need to copy/paste validator IDs from `solforge list`
192
+ ```json
193
+ {
194
+ \"server\": {
195
+ \"rpcPort\": 8899,
196
+ \"wsPort\": 8900,
197
+ \"db\": {
198
+ \"mode\": \"ephemeral\",
199
+ \"path\": \".solforge/db.db\"
200
+ }
201
+ },
202
+ \"svm\": {
203
+ \"initialLamports\": \"1000000000000000\",
204
+ \"faucetSOL\": 1000
205
+ },
206
+ \"clone\": {
207
+ \"endpoint\": \"https://api.mainnet-beta.solana.com\",
208
+ \"programs\": [],
209
+ \"tokens\": [],
210
+ \"programAccounts\": []
211
+ },
212
+ \"gui\": {
213
+ \"enabled\": true,
214
+ \"port\": 42069
215
+ },
216
+ \"bootstrap\": {
217
+ \"airdrops\": []
218
+ }
219
+ }
220
+ ```
204
221
 
205
- #### `solforge status`
222
+ ## 🛠️ CLI Tools
206
223
 
207
- Show overall localnet status and configuration summary.
224
+ SolForge includes powerful CLI tools for development:
208
225
 
209
226
  ```bash
210
- solforge status
211
- ```
227
+ # Airdrop SOL to any address
228
+ bun src/cli/main.ts airdrop --to <pubkey> --sol 100
212
229
 
213
- #### `solforge add-program [options]`
230
+ # Interactive token minting
231
+ bun src/cli/main.ts mint
214
232
 
215
- Add a program to your configuration.
233
+ # Clone mainnet programs and data
234
+ bun src/cli/main.ts program clone <program-id>
235
+ bun src/cli/main.ts token clone <mint-address>
216
236
 
217
- ```bash
218
- solforge add-program # Interactive mode
219
- solforge add-program --program-id <address> # Non-interactive
220
- solforge add-program --program-id <address> --name <name>
237
+ # Manage configuration
238
+ bun src/cli/main.ts config init
239
+ bun src/cli/main.ts config set server.rpcPort 9000
221
240
  ```
222
241
 
223
- **Options:**
242
+ ## 📡 RPC Method Coverage
224
243
 
225
- - `--program-id <address>` - Mainnet program ID to clone and deploy
226
- - `--name <name>` - Friendly name for the program
227
- - `--no-interactive` - Run in non-interactive mode
244
+ ### Fully Implemented (90+ methods)
228
245
 
229
- #### `solforge mint [options]`
246
+ **Account Operations**
230
247
 
231
- Interactively mint tokens to any wallet address.
248
+ - `getAccountInfo`, `getMultipleAccounts`, `getBalance`
249
+ - `getParsedAccountInfo`, `getProgramAccounts`
232
250
 
233
- ```bash
234
- solforge mint # Interactive mode
235
- solforge mint --symbol USDC --wallet <address> --amount 1000 # CLI mode
236
- solforge mint --rpc-url http://localhost:8899 # Custom RPC
237
- ```
251
+ **Transaction Operations**
238
252
 
239
- **Options:**
253
+ - `sendTransaction`, `simulateTransaction`, `getTransaction`
254
+ - `getSignatureStatuses`, `getSignaturesForAddress`
240
255
 
241
- - `--rpc-url <url>` - RPC URL to use (default: "http://127.0.0.1:8899")
242
- - `--symbol <symbol>` - Token symbol to mint
243
- - `--wallet <address>` - Wallet address to mint to
244
- - `--amount <amount>` - Amount to mint
256
+ **Block & Slot Operations**
245
257
 
246
- **Interactive Mode:**
247
- When run without arguments, `solforge mint` will:
258
+ - `getLatestBlockhash`, `getBlock`, `getBlocks`, `getBlockHeight`
259
+ - `getSlot`, `getSlotLeader`, `getSlotLeaders`
248
260
 
249
- - Display available cloned tokens
250
- - Allow you to select which token to mint
251
- - Prompt for recipient wallet address
252
- - Prompt for amount to mint
253
- - Handle SPL token account creation automatically
261
+ **System & Network**
254
262
 
255
- #### `solforge api-server [options]`
263
+ - `getHealth`, `getVersion`, `getGenesisHash`, `getEpochInfo`
264
+ - `getSupply`, `getInflationRate`, `getVoteAccounts`
256
265
 
257
- Start the API server as a standalone service (without validator).
266
+ **Fee Operations**
258
267
 
259
- ```bash
260
- solforge api-server # Start on default port 3000
261
- solforge api-server --port 8080 # Custom port
262
- solforge api-server --host 0.0.0.0 # Network accessible
263
- solforge api-server --rpc-url http://localhost:8899 # Custom RPC
264
- ```
268
+ - `getFeeForMessage`, `getFees`, `getRecentPrioritizationFees`
265
269
 
266
- **Options:**
270
+ **WebSocket Subscriptions**
267
271
 
268
- - `-p, --port <port>` - Port for API server (default: 3000)
269
- - `--host <host>` - Host to bind to (default: 127.0.0.1, use 0.0.0.0 for network access)
270
- - `--rpc-url <url>` - Validator RPC URL (default: http://127.0.0.1:8899)
271
- - `--faucet-url <url>` - Validator faucet URL (default: http://127.0.0.1:9900)
272
- - `--work-dir <dir>` - Work directory (default: ./.solforge)
272
+ - `signatureSubscribe/Unsubscribe` (real-time notifications)
273
+ - Other subscriptions (stubbed but functional)
273
274
 
274
- #### `solforge reset`
275
+ ### ⚠️ Minimal/Stubbed
275
276
 
276
- Reset localnet ledger (coming soon).
277
+ - Token-specific RPCs (returns defaults unless indexed)
278
+ - Some advanced cluster RPCs (simplified for local dev)
277
279
 
278
- ```bash
279
- solforge reset
280
- ```
280
+ ## 💾 Data & Persistence
281
281
 
282
- ### Configuration File (`sf.config.json`)
282
+ ### Ephemeral Mode (Default)
283
283
 
284
- The configuration file defines your localnet setup. For detailed configuration options, see the [Configuration Guide](docs/CONFIGURATION.md).
284
+ - SQLite database recreated on each restart
285
+ - Perfect for testing and development
286
+ - Stores full transaction history during session
285
287
 
286
- Here's the complete schema:
288
+ ### Persistent Mode
287
289
 
288
- ```json
289
- {
290
- "name": "my-localnet",
291
- "description": "Local Solana development environment",
292
- "tokens": [
293
- {
294
- "symbol": "USDC",
295
- "mainnetMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
296
- "mintAuthority": "./keypairs/mint-authority.json",
297
- "mintAmount": 1000000,
298
- "cloneMetadata": true,
299
- "recipients": [
300
- {
301
- "wallet": "YourWalletPublicKeyHere",
302
- "amount": 1000000000
303
- }
304
- ]
305
- }
306
- ],
307
- "programs": [
308
- {
309
- "name": "Token Metadata",
310
- "mainnetProgramId": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",
311
- "cluster": "mainnet-beta",
312
- "upgradeable": false,
313
- "dependencies": []
314
- }
315
- ],
316
- "localnet": {
317
- "airdropAmount": 100,
318
- "faucetAccounts": ["YourWalletPublicKeyHere"],
319
- "port": 8899,
320
- "faucetPort": 9900,
321
- "reset": true,
322
- "logLevel": "info",
323
- "bindAddress": "127.0.0.1",
324
- "limitLedgerSize": 100000,
325
- "rpc": "https://api.mainnet-beta.solana.com"
326
- }
327
- }
290
+ ```bash
291
+ # Enable persistent storage
292
+ export SOLFORGE_DB_MODE=persistent
293
+ bun start
328
294
  ```
329
295
 
330
- #### Configuration Schema
296
+ ### Database Schema
297
+
298
+ ```sql
299
+ -- Transactions with full metadata
300
+ CREATE TABLE transactions (
301
+ signature TEXT PRIMARY KEY,
302
+ slot INTEGER,
303
+ raw_transaction BLOB, -- Full transaction data
304
+ logs TEXT, -- JSON array of logs
305
+ status TEXT, -- success/error
306
+ fee INTEGER,
307
+ timestamp INTEGER
308
+ );
309
+
310
+ -- Account snapshots
311
+ CREATE TABLE accounts (
312
+ address TEXT PRIMARY KEY,
313
+ lamports INTEGER,
314
+ owner TEXT,
315
+ data_len INTEGER,
316
+ last_slot INTEGER
317
+ );
318
+
319
+ -- Address to signature mapping
320
+ CREATE TABLE address_signatures (
321
+ address TEXT,
322
+ signature TEXT,
323
+ slot INTEGER
324
+ );
325
+ ```
331
326
 
332
- For detailed configuration options and examples, see the [Configuration Guide](docs/CONFIGURATION.md).
327
+ ## 🔌 WebSocket Support
328
+
329
+ ```javascript
330
+ const ws = new WebSocket("ws://localhost:8900");
331
+
332
+ // Subscribe to signature updates
333
+ ws.send(
334
+ JSON.stringify({
335
+ jsonrpc: "2.0",
336
+ id: 1,
337
+ method: "signatureSubscribe",
338
+ params: ["<signature>", { commitment: "confirmed" }],
339
+ }),
340
+ );
341
+
342
+ // Receive real-time notifications
343
+ ws.onmessage = (event) => {
344
+ const response = JSON.parse(event.data);
345
+ console.log("Signature update:", response);
346
+ };
347
+ ```
333
348
 
334
- **Quick Reference:**
349
+ ## 🧪 Testing & Validation
335
350
 
336
- - `name` - Project name
337
- - `description` - Project description
338
- - `tokens[]` - Tokens to clone from mainnet
339
- - `programs[]` - Programs to clone from mainnet
340
- - `localnet` - Validator settings (ports, logging, etc.)
351
+ ```bash
352
+ # Run comprehensive test suite
353
+ bun run test-client.ts
341
354
 
342
- ## 🎯 Use Cases
355
+ # Test specific functionality
356
+ bun test
343
357
 
344
- ### DeFi Development
358
+ # Validate against real programs
359
+ anchor test --skip-local-validator
360
+ ```
345
361
 
346
- Clone popular DeFi tokens and programs to test your application:
362
+ ## 🏗️ Architecture Overview
347
363
 
348
- ```json
349
- {
350
- "name": "defi-testing",
351
- "tokens": [
352
- {
353
- "symbol": "USDC",
354
- "mainnetMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
355
- "mintAmount": 10000000
356
- },
357
- {
358
- "symbol": "USDT",
359
- "mainnetMint": "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
360
- "mintAmount": 10000000
361
- }
362
- ],
363
- "programs": [
364
- {
365
- "name": "Jupiter",
366
- "mainnetProgramId": "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4"
367
- }
368
- ]
369
- }
364
+ ```
365
+ SolForge
366
+ ├── 🧠 LiteSVM Core # In-memory execution engine
367
+ ├── 🌐 HTTP Server # JSON-RPC over HTTP
368
+ ├── 🔌 WebSocket Server # Real-time subscriptions
369
+ ├── 🗃️ SQLite + Drizzle # Ephemeral data indexing
370
+ ├── 💧 Smart Faucet # Unlimited SOL distribution
371
+ └── 🎯 CLI Tools # Developer utilities
370
372
  ```
371
373
 
372
- ### NFT Development
373
-
374
- Set up an environment for NFT projects:
374
+ ### Key Components
375
375
 
376
- ```json
377
- {
378
- "name": "nft-development",
379
- "programs": [
380
- {
381
- "name": "Token Metadata",
382
- "mainnetProgramId": "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
383
- },
384
- {
385
- "name": "Candy Machine",
386
- "mainnetProgramId": "cndy3Z4yapfJBmL3ShUp5exZKqR3z33thTzeNMm2gRZ"
387
- }
388
- ]
389
- }
390
- ```
376
+ - **`index.ts`**: Main server entry point
377
+ - **`server/`**: HTTP and WebSocket servers
378
+ - **`server/methods/`**: Modular RPC implementations
379
+ - **`src/cli/`**: Command-line interface
380
+ - **`src/config/`**: Configuration management
381
+ - **`src/db/`**: Database schema and operations
391
382
 
392
- ### Multi-Environment Testing
383
+ ## 🤝 Development
393
384
 
394
- Run multiple validators for different test scenarios:
385
+ ### Adding New RPC Methods
395
386
 
396
- ```bash
397
- # Terminal 1 - DeFi environment
398
- cd defi-project
399
- solforge start
387
+ 1. Create method file: `server/methods/your-method.ts`
388
+ 2. Implement the `RpcMethodHandler` interface
389
+ 3. Export from `server/methods/index.ts`
390
+ 4. Add to `rpcMethods` object
400
391
 
401
- # Terminal 2 - NFT environment
402
- cd nft-project
403
- solforge start
392
+ ```typescript
393
+ // server/methods/your-method.ts
394
+ import type { RpcMethodHandler } from \"../types\";
404
395
 
405
- # Check both
406
- solforge list
396
+ export const yourMethod: RpcMethodHandler = (id, params, context) => {
397
+ try {
398
+ const result = context.svm.someOperation();
399
+ return context.createSuccessResponse(id, result);
400
+ } catch (error: any) {
401
+ return context.createErrorResponse(id, -32603, \"Internal error\");
402
+ }
403
+ };
407
404
  ```
408
405
 
409
- ## 🔧 Development
410
-
411
406
  ### Project Structure
412
407
 
413
408
  ```
414
- src/
415
- ├── commands/ # CLI command implementations
416
- ├── init.ts # Initialize configuration
417
- │ ├── start.ts # Start validator
418
- │ ├── stop.ts # Stop validator
419
- │ ├── list.ts # List validators
420
- │ ├── status.ts # Show status
421
- │ ├── add-program.ts # Add programs
422
- │ └── transfer.ts # Transfer tokens
423
- ├── config/ # Configuration management
424
- │ └── manager.ts # Config file operations
425
- ├── services/ # Core services
426
- │ ├── validator.ts # Validator management
427
- ├── token-cloner.ts # Token cloning logic
428
- ├── program-cloner.ts # Program cloning logic
429
- │ ├── port-manager.ts # Port allocation
430
- │ └── process-registry.ts # Process tracking
431
- ├── types/ # TypeScript definitions
432
- │ └── config.ts # Configuration schemas
433
- ├── utils/ # Utility functions
434
- │ └── shell.ts # Shell command helpers
435
- └── index.ts # CLI entry point
409
+ solforge/
410
+ ├── index.ts # Main entry point
411
+ ├── server/ # Core server
412
+ │ ├── rpc-server.ts # HTTP server
413
+ │ ├── ws-server.ts # WebSocket server
414
+ │ ├── methods/ # RPC method implementations
415
+ ├── account/ # Account methods
416
+ ├── transaction/ # Transaction methods
417
+ └── index.ts # Method registry
418
+ │ └── lib/ # Utilities
419
+ ├── src/ # CLI and config
420
+ ├── cli/ # Command-line interface
421
+ │ ├── config/ # Configuration management
422
+ └── db/ # Database operations
423
+ ├── test-client.ts # Integration tests
424
+ └── docs/ # Documentation
436
425
  ```
437
426
 
438
- ### Build Commands
439
-
440
- ```bash
441
- # Development
442
- bun run dev # Watch mode development
427
+ ### Development Guidelines
443
428
 
444
- # Building
445
- bun run build # Build for Node.js
446
- bun run build:binary # Build standalone binary
447
-
448
- # Testing & Quality
449
- bun test # Run tests
450
- bun run lint # Lint code
451
- bun run format # Format code
452
-
453
- # Installation
454
- bun run install:binary # Install binary to ~/.local/bin
455
- ```
456
-
457
- ### Contributing
458
-
459
- 1. Fork the repository
460
- 2. Create a feature branch: `git checkout -b feature/amazing-feature`
461
- 3. Make your changes
462
- 4. Run tests and linting: `bun test && bun run lint`
463
- 5. Commit your changes: `git commit -m 'Add amazing feature'`
464
- 6. Push to the branch: `git push origin feature/amazing-feature`
465
- 7. Open a Pull Request
429
+ - Use **Bun exclusively** (no npm/yarn/node)
430
+ - Keep files **under 200 lines** (split when larger)
431
+ - Follow **kebab-case** for filenames
432
+ - Write **comprehensive tests**
433
+ - Use **TypeScript strictly**
466
434
 
467
435
  ## 🐛 Troubleshooting
468
436
 
469
437
  ### Common Issues
470
438
 
471
- **Port already in use**
439
+ **Server won't start**
472
440
 
473
441
  ```bash
474
- # Check what's using the port
442
+ # Check if port is in use
475
443
  lsof -i :8899
476
444
 
477
- # Use a different port in sf.config.json
478
- {
479
- "localnet": {
480
- "port": 8900,
481
- "faucetPort": 9901
482
- }
483
- }
445
+ # Use different port
446
+ RPC_PORT=9000 bun start
484
447
  ```
485
448
 
486
- **Validator won't start**
449
+ **Anchor deploy fails**
487
450
 
488
451
  ```bash
489
- # Check Solana CLI is installed
490
- solana --version
491
-
492
- # Check configuration
493
- solforge status
494
-
495
- # Start with debug logging
496
- solforge start --debug
452
+ # Ensure relaxed validation (default)
453
+ # Check logs with debug mode
454
+ DEBUG_RPC_LOG=1 bun start
497
455
  ```
498
456
 
499
- **Token cloning fails**
457
+ **WebSocket connection issues**
500
458
 
501
- - Ensure RPC URL in config is accessible
502
- - Check mainnet mint address is correct
503
- - Verify network connectivity
459
+ ```bash
460
+ # WebSocket runs on RPC_PORT + 1
461
+ # Default: ws://localhost:8900
462
+ ```
504
463
 
505
- **Program deployment fails**
464
+ **Airdrop not working**
506
465
 
507
- - Ensure program ID exists on specified cluster
508
- - Check if program has dependencies that need to be deployed first
509
- - Verify sufficient SOL for deployment
466
+ ```bash
467
+ # Check faucet was created
468
+ ls .solforge/faucet.json
510
469
 
511
- ### Debug Mode
470
+ # Manual airdrop via CLI
471
+ bun src/cli/main.ts airdrop --to <address> --sol 10
472
+ ```
512
473
 
513
- Use `--debug` flag to see detailed command output:
474
+ ## 🔮 Roadmap
514
475
 
515
- ```bash
516
- solforge start --debug
517
- ```
476
+ ### v0.3.0 - Enhanced RPC Coverage
518
477
 
519
- This shows:
478
+ - [ ] Complete token RPC implementations
479
+ - [ ] Advanced subscription support
480
+ - [ ] Improved error handling
520
481
 
521
- - Exact solana-test-validator commands
522
- - Program deployment steps
523
- - Token cloning operations
524
- - Error details
482
+ ### v0.4.0 - Developer Experience
525
483
 
526
- ### Logs and Data
484
+ - [ ] Web-based dashboard
485
+ - [ ] Time-travel debugging
486
+ - [ ] Snapshot/restore functionality
527
487
 
528
- SolForge stores data in:
488
+ ### v0.5.0 - Production Features
529
489
 
530
- - `~/.solforge/` - Process registry and metadata
531
- - `.solforge/` - Local working directory for current project
490
+ - [ ] Clustering support
491
+ - [ ] Metrics and monitoring
492
+ - [ ] Plugin architecture
532
493
 
533
494
  ## 📄 License
534
495
 
535
- MIT License - see [LICENSE](LICENSE) file for details.
496
+ MIT License - see LICENSE file for details.
497
+
498
+ ## 🤝 Contributing
536
499
 
537
- ## 🤝 Support
500
+ We welcome contributions! Please see:
538
501
 
539
- - 🐛 **Issues**: [GitHub Issues](https://github.com/nitishxyz/solforge/issues)
502
+ - [AGENTS.md](./AGENTS.md) - Development guidelines
503
+ - [PROJECT_STRUCTURE.md](./PROJECT_STRUCTURE.md) - Architecture details
504
+ - [SOLFORGE.md](./SOLFORGE.md) - Vision and roadmap
540
505
 
541
506
  ## 🙏 Acknowledgments
542
507
 
543
- - [Solana Labs](https://solana.com) for the amazing blockchain platform
544
- - [Bun](https://bun.sh) for the fast JavaScript runtime
545
- - The Solana developer community for inspiration and feedback
508
+ Built with ❤️ using:
509
+
510
+ - [LiteSVM](https://github.com/litesvm/litesvm) - Fast Solana VM
511
+ - [Bun](https://bun.sh) - Lightning-fast JavaScript runtime
512
+ - [Drizzle](https://drizzle.team) - TypeScript SQL toolkit
546
513
 
547
514
  ---
548
515
 
549
- **Happy building on Solana! 🚀**
516
+ **⚡ Ready to build on Solana at lightning speed?**
517
+
518
+ ```bash
519
+ git clone https://github.com/nitishxyz/solforge
520
+ cd solforge && bun install && bun start
521
+ ```
522
+
523
+ _Happy coding! 🦀_