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