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