@gitmyabi/usd 1.0.1 → 1.0.3

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