@gitmyabi-stg/wif 0.0.1

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