@gitmyabi/els 0.0.0-stage → 1.0.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.
@@ -0,0 +1,821 @@
1
+ import type { Abi, Address, PublicClient, WalletClient, GetContractReturnType } from 'viem';
2
+ import { getContract } from 'viem';
3
+
4
+ /**
5
+ * ELSERC20_json ABI
6
+ *
7
+ * This ABI is typed using viem's type system for full type safety.
8
+ */
9
+ export const ELSERC20_jsonAbi = [
10
+ {
11
+ "inputs": [
12
+ {
13
+ "internalType": "uint256",
14
+ "name": "initialSupply",
15
+ "type": "uint256"
16
+ }
17
+ ],
18
+ "stateMutability": "nonpayable",
19
+ "type": "constructor"
20
+ },
21
+ {
22
+ "anonymous": false,
23
+ "inputs": [
24
+ {
25
+ "indexed": true,
26
+ "internalType": "address",
27
+ "name": "owner",
28
+ "type": "address"
29
+ },
30
+ {
31
+ "indexed": true,
32
+ "internalType": "address",
33
+ "name": "spender",
34
+ "type": "address"
35
+ },
36
+ {
37
+ "indexed": false,
38
+ "internalType": "uint256",
39
+ "name": "value",
40
+ "type": "uint256"
41
+ }
42
+ ],
43
+ "name": "Approval",
44
+ "type": "event"
45
+ },
46
+ {
47
+ "anonymous": false,
48
+ "inputs": [
49
+ {
50
+ "indexed": true,
51
+ "internalType": "address",
52
+ "name": "from",
53
+ "type": "address"
54
+ },
55
+ {
56
+ "indexed": true,
57
+ "internalType": "address",
58
+ "name": "to",
59
+ "type": "address"
60
+ },
61
+ {
62
+ "indexed": false,
63
+ "internalType": "uint256",
64
+ "name": "value",
65
+ "type": "uint256"
66
+ }
67
+ ],
68
+ "name": "Transfer",
69
+ "type": "event"
70
+ },
71
+ {
72
+ "inputs": [
73
+ {
74
+ "internalType": "address",
75
+ "name": "owner",
76
+ "type": "address"
77
+ },
78
+ {
79
+ "internalType": "address",
80
+ "name": "spender",
81
+ "type": "address"
82
+ }
83
+ ],
84
+ "name": "allowance",
85
+ "outputs": [
86
+ {
87
+ "internalType": "uint256",
88
+ "name": "",
89
+ "type": "uint256"
90
+ }
91
+ ],
92
+ "stateMutability": "view",
93
+ "type": "function"
94
+ },
95
+ {
96
+ "inputs": [
97
+ {
98
+ "internalType": "address",
99
+ "name": "spender",
100
+ "type": "address"
101
+ },
102
+ {
103
+ "internalType": "uint256",
104
+ "name": "amount",
105
+ "type": "uint256"
106
+ }
107
+ ],
108
+ "name": "approve",
109
+ "outputs": [
110
+ {
111
+ "internalType": "bool",
112
+ "name": "",
113
+ "type": "bool"
114
+ }
115
+ ],
116
+ "stateMutability": "nonpayable",
117
+ "type": "function"
118
+ },
119
+ {
120
+ "inputs": [
121
+ {
122
+ "internalType": "address",
123
+ "name": "account",
124
+ "type": "address"
125
+ }
126
+ ],
127
+ "name": "balanceOf",
128
+ "outputs": [
129
+ {
130
+ "internalType": "uint256",
131
+ "name": "",
132
+ "type": "uint256"
133
+ }
134
+ ],
135
+ "stateMutability": "view",
136
+ "type": "function"
137
+ },
138
+ {
139
+ "inputs": [
140
+ {
141
+ "internalType": "uint256",
142
+ "name": "amount",
143
+ "type": "uint256"
144
+ }
145
+ ],
146
+ "name": "burn",
147
+ "outputs": [],
148
+ "stateMutability": "nonpayable",
149
+ "type": "function"
150
+ },
151
+ {
152
+ "inputs": [
153
+ {
154
+ "internalType": "address",
155
+ "name": "account",
156
+ "type": "address"
157
+ },
158
+ {
159
+ "internalType": "uint256",
160
+ "name": "amount",
161
+ "type": "uint256"
162
+ }
163
+ ],
164
+ "name": "burnFrom",
165
+ "outputs": [],
166
+ "stateMutability": "nonpayable",
167
+ "type": "function"
168
+ },
169
+ {
170
+ "inputs": [],
171
+ "name": "decimals",
172
+ "outputs": [
173
+ {
174
+ "internalType": "uint8",
175
+ "name": "",
176
+ "type": "uint8"
177
+ }
178
+ ],
179
+ "stateMutability": "view",
180
+ "type": "function"
181
+ },
182
+ {
183
+ "inputs": [
184
+ {
185
+ "internalType": "address",
186
+ "name": "spender",
187
+ "type": "address"
188
+ },
189
+ {
190
+ "internalType": "uint256",
191
+ "name": "subtractedValue",
192
+ "type": "uint256"
193
+ }
194
+ ],
195
+ "name": "decreaseAllowance",
196
+ "outputs": [
197
+ {
198
+ "internalType": "bool",
199
+ "name": "",
200
+ "type": "bool"
201
+ }
202
+ ],
203
+ "stateMutability": "nonpayable",
204
+ "type": "function"
205
+ },
206
+ {
207
+ "inputs": [
208
+ {
209
+ "internalType": "address",
210
+ "name": "spender",
211
+ "type": "address"
212
+ },
213
+ {
214
+ "internalType": "uint256",
215
+ "name": "addedValue",
216
+ "type": "uint256"
217
+ }
218
+ ],
219
+ "name": "increaseAllowance",
220
+ "outputs": [
221
+ {
222
+ "internalType": "bool",
223
+ "name": "",
224
+ "type": "bool"
225
+ }
226
+ ],
227
+ "stateMutability": "nonpayable",
228
+ "type": "function"
229
+ },
230
+ {
231
+ "inputs": [],
232
+ "name": "name",
233
+ "outputs": [
234
+ {
235
+ "internalType": "string",
236
+ "name": "",
237
+ "type": "string"
238
+ }
239
+ ],
240
+ "stateMutability": "view",
241
+ "type": "function"
242
+ },
243
+ {
244
+ "inputs": [],
245
+ "name": "symbol",
246
+ "outputs": [
247
+ {
248
+ "internalType": "string",
249
+ "name": "",
250
+ "type": "string"
251
+ }
252
+ ],
253
+ "stateMutability": "view",
254
+ "type": "function"
255
+ },
256
+ {
257
+ "inputs": [],
258
+ "name": "totalSupply",
259
+ "outputs": [
260
+ {
261
+ "internalType": "uint256",
262
+ "name": "",
263
+ "type": "uint256"
264
+ }
265
+ ],
266
+ "stateMutability": "view",
267
+ "type": "function"
268
+ },
269
+ {
270
+ "inputs": [
271
+ {
272
+ "internalType": "address",
273
+ "name": "to",
274
+ "type": "address"
275
+ },
276
+ {
277
+ "internalType": "uint256",
278
+ "name": "amount",
279
+ "type": "uint256"
280
+ }
281
+ ],
282
+ "name": "transfer",
283
+ "outputs": [
284
+ {
285
+ "internalType": "bool",
286
+ "name": "",
287
+ "type": "bool"
288
+ }
289
+ ],
290
+ "stateMutability": "nonpayable",
291
+ "type": "function"
292
+ },
293
+ {
294
+ "inputs": [
295
+ {
296
+ "internalType": "address",
297
+ "name": "from",
298
+ "type": "address"
299
+ },
300
+ {
301
+ "internalType": "address",
302
+ "name": "to",
303
+ "type": "address"
304
+ },
305
+ {
306
+ "internalType": "uint256",
307
+ "name": "amount",
308
+ "type": "uint256"
309
+ }
310
+ ],
311
+ "name": "transferFrom",
312
+ "outputs": [
313
+ {
314
+ "internalType": "bool",
315
+ "name": "",
316
+ "type": "bool"
317
+ }
318
+ ],
319
+ "stateMutability": "nonpayable",
320
+ "type": "function"
321
+ }
322
+ ] as const satisfies Abi;
323
+
324
+ /**
325
+ * Type-safe ABI for ELSERC20_json
326
+ */
327
+ export type ELSERC20_jsonAbi = typeof ELSERC20_jsonAbi;
328
+
329
+ /**
330
+ * Contract instance type for ELSERC20_json
331
+ */
332
+ // Use any for contract type to avoid complex viem type issues
333
+ // The runtime behavior is type-safe through viem's ABI typing
334
+ export type ELSERC20_jsonContract = any;
335
+
336
+ /**
337
+ * ELSERC20_json Contract Class
338
+ *
339
+ * Provides a class-based API similar to TypeChain for interacting with the contract.
340
+ *
341
+ * @example
342
+ * ```typescript
343
+ * import { createPublicClient, createWalletClient, http } from 'viem';
344
+ * import { mainnet } from 'viem/chains';
345
+ * import { ELSERC20_json } from 'ELSERC20_json';
346
+ *
347
+ * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
348
+ * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
349
+ *
350
+ * const contract = new ELSERC20_json('0x...', { publicClient, walletClient });
351
+ *
352
+ * // Read functions
353
+ * const result = await contract.balanceOf('0x...');
354
+ *
355
+ * // Write functions
356
+ * const hash = await contract.transfer('0x...', 1000n);
357
+ *
358
+ * // Simulate transactions (dry-run)
359
+ * const simulation = await contract.simulate.transfer('0x...', 1000n);
360
+ * console.log('Gas estimate:', simulation.request.gas);
361
+ *
362
+ * // Watch events
363
+ * const unwatch = contract.watch.Transfer((event) => {
364
+ * console.log('Transfer event:', event);
365
+ * });
366
+ * ```
367
+ */
368
+ export class ELSERC20_json {
369
+ private contract: ELSERC20_jsonContract;
370
+ private contractAddress: Address;
371
+ private publicClient: PublicClient;
372
+
373
+ constructor(
374
+ address: Address,
375
+ clients: {
376
+ publicClient: PublicClient;
377
+ walletClient?: WalletClient;
378
+ }
379
+ ) {
380
+ this.contractAddress = address;
381
+ this.publicClient = clients.publicClient;
382
+ this.contract = getContract({
383
+ address,
384
+ abi: ELSERC20_jsonAbi,
385
+ client: {
386
+ public: clients.publicClient,
387
+ wallet: clients.walletClient,
388
+ },
389
+ });
390
+ }
391
+
392
+ /**
393
+ * Get the contract address
394
+ */
395
+ get address(): Address {
396
+ return this.contractAddress;
397
+ }
398
+
399
+ /**
400
+ * Get the underlying viem contract instance
401
+ */
402
+ getContract(): ELSERC20_jsonContract {
403
+ return this.contract;
404
+ }
405
+
406
+ /**
407
+ * allowance
408
+ * view
409
+ */
410
+ async allowance(owner: `0x${string}`, spender: `0x${string}`): Promise<bigint> {
411
+ return this.contract.read.allowance([owner, spender] as const) as Promise<bigint>;
412
+ }
413
+
414
+ /**
415
+ * balanceOf
416
+ * view
417
+ */
418
+ async balanceOf(account: `0x${string}`): Promise<bigint> {
419
+ return this.contract.read.balanceOf([account] as const) as Promise<bigint>;
420
+ }
421
+
422
+ /**
423
+ * decimals
424
+ * view
425
+ */
426
+ async decimals(): Promise<bigint> {
427
+ return this.contract.read.decimals() as Promise<bigint>;
428
+ }
429
+
430
+ /**
431
+ * name
432
+ * view
433
+ */
434
+ async name(): Promise<string> {
435
+ return this.contract.read.name() as Promise<string>;
436
+ }
437
+
438
+ /**
439
+ * symbol
440
+ * view
441
+ */
442
+ async symbol(): Promise<string> {
443
+ return this.contract.read.symbol() as Promise<string>;
444
+ }
445
+
446
+ /**
447
+ * totalSupply
448
+ * view
449
+ */
450
+ async totalSupply(): Promise<bigint> {
451
+ return this.contract.read.totalSupply() as Promise<bigint>;
452
+ }
453
+
454
+ /**
455
+ * approve
456
+ * nonpayable
457
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
458
+ */
459
+ async approve(spender: `0x${string}`, amount: bigint, options?: {
460
+ accessList?: import('viem').AccessList;
461
+ authorizationList?: import('viem').AuthorizationList;
462
+ chain?: import('viem').Chain | null;
463
+ dataSuffix?: `0x${string}`;
464
+ gas?: bigint;
465
+ gasPrice?: bigint;
466
+ maxFeePerGas?: bigint;
467
+ maxPriorityFeePerGas?: bigint;
468
+ nonce?: number;
469
+ value?: bigint;
470
+ }): Promise<`0x${string}`> {
471
+ if (!this.contract.write) {
472
+ throw new Error('Wallet client is required for write operations');
473
+ }
474
+ return this.contract.write.approve([spender, amount] as const, options) as Promise<`0x${string}`>;
475
+ }
476
+
477
+ /**
478
+ * burn
479
+ * nonpayable
480
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
481
+ */
482
+ async burn(amount: bigint, options?: {
483
+ accessList?: import('viem').AccessList;
484
+ authorizationList?: import('viem').AuthorizationList;
485
+ chain?: import('viem').Chain | null;
486
+ dataSuffix?: `0x${string}`;
487
+ gas?: bigint;
488
+ gasPrice?: bigint;
489
+ maxFeePerGas?: bigint;
490
+ maxPriorityFeePerGas?: bigint;
491
+ nonce?: number;
492
+ value?: bigint;
493
+ }): Promise<`0x${string}`> {
494
+ if (!this.contract.write) {
495
+ throw new Error('Wallet client is required for write operations');
496
+ }
497
+ return this.contract.write.burn([amount] as const, options) as Promise<`0x${string}`>;
498
+ }
499
+
500
+ /**
501
+ * burnFrom
502
+ * nonpayable
503
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
504
+ */
505
+ async burnFrom(account: `0x${string}`, amount: bigint, options?: {
506
+ accessList?: import('viem').AccessList;
507
+ authorizationList?: import('viem').AuthorizationList;
508
+ chain?: import('viem').Chain | null;
509
+ dataSuffix?: `0x${string}`;
510
+ gas?: bigint;
511
+ gasPrice?: bigint;
512
+ maxFeePerGas?: bigint;
513
+ maxPriorityFeePerGas?: bigint;
514
+ nonce?: number;
515
+ value?: bigint;
516
+ }): Promise<`0x${string}`> {
517
+ if (!this.contract.write) {
518
+ throw new Error('Wallet client is required for write operations');
519
+ }
520
+ return this.contract.write.burnFrom([account, amount] as const, options) as Promise<`0x${string}`>;
521
+ }
522
+
523
+ /**
524
+ * decreaseAllowance
525
+ * nonpayable
526
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
527
+ */
528
+ async decreaseAllowance(spender: `0x${string}`, subtractedValue: bigint, options?: {
529
+ accessList?: import('viem').AccessList;
530
+ authorizationList?: import('viem').AuthorizationList;
531
+ chain?: import('viem').Chain | null;
532
+ dataSuffix?: `0x${string}`;
533
+ gas?: bigint;
534
+ gasPrice?: bigint;
535
+ maxFeePerGas?: bigint;
536
+ maxPriorityFeePerGas?: bigint;
537
+ nonce?: number;
538
+ value?: bigint;
539
+ }): Promise<`0x${string}`> {
540
+ if (!this.contract.write) {
541
+ throw new Error('Wallet client is required for write operations');
542
+ }
543
+ return this.contract.write.decreaseAllowance([spender, subtractedValue] as const, options) as Promise<`0x${string}`>;
544
+ }
545
+
546
+ /**
547
+ * increaseAllowance
548
+ * nonpayable
549
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
550
+ */
551
+ async increaseAllowance(spender: `0x${string}`, addedValue: bigint, options?: {
552
+ accessList?: import('viem').AccessList;
553
+ authorizationList?: import('viem').AuthorizationList;
554
+ chain?: import('viem').Chain | null;
555
+ dataSuffix?: `0x${string}`;
556
+ gas?: bigint;
557
+ gasPrice?: bigint;
558
+ maxFeePerGas?: bigint;
559
+ maxPriorityFeePerGas?: bigint;
560
+ nonce?: number;
561
+ value?: bigint;
562
+ }): Promise<`0x${string}`> {
563
+ if (!this.contract.write) {
564
+ throw new Error('Wallet client is required for write operations');
565
+ }
566
+ return this.contract.write.increaseAllowance([spender, addedValue] as const, options) as Promise<`0x${string}`>;
567
+ }
568
+
569
+ /**
570
+ * transfer
571
+ * nonpayable
572
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
573
+ */
574
+ async transfer(to: `0x${string}`, amount: bigint, options?: {
575
+ accessList?: import('viem').AccessList;
576
+ authorizationList?: import('viem').AuthorizationList;
577
+ chain?: import('viem').Chain | null;
578
+ dataSuffix?: `0x${string}`;
579
+ gas?: bigint;
580
+ gasPrice?: bigint;
581
+ maxFeePerGas?: bigint;
582
+ maxPriorityFeePerGas?: bigint;
583
+ nonce?: number;
584
+ value?: bigint;
585
+ }): Promise<`0x${string}`> {
586
+ if (!this.contract.write) {
587
+ throw new Error('Wallet client is required for write operations');
588
+ }
589
+ return this.contract.write.transfer([to, amount] as const, options) as Promise<`0x${string}`>;
590
+ }
591
+
592
+ /**
593
+ * transferFrom
594
+ * nonpayable
595
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
596
+ */
597
+ async transferFrom(from: `0x${string}`, to: `0x${string}`, amount: bigint, options?: {
598
+ accessList?: import('viem').AccessList;
599
+ authorizationList?: import('viem').AuthorizationList;
600
+ chain?: import('viem').Chain | null;
601
+ dataSuffix?: `0x${string}`;
602
+ gas?: bigint;
603
+ gasPrice?: bigint;
604
+ maxFeePerGas?: bigint;
605
+ maxPriorityFeePerGas?: bigint;
606
+ nonce?: number;
607
+ value?: bigint;
608
+ }): Promise<`0x${string}`> {
609
+ if (!this.contract.write) {
610
+ throw new Error('Wallet client is required for write operations');
611
+ }
612
+ return this.contract.write.transferFrom([from, to, amount] as const, options) as Promise<`0x${string}`>;
613
+ }
614
+
615
+
616
+
617
+ /**
618
+ * Simulate contract write operations (dry-run without sending transaction)
619
+ *
620
+ * @example
621
+ * const result = await contract.simulate.transfer('0x...', 1000n);
622
+ * console.log('Gas estimate:', result.request.gas);
623
+ * console.log('Would succeed:', result.result);
624
+ */
625
+ get simulate() {
626
+ const contract = this.contract;
627
+ if (!contract.simulate) {
628
+ throw new Error('Public client is required for simulation');
629
+ }
630
+ return {
631
+ /**
632
+ * Simulate approve
633
+ * Returns gas estimate and result without sending transaction
634
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
635
+ */
636
+ async approve(spender: `0x${string}`, amount: bigint, options?: {
637
+ accessList?: import('viem').AccessList;
638
+ authorizationList?: import('viem').AuthorizationList;
639
+ chain?: import('viem').Chain | null;
640
+ dataSuffix?: `0x${string}`;
641
+ gas?: bigint;
642
+ gasPrice?: bigint;
643
+ maxFeePerGas?: bigint;
644
+ maxPriorityFeePerGas?: bigint;
645
+ nonce?: number;
646
+ value?: bigint;
647
+ }): Promise<boolean> {
648
+ return contract.simulate.approve([spender, amount] as const, options) as Promise<boolean>;
649
+ },
650
+ /**
651
+ * Simulate burn
652
+ * Returns gas estimate and result without sending transaction
653
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
654
+ */
655
+ async burn(amount: bigint, options?: {
656
+ accessList?: import('viem').AccessList;
657
+ authorizationList?: import('viem').AuthorizationList;
658
+ chain?: import('viem').Chain | null;
659
+ dataSuffix?: `0x${string}`;
660
+ gas?: bigint;
661
+ gasPrice?: bigint;
662
+ maxFeePerGas?: bigint;
663
+ maxPriorityFeePerGas?: bigint;
664
+ nonce?: number;
665
+ value?: bigint;
666
+ }): Promise<void> {
667
+ return contract.simulate.burn([amount] as const, options) as Promise<void>;
668
+ },
669
+ /**
670
+ * Simulate burnFrom
671
+ * Returns gas estimate and result without sending transaction
672
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
673
+ */
674
+ async burnFrom(account: `0x${string}`, amount: bigint, options?: {
675
+ accessList?: import('viem').AccessList;
676
+ authorizationList?: import('viem').AuthorizationList;
677
+ chain?: import('viem').Chain | null;
678
+ dataSuffix?: `0x${string}`;
679
+ gas?: bigint;
680
+ gasPrice?: bigint;
681
+ maxFeePerGas?: bigint;
682
+ maxPriorityFeePerGas?: bigint;
683
+ nonce?: number;
684
+ value?: bigint;
685
+ }): Promise<void> {
686
+ return contract.simulate.burnFrom([account, amount] as const, options) as Promise<void>;
687
+ },
688
+ /**
689
+ * Simulate decreaseAllowance
690
+ * Returns gas estimate and result without sending transaction
691
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
692
+ */
693
+ async decreaseAllowance(spender: `0x${string}`, subtractedValue: bigint, options?: {
694
+ accessList?: import('viem').AccessList;
695
+ authorizationList?: import('viem').AuthorizationList;
696
+ chain?: import('viem').Chain | null;
697
+ dataSuffix?: `0x${string}`;
698
+ gas?: bigint;
699
+ gasPrice?: bigint;
700
+ maxFeePerGas?: bigint;
701
+ maxPriorityFeePerGas?: bigint;
702
+ nonce?: number;
703
+ value?: bigint;
704
+ }): Promise<boolean> {
705
+ return contract.simulate.decreaseAllowance([spender, subtractedValue] as const, options) as Promise<boolean>;
706
+ },
707
+ /**
708
+ * Simulate increaseAllowance
709
+ * Returns gas estimate and result without sending transaction
710
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
711
+ */
712
+ async increaseAllowance(spender: `0x${string}`, addedValue: bigint, options?: {
713
+ accessList?: import('viem').AccessList;
714
+ authorizationList?: import('viem').AuthorizationList;
715
+ chain?: import('viem').Chain | null;
716
+ dataSuffix?: `0x${string}`;
717
+ gas?: bigint;
718
+ gasPrice?: bigint;
719
+ maxFeePerGas?: bigint;
720
+ maxPriorityFeePerGas?: bigint;
721
+ nonce?: number;
722
+ value?: bigint;
723
+ }): Promise<boolean> {
724
+ return contract.simulate.increaseAllowance([spender, addedValue] as const, options) as Promise<boolean>;
725
+ },
726
+ /**
727
+ * Simulate transfer
728
+ * Returns gas estimate and result without sending transaction
729
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
730
+ */
731
+ async transfer(to: `0x${string}`, amount: bigint, options?: {
732
+ accessList?: import('viem').AccessList;
733
+ authorizationList?: import('viem').AuthorizationList;
734
+ chain?: import('viem').Chain | null;
735
+ dataSuffix?: `0x${string}`;
736
+ gas?: bigint;
737
+ gasPrice?: bigint;
738
+ maxFeePerGas?: bigint;
739
+ maxPriorityFeePerGas?: bigint;
740
+ nonce?: number;
741
+ value?: bigint;
742
+ }): Promise<boolean> {
743
+ return contract.simulate.transfer([to, amount] as const, options) as Promise<boolean>;
744
+ },
745
+ /**
746
+ * Simulate transferFrom
747
+ * Returns gas estimate and result without sending transaction
748
+ * @param options Optional transaction parameters (value, gas, nonce, etc.)
749
+ */
750
+ async transferFrom(from: `0x${string}`, to: `0x${string}`, amount: bigint, options?: {
751
+ accessList?: import('viem').AccessList;
752
+ authorizationList?: import('viem').AuthorizationList;
753
+ chain?: import('viem').Chain | null;
754
+ dataSuffix?: `0x${string}`;
755
+ gas?: bigint;
756
+ gasPrice?: bigint;
757
+ maxFeePerGas?: bigint;
758
+ maxPriorityFeePerGas?: bigint;
759
+ nonce?: number;
760
+ value?: bigint;
761
+ }): Promise<boolean> {
762
+ return contract.simulate.transferFrom([from, to, amount] as const, options) as Promise<boolean>;
763
+ }
764
+ };
765
+ }
766
+
767
+ /**
768
+ * Watch contract events
769
+ *
770
+ * @example
771
+ * // Watch all Transfer events
772
+ * const unwatch = contract.watch.Transfer((event) => {
773
+ * console.log('Transfer:', event);
774
+ * });
775
+ *
776
+ * // Stop watching
777
+ * unwatch();
778
+ */
779
+ get watch() {
780
+ return {
781
+ /**
782
+ * Watch Approval events
783
+ * @param callback Function to call when event is emitted
784
+ * @param filter Optional filter for indexed parameters
785
+ * @returns Unwatch function to stop listening
786
+ */
787
+ Approval: (callback: (event: { owner: `0x${string}`; spender: `0x${string}`; value: bigint }) => void, filter?: { owner: `0x${string}`; spender: `0x${string}` }) => {
788
+ return this.publicClient.watchContractEvent({
789
+ address: this.contractAddress,
790
+ abi: ELSERC20_jsonAbi,
791
+ eventName: 'Approval',
792
+ args: filter,
793
+ onLogs: (logs: any[]) => {
794
+ logs.forEach((log: any) => {
795
+ callback(log.args as any);
796
+ });
797
+ },
798
+ }) as () => void;
799
+ },
800
+ /**
801
+ * Watch Transfer events
802
+ * @param callback Function to call when event is emitted
803
+ * @param filter Optional filter for indexed parameters
804
+ * @returns Unwatch function to stop listening
805
+ */
806
+ Transfer: (callback: (event: { from: `0x${string}`; to: `0x${string}`; value: bigint }) => void, filter?: { from: `0x${string}`; to: `0x${string}` }) => {
807
+ return this.publicClient.watchContractEvent({
808
+ address: this.contractAddress,
809
+ abi: ELSERC20_jsonAbi,
810
+ eventName: 'Transfer',
811
+ args: filter,
812
+ onLogs: (logs: any[]) => {
813
+ logs.forEach((log: any) => {
814
+ callback(log.args as any);
815
+ });
816
+ },
817
+ }) as () => void;
818
+ }
819
+ };
820
+ }
821
+ }