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