smartledger-bsv 3.3.2 → 3.3.4
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.
- package/CHANGELOG.md +220 -79
- package/README.md +283 -71
- package/bsv-covenant.min.js +26 -3
- package/bsv-gdaf.min.js +11 -9
- package/bsv-ltp.min.js +10 -8
- package/bsv-mnemonic.min.js +4 -4
- package/bsv-script-helper.min.js +2 -2
- package/bsv-security.min.js +3 -24
- package/bsv-shamir.min.js +2 -2
- package/bsv-smartcontract.min.js +10 -8
- package/bsv.bundle.js +9 -9
- package/bsv.min.js +10 -8
- package/build/webpack.bundle.config.js +2 -2
- package/build/webpack.config.js +2 -2
- package/build/webpack.covenant.config.js +2 -2
- package/build/webpack.gdaf.config.js +6 -43
- package/build/webpack.script-helper.config.js +2 -2
- package/build/webpack.security.config.js +2 -2
- package/build/webpack.smartcontract.config.js +2 -2
- package/bundle-entry.js +1 -341
- package/covenant-entry.js +1 -44
- package/demos/README.md +188 -0
- package/{architecture_demo.js → demos/architecture_demo.js} +2 -2
- package/demos/bsv_wallet_demo.js +242 -0
- package/{complete_ltp_demo.js → demos/complete_ltp_demo.js} +1 -1
- package/demos/debug_tools_demo.js +87 -0
- package/demos/demo_features.js +123 -0
- package/demos/easy_interface_demo.js +109 -0
- package/demos/ecies_demo.js +182 -0
- package/demos/gdaf_core_test.js +131 -0
- package/demos/gdaf_demo.js +237 -0
- package/demos/ltp_demo.js +361 -0
- package/demos/ltp_primitives_demo.js +403 -0
- package/demos/message_demo.js +209 -0
- package/demos/preimage_separation_demo.js +383 -0
- package/demos/script_helper_demo.js +289 -0
- package/demos/security_demo.js +287 -0
- package/{shamir_demo.js → demos/shamir_demo.js} +1 -1
- package/{simple_demo.js → demos/simple_demo.js} +1 -1
- package/demos/simple_p2pkh_demo.js +169 -0
- package/demos/simple_utxo_preimage_demo.js +196 -0
- package/demos/smart_contract_demo.html +1347 -0
- package/demos/smart_contract_demo.js +910 -0
- package/demos/utxo_generator_demo.js +244 -0
- package/demos/validation_pipeline_demo.js +155 -0
- package/demos/web3keys.html +740 -0
- package/docs/BUNDLE_UPDATE_SUMMARY.md +40 -0
- package/docs/DOCUMENTATION_REVIEW_REPORT.md +295 -0
- package/docs/FIX_CREATEHMAC_ISSUE.md +91 -0
- package/docs/MODULE_REFERENCE_COMPLETE.md +330 -0
- package/docs/README.md +107 -79
- package/docs/SMARTLEDGER_BSV_USAGE_ANSWERS.md +477 -0
- package/docs/SMARTLEDGER_BSV_USAGE_EXAMPLES.js +372 -0
- package/docs/SMARTLEDGER_BSV_USAGE_GUIDE.md +555 -0
- package/docs/SMART_CONTRACT_DEVELOPMENT_GUIDE.md +1459 -0
- package/docs/advanced/LEGAL_TOKEN_PROTOCOL.md +411 -0
- package/docs/advanced/SMART_CONTRACT_GUIDE.md +1255 -0
- package/docs/advanced/UTXO_MANAGER_GUIDE.md +851 -0
- package/docs/api/LTP.md +334 -0
- package/docs/getting-started/INSTALLATION.md +410 -0
- package/docs/getting-started/QUICK_START.md +180 -0
- package/docs/migration/FROM_BSV_1_5_6.md +260 -0
- package/docs/technical/GDAF_DEVELOPER_INTERFACE.md +187 -0
- package/docs/technical/GDAF_IMPLEMENTATION_COMPLETE.md +190 -0
- package/docs/technical/SHAMIR_INTEGRATION_SUMMARY.md +165 -0
- package/docs/technical/roadmap.md +1250 -0
- package/docs/technical/trust_law.md +142 -0
- package/examples/complete_workflow_demo.js +783 -0
- package/examples/definitive_working_demo.js +261 -0
- package/examples/final_working_contracts.js +338 -0
- package/examples/smart_contract_templates.js +718 -0
- package/examples/working_smart_contracts.js +348 -0
- package/gdaf-entry.js +2 -54
- package/index.js +32 -0
- package/lib/mnemonic/pbkdf2.browser.js +69 -0
- package/lib/mnemonic/pbkdf2.js +2 -68
- package/lib/mnemonic/pbkdf2.node.js +68 -0
- package/ltp-entry.js +2 -92
- package/package.json +21 -8
- package/script-helper-entry.js +1 -49
- package/security-entry.js +1 -70
- package/shamir-entry.js +1 -173
- package/smartcontract-entry.js +1 -133
- package/tests/browser-compatibility/README.md +35 -0
- package/tests/browser-compatibility/test-cdn-vs-local.html +186 -0
- package/tests/browser-compatibility/test-pbkdf2.html +51 -0
- package/tests/test_builtin_verify.js +117 -0
- package/tests/test_debug_integration.js +71 -0
- package/tests/test_ecdsa_little.js +70 -0
- package/tests/test_smartverify_der.js +110 -0
- package/utilities/blockchain-state.js +155 -155
- package/utilities/blockchain-state.json +103293 -5244
- package/utilities/miner-simulator.js +354 -358
- package/utilities/mock-utxo-generator.js +54 -54
- package/utilities/raw-tx-examples.js +120 -122
- package/utilities/success-demo.js +104 -105
- package/utilities/transaction-examples.js +188 -188
- package/utilities/utxo-manager.js +91 -91
- package/utilities/wallet-setup.js +79 -80
- package/utilities/working-signature-demo.js +108 -110
- package/SECURITY.md +0 -75
- package/build/bsv-covenant.min.js +0 -10
- package/build/bsv-script-helper.min.js +0 -10
- package/build/bsv-security.min.js +0 -31
- package/build/bsv-smartcontract.min.js +0 -39
- package/build/bsv.bundle.js +0 -39
- package/build/bsv.min.js +0 -39
- package/validation_test.js +0 -97
- /package/docs/{ADVANCED_COVENANT_DEVELOPMENT.md → advanced/ADVANCED_COVENANT_DEVELOPMENT.md} +0 -0
- /package/docs/{CUSTOM_SCRIPT_DEVELOPMENT.md → advanced/CUSTOM_SCRIPT_DEVELOPMENT.md} +0 -0
- /package/docs/{block.md → api/BLOCKS.md} +0 -0
- /package/docs/{ecies.md → api/ECIES.md} +0 -0
- /package/docs/{networks.md → api/NETWORKS.md} +0 -0
- /package/docs/{script.md → api/SCRIPTS.md} +0 -0
- /package/docs/{transaction.md → api/TRANSACTIONS.md} +0 -0
- /package/docs/{unspentoutput.md → api/UTXO.md} +0 -0
- /package/{test_shamir.js → tests/test_shamir.js} +0 -0
- /package/{test_standalone_shamir.html → tests/test_standalone_shamir.html} +0 -0
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
# Installation & Setup
|
|
2
|
+
|
|
3
|
+
**Complete installation guide for all environments and use cases**
|
|
4
|
+
|
|
5
|
+
SmartLedger-BSV offers multiple installation methods to suit different development environments and project requirements.
|
|
6
|
+
|
|
7
|
+
## 📦 **NPM Installation (Recommended)**
|
|
8
|
+
|
|
9
|
+
### **Standard Installation**
|
|
10
|
+
```bash
|
|
11
|
+
# Install latest version
|
|
12
|
+
npm install @smartledger/bsv
|
|
13
|
+
|
|
14
|
+
# Install specific version
|
|
15
|
+
npm install @smartledger/bsv@3.3.3
|
|
16
|
+
|
|
17
|
+
# Install with exact version lock
|
|
18
|
+
npm install --save-exact @smartledger/bsv@3.3.3
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### **Usage in Node.js**
|
|
22
|
+
```javascript
|
|
23
|
+
// ES6 modules
|
|
24
|
+
import bsv from '@smartledger/bsv';
|
|
25
|
+
|
|
26
|
+
// CommonJS
|
|
27
|
+
const bsv = require('@smartledger/bsv');
|
|
28
|
+
|
|
29
|
+
// Specific modules only
|
|
30
|
+
const { PrivateKey, Transaction } = require('@smartledger/bsv');
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### **TypeScript Support**
|
|
34
|
+
SmartLedger-BSV includes complete TypeScript definitions:
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import { PrivateKey, Transaction, Address } from '@smartledger/bsv';
|
|
38
|
+
|
|
39
|
+
const privateKey: PrivateKey = new PrivateKey();
|
|
40
|
+
const address: Address = privateKey.toAddress();
|
|
41
|
+
const tx: Transaction = new Transaction();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 🌐 **Browser Installation**
|
|
45
|
+
|
|
46
|
+
### **CDN Links (Instant Setup)**
|
|
47
|
+
|
|
48
|
+
#### **Core Library Only (449KB)**
|
|
49
|
+
For basic Bitcoin SV operations:
|
|
50
|
+
```html
|
|
51
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv.min.js"></script>
|
|
52
|
+
<script>
|
|
53
|
+
const privateKey = new bsv.PrivateKey();
|
|
54
|
+
const address = privateKey.toAddress();
|
|
55
|
+
</script>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### **Complete Bundle (885KB)**
|
|
59
|
+
Everything in one file:
|
|
60
|
+
```html
|
|
61
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv.bundle.js"></script>
|
|
62
|
+
<script>
|
|
63
|
+
// All features available immediately
|
|
64
|
+
const shares = bsv.splitSecret('secret', 5, 3);
|
|
65
|
+
const did = bsv.createDID(publicKey);
|
|
66
|
+
const propertyToken = bsv.createPropertyToken({...});
|
|
67
|
+
</script>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### **Modular Loading (Choose What You Need)**
|
|
71
|
+
|
|
72
|
+
#### **Smart Contract Development (932KB total)**
|
|
73
|
+
```html
|
|
74
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv.min.js"></script>
|
|
75
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv-covenant.min.js"></script>
|
|
76
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv-smartcontract.min.js"></script>
|
|
77
|
+
<script>
|
|
78
|
+
const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
79
|
+
.extractField('amount').push(50000).greaterThanOrEqual().build();
|
|
80
|
+
</script>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
#### **Legal & Identity Development (1.87MB total)**
|
|
84
|
+
```html
|
|
85
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv.min.js"></script>
|
|
86
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv-ltp.min.js"></script>
|
|
87
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv-gdaf.min.js"></script>
|
|
88
|
+
<script>
|
|
89
|
+
// Legal Token Protocol
|
|
90
|
+
const propertyToken = bsv.createPropertyToken({
|
|
91
|
+
propertyType: 'real_estate', jurisdiction: 'us_delaware'
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Digital Identity
|
|
95
|
+
const credential = bsv.createEmailCredential(issuerDID, subjectDID, 'user@example.com', key);
|
|
96
|
+
</script>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### **Security & Cryptography (1.17MB total)**
|
|
100
|
+
```html
|
|
101
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv.min.js"></script>
|
|
102
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv-security.min.js"></script>
|
|
103
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv-shamir.min.js"></script>
|
|
104
|
+
<script>
|
|
105
|
+
// Threshold Cryptography
|
|
106
|
+
const shares = bsv.splitSecret('my_secret_key', 5, 3);
|
|
107
|
+
|
|
108
|
+
// Enhanced Security
|
|
109
|
+
const verified = bsvSecurity.SmartVerify.verify(signature, hash, publicKey);
|
|
110
|
+
</script>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### **Complete Module Reference**
|
|
114
|
+
|
|
115
|
+
| Module | Size | Purpose | CDN Link |
|
|
116
|
+
|--------|------|---------|----------|
|
|
117
|
+
| **bsv.min.js** | 449KB | Core BSV + SmartContract | `unpkg.com/@smartledger/bsv@3.3.3/bsv.min.js` |
|
|
118
|
+
| **bsv.bundle.js** | 885KB | Everything in one file | `unpkg.com/@smartledger/bsv@3.3.3/bsv.bundle.js` |
|
|
119
|
+
| **bsv-smartcontract.min.js** | 451KB | Complete covenant framework | `unpkg.com/@smartledger/bsv@3.3.3/bsv-smartcontract.min.js` |
|
|
120
|
+
| **bsv-ltp.min.js** | 817KB | **Legal Token Protocol** | `unpkg.com/@smartledger/bsv@3.3.3/bsv-ltp.min.js` |
|
|
121
|
+
| **bsv-gdaf.min.js** | 604KB | **Digital Identity & Attestation** | `unpkg.com/@smartledger/bsv@3.3.3/bsv-gdaf.min.js` |
|
|
122
|
+
| **bsv-shamir.min.js** | 433KB | **Threshold Cryptography** | `unpkg.com/@smartledger/bsv@3.3.3/bsv-shamir.min.js` |
|
|
123
|
+
| **bsv-security.min.js** | 290KB | Security enhancements | `unpkg.com/@smartledger/bsv@3.3.3/bsv-security.min.js` |
|
|
124
|
+
| **bsv-mnemonic.min.js** | 670KB | HD wallets | `unpkg.com/@smartledger/bsv@3.3.3/bsv-mnemonic.min.js` |
|
|
125
|
+
| **bsv-ecies.min.js** | 71KB | Encryption | `unpkg.com/@smartledger/bsv@3.3.3/bsv-ecies.min.js` |
|
|
126
|
+
| **bsv-covenant.min.js** | 32KB | Covenant operations | `unpkg.com/@smartledger/bsv@3.3.3/bsv-covenant.min.js` |
|
|
127
|
+
| **bsv-script-helper.min.js** | 27KB | Custom script tools | `unpkg.com/@smartledger/bsv@3.3.3/bsv-script-helper.min.js` |
|
|
128
|
+
| **bsv-message.min.js** | 26KB | Message signing | `unpkg.com/@smartledger/bsv@3.3.3/bsv-message.min.js` |
|
|
129
|
+
|
|
130
|
+
## ⚙️ **Development Environment Setup**
|
|
131
|
+
|
|
132
|
+
### **VS Code Setup**
|
|
133
|
+
```json
|
|
134
|
+
// .vscode/settings.json
|
|
135
|
+
{
|
|
136
|
+
"typescript.preferences.includePackageJsonAutoImports": "on",
|
|
137
|
+
"npm.packageManager": "npm",
|
|
138
|
+
"eslint.workingDirectories": ["."],
|
|
139
|
+
"typescript.suggest.autoImports": true
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### **ESLint Configuration**
|
|
144
|
+
```json
|
|
145
|
+
// .eslintrc.json
|
|
146
|
+
{
|
|
147
|
+
"extends": ["eslint:recommended"],
|
|
148
|
+
"env": {
|
|
149
|
+
"node": true,
|
|
150
|
+
"browser": true,
|
|
151
|
+
"es2021": true
|
|
152
|
+
},
|
|
153
|
+
"globals": {
|
|
154
|
+
"bsv": "readonly"
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### **Webpack Configuration**
|
|
160
|
+
```javascript
|
|
161
|
+
// webpack.config.js
|
|
162
|
+
module.exports = {
|
|
163
|
+
externals: {
|
|
164
|
+
'@smartledger/bsv': 'bsv'
|
|
165
|
+
},
|
|
166
|
+
resolve: {
|
|
167
|
+
fallback: {
|
|
168
|
+
"crypto": require.resolve("crypto-browserify"),
|
|
169
|
+
"stream": require.resolve("stream-browserify"),
|
|
170
|
+
"buffer": require.resolve("buffer")
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## 🔧 **Project Templates**
|
|
177
|
+
|
|
178
|
+
### **Basic Node.js Project**
|
|
179
|
+
```bash
|
|
180
|
+
mkdir my-bsv-project
|
|
181
|
+
cd my-bsv-project
|
|
182
|
+
npm init -y
|
|
183
|
+
npm install @smartledger/bsv
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
```javascript
|
|
187
|
+
// index.js
|
|
188
|
+
const bsv = require('@smartledger/bsv');
|
|
189
|
+
|
|
190
|
+
const privateKey = new bsv.PrivateKey();
|
|
191
|
+
console.log('Address:', privateKey.toAddress().toString());
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### **Express.js API Server**
|
|
195
|
+
```bash
|
|
196
|
+
npm install express @smartledger/bsv
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
```javascript
|
|
200
|
+
// server.js
|
|
201
|
+
const express = require('express');
|
|
202
|
+
const bsv = require('@smartledger/bsv');
|
|
203
|
+
|
|
204
|
+
const app = express();
|
|
205
|
+
app.use(express.json());
|
|
206
|
+
|
|
207
|
+
app.post('/create-address', (req, res) => {
|
|
208
|
+
const privateKey = new bsv.PrivateKey();
|
|
209
|
+
res.json({
|
|
210
|
+
address: privateKey.toAddress().toString(),
|
|
211
|
+
privateKey: privateKey.toString()
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
app.listen(3000, () => {
|
|
216
|
+
console.log('BSV API server running on port 3000');
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### **React App Integration**
|
|
221
|
+
```bash
|
|
222
|
+
npx create-react-app my-bsv-app
|
|
223
|
+
cd my-bsv-app
|
|
224
|
+
npm install @smartledger/bsv
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
```javascript
|
|
228
|
+
// src/App.js
|
|
229
|
+
import { useEffect, useState } from 'react';
|
|
230
|
+
|
|
231
|
+
// For React, use dynamic import to avoid SSR issues
|
|
232
|
+
function App() {
|
|
233
|
+
const [bsv, setBsv] = useState(null);
|
|
234
|
+
const [address, setAddress] = useState('');
|
|
235
|
+
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
import('@smartledger/bsv').then(bsvModule => {
|
|
238
|
+
setBsv(bsvModule);
|
|
239
|
+
});
|
|
240
|
+
}, []);
|
|
241
|
+
|
|
242
|
+
const generateAddress = () => {
|
|
243
|
+
if (bsv) {
|
|
244
|
+
const privateKey = new bsv.PrivateKey();
|
|
245
|
+
setAddress(privateKey.toAddress().toString());
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<div>
|
|
251
|
+
<button onClick={generateAddress}>Generate Address</button>
|
|
252
|
+
<p>Address: {address}</p>
|
|
253
|
+
</div>
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## 🧪 **Testing Setup**
|
|
259
|
+
|
|
260
|
+
### **Jest Configuration**
|
|
261
|
+
```json
|
|
262
|
+
// package.json
|
|
263
|
+
{
|
|
264
|
+
"scripts": {
|
|
265
|
+
"test": "jest"
|
|
266
|
+
},
|
|
267
|
+
"jest": {
|
|
268
|
+
"testEnvironment": "node",
|
|
269
|
+
"setupFilesAfterEnv": ["<rootDir>/test/setup.js"]
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
```javascript
|
|
275
|
+
// test/setup.js
|
|
276
|
+
global.bsv = require('@smartledger/bsv');
|
|
277
|
+
|
|
278
|
+
// Test/development configuration
|
|
279
|
+
process.env.BSV_NETWORK = 'testnet';
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
### **Basic Test Example**
|
|
283
|
+
```javascript
|
|
284
|
+
// test/bsv.test.js
|
|
285
|
+
const bsv = require('@smartledger/bsv');
|
|
286
|
+
|
|
287
|
+
describe('SmartLedger-BSV', () => {
|
|
288
|
+
test('generates valid private keys', () => {
|
|
289
|
+
const privateKey = new bsv.PrivateKey();
|
|
290
|
+
expect(privateKey.isValid()).toBe(true);
|
|
291
|
+
expect(privateKey.toString()).toMatch(/^[5KL][1-9A-HJ-NP-Z0-9a-km-z]{50,51}$/);
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
test('creates valid addresses', () => {
|
|
295
|
+
const privateKey = new bsv.PrivateKey();
|
|
296
|
+
const address = privateKey.toAddress();
|
|
297
|
+
expect(address.toString()).toMatch(/^1[A-HJ-NP-Z0-9a-km-z]{25,34}$/);
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test('builds valid transactions', () => {
|
|
301
|
+
const privateKey = new bsv.PrivateKey();
|
|
302
|
+
const address = privateKey.toAddress();
|
|
303
|
+
|
|
304
|
+
const utxo = {
|
|
305
|
+
txId: '6e30c9df8a4b2d8e4d8c8e5f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b',
|
|
306
|
+
outputIndex: 0,
|
|
307
|
+
address: address.toString(),
|
|
308
|
+
script: bsv.Script.buildPublicKeyHashOut(address).toHex(),
|
|
309
|
+
satoshis: 100000
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
const tx = new bsv.Transaction()
|
|
313
|
+
.from(utxo)
|
|
314
|
+
.to('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', 50000)
|
|
315
|
+
.change(address)
|
|
316
|
+
.sign(privateKey);
|
|
317
|
+
|
|
318
|
+
expect(tx.isFullySigned()).toBe(true);
|
|
319
|
+
});
|
|
320
|
+
});
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## 🚨 **Troubleshooting**
|
|
324
|
+
|
|
325
|
+
### **Common Installation Issues**
|
|
326
|
+
|
|
327
|
+
#### **Node.js Version Compatibility**
|
|
328
|
+
SmartLedger-BSV requires Node.js 14+ for optimal performance:
|
|
329
|
+
```bash
|
|
330
|
+
# Check Node version
|
|
331
|
+
node --version
|
|
332
|
+
|
|
333
|
+
# Update if needed (using nvm)
|
|
334
|
+
nvm install 18
|
|
335
|
+
nvm use 18
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
#### **Browser Compatibility Issues**
|
|
339
|
+
```javascript
|
|
340
|
+
// For older browsers, include polyfills
|
|
341
|
+
if (typeof Buffer === 'undefined') {
|
|
342
|
+
window.Buffer = require('buffer').Buffer;
|
|
343
|
+
}
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
#### **Webpack Bundle Issues**
|
|
347
|
+
```javascript
|
|
348
|
+
// webpack.config.js
|
|
349
|
+
module.exports = {
|
|
350
|
+
resolve: {
|
|
351
|
+
fallback: {
|
|
352
|
+
"crypto": require.resolve("crypto-browserify"),
|
|
353
|
+
"stream": require.resolve("stream-browserify"),
|
|
354
|
+
"buffer": require.resolve("buffer"),
|
|
355
|
+
"util": require.resolve("util"),
|
|
356
|
+
"assert": require.resolve("assert"),
|
|
357
|
+
"url": require.resolve("url")
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
plugins: [
|
|
361
|
+
new webpack.ProvidePlugin({
|
|
362
|
+
Buffer: ['buffer', 'Buffer'],
|
|
363
|
+
process: 'process/browser'
|
|
364
|
+
})
|
|
365
|
+
]
|
|
366
|
+
};
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
## ✅ **Verification**
|
|
370
|
+
|
|
371
|
+
After installation, verify everything works:
|
|
372
|
+
|
|
373
|
+
```javascript
|
|
374
|
+
// verification.js
|
|
375
|
+
const bsv = require('@smartledger/bsv');
|
|
376
|
+
|
|
377
|
+
console.log('SmartLedger-BSV Version:', require('@smartledger/bsv/package.json').version);
|
|
378
|
+
console.log('Core functionality test...');
|
|
379
|
+
|
|
380
|
+
const privateKey = new bsv.PrivateKey();
|
|
381
|
+
const address = privateKey.toAddress();
|
|
382
|
+
const publicKey = privateKey.toPublicKey();
|
|
383
|
+
|
|
384
|
+
console.log('✅ Private Key:', privateKey.toString());
|
|
385
|
+
console.log('✅ Address:', address.toString());
|
|
386
|
+
console.log('✅ Public Key:', publicKey.toString());
|
|
387
|
+
|
|
388
|
+
// Test advanced features if available
|
|
389
|
+
if (bsv.SmartContract) {
|
|
390
|
+
console.log('✅ Smart Contract module loaded');
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (bsv.splitSecret) {
|
|
394
|
+
console.log('✅ Shamir Secret Sharing available');
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
console.log('🎉 Installation verified successfully!');
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
## 🎯 **Next Steps**
|
|
401
|
+
|
|
402
|
+
1. **🚀 Quick Start**: [Get running in 2 minutes](QUICK_START.md)
|
|
403
|
+
2. **🔄 Migration**: [Upgrade from bsv@1.5.6](../migration/FROM_BSV_1_5_6.md)
|
|
404
|
+
3. **💡 Examples**: [Working Code Examples](../../examples/)
|
|
405
|
+
4. **📖 API Docs**: [Complete API Reference](../api/)
|
|
406
|
+
5. **🏗️ Advanced**: [Smart Contract Development](../advanced/SMART_CONTRACT_GUIDE.md)
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
**Ready to build the future of Bitcoin SV applications! 🚀**
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Quick Start Guide
|
|
2
|
+
|
|
3
|
+
**Get up and running with SmartLedger-BSV in under 2 minutes**
|
|
4
|
+
|
|
5
|
+
SmartLedger-BSV is a drop-in replacement for bsv@1.5.6 with enhanced security and additional features. If you're already using bsv@1.5.6, you can upgrade immediately with zero code changes.
|
|
6
|
+
|
|
7
|
+
## 🚀 **30-Second Installation**
|
|
8
|
+
|
|
9
|
+
### NPM (Recommended)
|
|
10
|
+
```bash
|
|
11
|
+
npm install @smartledger/bsv
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
### Browser CDN (Instant)
|
|
15
|
+
```html
|
|
16
|
+
<!-- Core library (449KB) -->
|
|
17
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv.min.js"></script>
|
|
18
|
+
|
|
19
|
+
<!-- Everything included (885KB) -->
|
|
20
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv.bundle.js"></script>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## 💰 **Your First Transaction (60 seconds)**
|
|
24
|
+
|
|
25
|
+
```javascript
|
|
26
|
+
const bsv = require('@smartledger/bsv'); // Node.js
|
|
27
|
+
// const bsv = window.bsv; // Browser
|
|
28
|
+
|
|
29
|
+
// 1. Generate keys
|
|
30
|
+
const privateKey = new bsv.PrivateKey();
|
|
31
|
+
const address = privateKey.toAddress();
|
|
32
|
+
|
|
33
|
+
console.log('Address:', address.toString());
|
|
34
|
+
console.log('Private Key:', privateKey.toString());
|
|
35
|
+
|
|
36
|
+
// 2. Create a transaction (with real UTXO)
|
|
37
|
+
const transaction = new bsv.Transaction()
|
|
38
|
+
.from({
|
|
39
|
+
txId: '6e30c9df8a4b2d8e4d8c8e5f1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b',
|
|
40
|
+
outputIndex: 0,
|
|
41
|
+
address: address.toString(),
|
|
42
|
+
script: bsv.Script.buildPublicKeyHashOut(address).toHex(),
|
|
43
|
+
satoshis: 100000 // 1000 sats
|
|
44
|
+
})
|
|
45
|
+
.to('1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa', 50000) // Send 500 sats
|
|
46
|
+
.feePerKb(1000) // Ultra-low fee: ~0.01 sats/byte
|
|
47
|
+
.change(address) // Change back to sender
|
|
48
|
+
.sign(privateKey);
|
|
49
|
+
|
|
50
|
+
console.log('Transaction:', transaction.toString());
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 🎯 **Choose Your Path**
|
|
54
|
+
|
|
55
|
+
### **New to Bitcoin SV?**
|
|
56
|
+
Start here for comprehensive Bitcoin SV development:
|
|
57
|
+
```javascript
|
|
58
|
+
// Basic wallet operations
|
|
59
|
+
const privateKey = new bsv.PrivateKey();
|
|
60
|
+
const publicKey = privateKey.toPublicKey();
|
|
61
|
+
const address = privateKey.toAddress();
|
|
62
|
+
|
|
63
|
+
// Create and sign transactions
|
|
64
|
+
const tx = new bsv.Transaction()
|
|
65
|
+
.from(utxo)
|
|
66
|
+
.to(destinationAddress, amount)
|
|
67
|
+
.sign(privateKey);
|
|
68
|
+
```
|
|
69
|
+
➡️ **Next**: [Complete Installation Guide](INSTALLATION.md)
|
|
70
|
+
|
|
71
|
+
### **Migrating from bsv@1.5.6?**
|
|
72
|
+
SmartLedger-BSV is 100% backward compatible:
|
|
73
|
+
```javascript
|
|
74
|
+
// Your existing bsv@1.5.6 code works unchanged
|
|
75
|
+
const bsv = require('@smartledger/bsv'); // Only change the import
|
|
76
|
+
|
|
77
|
+
// All your existing code continues to work
|
|
78
|
+
const tx = new bsv.Transaction()
|
|
79
|
+
.from(utxo)
|
|
80
|
+
.to(address, amount)
|
|
81
|
+
.sign(privateKey);
|
|
82
|
+
```
|
|
83
|
+
➡️ **Next**: [Migration Guide](../migration/FROM_BSV_1_5_6.md)
|
|
84
|
+
|
|
85
|
+
### **Want Advanced Features?**
|
|
86
|
+
Explore unique SmartLedger-BSV capabilities:
|
|
87
|
+
```javascript
|
|
88
|
+
// Legal Token Protocol - Property rights on-chain
|
|
89
|
+
const propertyToken = bsv.createPropertyToken({
|
|
90
|
+
propertyType: 'real_estate',
|
|
91
|
+
jurisdiction: 'us_delaware'
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// Digital Identity - W3C standard DIDs
|
|
95
|
+
const did = bsv.createDID(publicKey);
|
|
96
|
+
const credential = bsv.createEmailCredential(issuerDID, did, 'user@example.com', signingKey);
|
|
97
|
+
|
|
98
|
+
// Shamir Secret Sharing - Threshold cryptography
|
|
99
|
+
const shares = bsv.splitSecret('my_private_key', 5, 3); // 5 shares, need 3
|
|
100
|
+
```
|
|
101
|
+
➡️ **Next**: [Advanced Features Guide](../advanced/)
|
|
102
|
+
|
|
103
|
+
### **Building Smart Contracts?**
|
|
104
|
+
Complete covenant development framework:
|
|
105
|
+
```javascript
|
|
106
|
+
// Generate test UTXOs
|
|
107
|
+
const generator = new bsv.SmartContract.UTXOGenerator();
|
|
108
|
+
const utxos = generator.createRealUTXOs(3, 100000);
|
|
109
|
+
|
|
110
|
+
// Build covenants with JavaScript
|
|
111
|
+
const covenant = bsv.SmartContract.createCovenantBuilder()
|
|
112
|
+
.extractField('amount')
|
|
113
|
+
.push(50000)
|
|
114
|
+
.greaterThanOrEqual()
|
|
115
|
+
.verify()
|
|
116
|
+
.build();
|
|
117
|
+
|
|
118
|
+
// Parse BIP-143 preimages
|
|
119
|
+
const preimage = new bsv.SmartContract.Preimage(transaction, inputIndex);
|
|
120
|
+
const amount = preimage.getField('amount');
|
|
121
|
+
```
|
|
122
|
+
➡️ **Next**: [Smart Contract Guide](../SMART_CONTRACT_GUIDE.md)
|
|
123
|
+
|
|
124
|
+
## 📦 **Modular Loading Options**
|
|
125
|
+
|
|
126
|
+
SmartLedger-BSV offers 12 different loading options - use only what you need:
|
|
127
|
+
|
|
128
|
+
```html
|
|
129
|
+
<!-- Core BSV only (449KB) -->
|
|
130
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv.min.js"></script>
|
|
131
|
+
|
|
132
|
+
<!-- Smart contracts (873KB) -->
|
|
133
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv-smartcontract.min.js"></script>
|
|
134
|
+
|
|
135
|
+
<!-- Legal tokens (1.1MB) -->
|
|
136
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv-ltp.min.js"></script>
|
|
137
|
+
|
|
138
|
+
<!-- Digital identity (1.1MB) -->
|
|
139
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv-gdaf.min.js"></script>
|
|
140
|
+
|
|
141
|
+
<!-- Everything (885KB) -->
|
|
142
|
+
<script src="https://unpkg.com/@smartledger/bsv@3.3.3/bsv.bundle.js"></script>
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## ⚡ **Key Advantages**
|
|
146
|
+
|
|
147
|
+
### **Security First**
|
|
148
|
+
- ✅ **Elliptic curve hardening** - Enhanced cryptographic security
|
|
149
|
+
- ✅ **Production tested** - Battle-tested in real applications
|
|
150
|
+
- ✅ **Comprehensive validation** - Built-in error checking
|
|
151
|
+
|
|
152
|
+
### **Developer Experience**
|
|
153
|
+
- ✅ **Zero breaking changes** - Drop-in replacement for bsv@1.5.6
|
|
154
|
+
- ✅ **Extensive documentation** - Complete guides and examples
|
|
155
|
+
- ✅ **TypeScript support** - Full type definitions included
|
|
156
|
+
|
|
157
|
+
### **Modern Features**
|
|
158
|
+
- ✅ **Legal compliance** - Built-in regulatory token support
|
|
159
|
+
- ✅ **Digital identity** - W3C standard implementation
|
|
160
|
+
- ✅ **Enterprise security** - Shamir secret sharing and more
|
|
161
|
+
|
|
162
|
+
## 🎓 **Next Steps**
|
|
163
|
+
|
|
164
|
+
1. **📖 Learn More**: [Complete Installation Guide](INSTALLATION.md)
|
|
165
|
+
2. **🔄 Migration**: [Upgrade from bsv@1.5.6](../migration/FROM_BSV_1_5_6.md)
|
|
166
|
+
3. **💡 Examples**: [Working Code Examples](../../examples/)
|
|
167
|
+
4. **🚀 Advanced**: [Smart Contract Development](../SMART_CONTRACT_GUIDE.md)
|
|
168
|
+
5. **🆔 Identity**: [Digital Attestation](../advanced/DIGITAL_ATTESTATION.md)
|
|
169
|
+
6. **⚖️ Legal**: [Legal Token Protocol](../advanced/LEGAL_TOKEN_PROTOCOL.md)
|
|
170
|
+
|
|
171
|
+
## 🤝 **Getting Help**
|
|
172
|
+
|
|
173
|
+
- **📚 Documentation**: [Complete Docs](../)
|
|
174
|
+
- **💬 Community**: [GitHub Discussions](https://github.com/codenlighten/smartledger-bsv/discussions)
|
|
175
|
+
- **🐛 Issues**: [GitHub Issues](https://github.com/codenlighten/smartledger-bsv/issues)
|
|
176
|
+
- **📧 Support**: [hello@smartledger.technology](mailto:hello@smartledger.technology)
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
**Welcome to the future of Bitcoin SV development! 🎉**
|