@cryptforge/blockchain-evm 0.1.0 → 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 (2) hide show
  1. package/README.md +188 -0
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -225,6 +225,194 @@ interface EVMAdapterConfig {
225
225
  - Fantom (FTM)
226
226
  - Any other EVM-compatible chain
227
227
 
228
+ ## Transaction Examples
229
+
230
+ ### Send Native Token (ETH/S)
231
+
232
+ ```typescript
233
+ import { createAuthClient } from '@cryptforge/auth';
234
+ import { EthereumAdapter } from '@cryptforge/blockchain-evm';
235
+
236
+ const auth = createAuthClient();
237
+ auth.registerAdapter('ethereum', EthereumAdapter);
238
+
239
+ // Unlock wallet
240
+ await auth.unlock({ password: 'password', chainId: 'ethereum' });
241
+
242
+ // Sign and send transaction
243
+ const { signedTransaction, signature } = await auth.signTransaction({
244
+ transaction: {
245
+ to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
246
+ value: ethers.parseEther('0.1'), // 0.1 ETH
247
+ gasLimit: 21000,
248
+ },
249
+ });
250
+
251
+ console.log('Signed Transaction:', signedTransaction);
252
+ console.log('Transaction Hash:', signature);
253
+ ```
254
+
255
+ ### Sign Message
256
+
257
+ ```typescript
258
+ // Unlock wallet first
259
+ await auth.unlock({ password: 'password', chainId: 'ethereum' });
260
+
261
+ // Sign a message
262
+ const { signature, address, publicKey } = await auth.signMessage({
263
+ message: 'Hello Ethereum!',
264
+ });
265
+
266
+ console.log('Signature:', signature);
267
+ console.log('Signed by:', address);
268
+
269
+ // Verify signature
270
+ const isValid = await auth.verifySignature(
271
+ 'Hello Ethereum!',
272
+ signature,
273
+ publicKey
274
+ );
275
+ console.log('Valid:', isValid);
276
+ ```
277
+
278
+ ### Get Balance
279
+
280
+ ```typescript
281
+ const adapter = EthereumAdapter;
282
+
283
+ // Get native balance
284
+ const balance = await adapter.getNativeBalance(
285
+ '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
286
+ );
287
+ console.log('ETH Balance:', ethers.formatEther(balance));
288
+
289
+ // Get all token balances
290
+ const tokens = await adapter.getTokenBalances(
291
+ '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
292
+ );
293
+ tokens.forEach(token => {
294
+ console.log(`${token.symbol}: ${token.balance}`);
295
+ });
296
+ ```
297
+
298
+ ### Get Transactions
299
+
300
+ ```typescript
301
+ const adapter = EthereumAdapter;
302
+
303
+ // Get recent transactions
304
+ const transactions = await adapter.getTransactions(
305
+ '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb',
306
+ { limit: 10 }
307
+ );
308
+
309
+ transactions.forEach(tx => {
310
+ console.log('Hash:', tx.hash);
311
+ console.log('From:', tx.from);
312
+ console.log('To:', tx.to);
313
+ console.log('Value:', ethers.formatEther(tx.value));
314
+ });
315
+ ```
316
+
317
+ ### Generate Multiple Addresses
318
+
319
+ ```typescript
320
+ // Get addresses at different indices
321
+ const addresses = await auth.getAddresses('ethereum', 0, 5);
322
+
323
+ addresses.forEach(addr => {
324
+ console.log(`Index ${addr.index}: ${addr.address}`);
325
+ console.log(`Path: ${addr.path}`);
326
+ });
327
+
328
+ // Output:
329
+ // Index 0: 0xabc... Path: m/44'/60'/0'/0/0
330
+ // Index 1: 0xdef... Path: m/44'/60'/0'/0/1
331
+ // ...
332
+ ```
333
+
334
+ ## Data Providers
335
+
336
+ The EVM adapter supports pluggable data providers for fetching blockchain data.
337
+
338
+ ### Using Alchemy Provider
339
+
340
+ ```typescript
341
+ import { EVMAdapter, AlchemyProvider } from '@cryptforge/blockchain-evm';
342
+
343
+ const adapter = new EVMAdapter({
344
+ chainData: {
345
+ name: 'Ethereum',
346
+ symbol: 'ETH',
347
+ cmc_id: 1027,
348
+ },
349
+ coinType: 60,
350
+ networks: {
351
+ mainnet: {
352
+ name: 'Ethereum Mainnet',
353
+ rpcUrl: 'https://eth-mainnet.g.alchemy.com/v2/YOUR_API_KEY',
354
+ chainId: 1,
355
+ },
356
+ },
357
+ });
358
+
359
+ // Alchemy provider automatically detects Alchemy RPC URLs
360
+ // and provides enhanced data fetching capabilities
361
+ ```
362
+
363
+ ### Using Etherscan Provider
364
+
365
+ ```typescript
366
+ import { EVMAdapter, EtherscanProvider } from '@cryptforge/blockchain-evm';
367
+
368
+ const adapter = new EVMAdapter({
369
+ chainData: {
370
+ name: 'Ethereum',
371
+ symbol: 'ETH',
372
+ cmc_id: 1027,
373
+ },
374
+ coinType: 60,
375
+ networks: {
376
+ mainnet: {
377
+ name: 'Ethereum Mainnet',
378
+ rpcUrl: 'https://mainnet.infura.io/v3/YOUR_KEY',
379
+ explorerUrl: 'https://etherscan.io',
380
+ chainId: 1,
381
+ },
382
+ },
383
+ });
384
+
385
+ // Configure Etherscan provider
386
+ const etherscanProvider = new EtherscanProvider({
387
+ apiKey: 'YOUR_ETHERSCAN_API_KEY',
388
+ network: 'mainnet',
389
+ });
390
+ ```
391
+
392
+ ## Browser Compatibility
393
+
394
+ This package is **100% browser-compatible**:
395
+
396
+ - ✅ Chrome, Firefox, Safari, Edge
397
+ - ✅ Node.js (v16+)
398
+ - ✅ Electron (main and renderer)
399
+ - ✅ React Native (with polyfills)
400
+ - ✅ Web Workers
401
+
402
+ Uses ethers.js which is fully browser-safe.
403
+
404
+ ## Examples
405
+
406
+ See working examples in:
407
+ - `examples/vue-electron-example/` - Complete wallet application
408
+ - `examples/vue-web-example/` - Web-based wallet
409
+
410
+ ## Related Packages
411
+
412
+ - **[@cryptforge/auth](../auth)** - Authentication and key management
413
+ - **[@cryptforge/core](../core)** - Core types and interfaces
414
+ - **[@cryptforge/blockchain-btc](../blockchain-btc)** - Bitcoin blockchain adapter
415
+
228
416
  ## License
229
417
 
230
418
  ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptforge/blockchain-evm",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "EVM-compatible blockchain adapter for CryptForge SDK (Ethereum, Sonic, Polygon, etc.)",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -41,7 +41,7 @@
41
41
  "README.md"
42
42
  ],
43
43
  "dependencies": {
44
- "@cryptforge/core": "^0.1.0",
44
+ "@cryptforge/core": "workspace:*",
45
45
  "alchemy-sdk": "^3.4.2",
46
46
  "ethers": "^6.13.4"
47
47
  },
@@ -51,6 +51,6 @@
51
51
  "typescript": "^5.7.2"
52
52
  },
53
53
  "peerDependencies": {
54
- "@cryptforge/core": "^0.1.0"
54
+ "@cryptforge/core": "workspace:*"
55
55
  }
56
56
  }