@gitmyabi/erc20 1.0.1 → 1.0.2

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,569 +0,0 @@
1
- import type { Address, PublicClient, WalletClient } from 'viem';
2
- /**
3
- * TokenERC20 ABI
4
- *
5
- * This ABI is typed using viem's type system for full type safety.
6
- */
7
- export declare const TokenERC20Abi: readonly [{
8
- readonly constant: true;
9
- readonly inputs: readonly [];
10
- readonly name: "name";
11
- readonly outputs: readonly [{
12
- readonly name: "";
13
- readonly type: "string";
14
- }];
15
- readonly payable: false;
16
- readonly stateMutability: "view";
17
- readonly type: "function";
18
- }, {
19
- readonly constant: false;
20
- readonly inputs: readonly [{
21
- readonly name: "_spender";
22
- readonly type: "address";
23
- }, {
24
- readonly name: "_value";
25
- readonly type: "uint256";
26
- }];
27
- readonly name: "approve";
28
- readonly outputs: readonly [{
29
- readonly name: "success";
30
- readonly type: "bool";
31
- }];
32
- readonly payable: false;
33
- readonly stateMutability: "nonpayable";
34
- readonly type: "function";
35
- }, {
36
- readonly constant: true;
37
- readonly inputs: readonly [];
38
- readonly name: "totalSupply";
39
- readonly outputs: readonly [{
40
- readonly name: "";
41
- readonly type: "uint256";
42
- }];
43
- readonly payable: false;
44
- readonly stateMutability: "view";
45
- readonly type: "function";
46
- }, {
47
- readonly constant: false;
48
- readonly inputs: readonly [{
49
- readonly name: "_from";
50
- readonly type: "address";
51
- }, {
52
- readonly name: "_to";
53
- readonly type: "address";
54
- }, {
55
- readonly name: "_value";
56
- readonly type: "uint256";
57
- }];
58
- readonly name: "transferFrom";
59
- readonly outputs: readonly [{
60
- readonly name: "success";
61
- readonly type: "bool";
62
- }];
63
- readonly payable: false;
64
- readonly stateMutability: "nonpayable";
65
- readonly type: "function";
66
- }, {
67
- readonly constant: true;
68
- readonly inputs: readonly [];
69
- readonly name: "decimals";
70
- readonly outputs: readonly [{
71
- readonly name: "";
72
- readonly type: "uint8";
73
- }];
74
- readonly payable: false;
75
- readonly stateMutability: "view";
76
- readonly type: "function";
77
- }, {
78
- readonly constant: false;
79
- readonly inputs: readonly [{
80
- readonly name: "_value";
81
- readonly type: "uint256";
82
- }];
83
- readonly name: "burn";
84
- readonly outputs: readonly [{
85
- readonly name: "success";
86
- readonly type: "bool";
87
- }];
88
- readonly payable: false;
89
- readonly stateMutability: "nonpayable";
90
- readonly type: "function";
91
- }, {
92
- readonly constant: true;
93
- readonly inputs: readonly [{
94
- readonly name: "";
95
- readonly type: "address";
96
- }];
97
- readonly name: "balanceOf";
98
- readonly outputs: readonly [{
99
- readonly name: "";
100
- readonly type: "uint256";
101
- }];
102
- readonly payable: false;
103
- readonly stateMutability: "view";
104
- readonly type: "function";
105
- }, {
106
- readonly constant: false;
107
- readonly inputs: readonly [{
108
- readonly name: "_from";
109
- readonly type: "address";
110
- }, {
111
- readonly name: "_value";
112
- readonly type: "uint256";
113
- }];
114
- readonly name: "burnFrom";
115
- readonly outputs: readonly [{
116
- readonly name: "success";
117
- readonly type: "bool";
118
- }];
119
- readonly payable: false;
120
- readonly stateMutability: "nonpayable";
121
- readonly type: "function";
122
- }, {
123
- readonly constant: true;
124
- readonly inputs: readonly [];
125
- readonly name: "symbol";
126
- readonly outputs: readonly [{
127
- readonly name: "";
128
- readonly type: "string";
129
- }];
130
- readonly payable: false;
131
- readonly stateMutability: "view";
132
- readonly type: "function";
133
- }, {
134
- readonly constant: false;
135
- readonly inputs: readonly [{
136
- readonly name: "_to";
137
- readonly type: "address";
138
- }, {
139
- readonly name: "_value";
140
- readonly type: "uint256";
141
- }];
142
- readonly name: "transfer";
143
- readonly outputs: readonly [];
144
- readonly payable: false;
145
- readonly stateMutability: "nonpayable";
146
- readonly type: "function";
147
- }, {
148
- readonly constant: false;
149
- readonly inputs: readonly [{
150
- readonly name: "_spender";
151
- readonly type: "address";
152
- }, {
153
- readonly name: "_value";
154
- readonly type: "uint256";
155
- }, {
156
- readonly name: "_extraData";
157
- readonly type: "bytes";
158
- }];
159
- readonly name: "approveAndCall";
160
- readonly outputs: readonly [{
161
- readonly name: "success";
162
- readonly type: "bool";
163
- }];
164
- readonly payable: false;
165
- readonly stateMutability: "nonpayable";
166
- readonly type: "function";
167
- }, {
168
- readonly constant: true;
169
- readonly inputs: readonly [{
170
- readonly name: "";
171
- readonly type: "address";
172
- }, {
173
- readonly name: "";
174
- readonly type: "address";
175
- }];
176
- readonly name: "allowance";
177
- readonly outputs: readonly [{
178
- readonly name: "";
179
- readonly type: "uint256";
180
- }];
181
- readonly payable: false;
182
- readonly stateMutability: "view";
183
- readonly type: "function";
184
- }, {
185
- readonly inputs: readonly [{
186
- readonly name: "initialSupply";
187
- readonly type: "uint256";
188
- }, {
189
- readonly name: "tokenName";
190
- readonly type: "string";
191
- }, {
192
- readonly name: "tokenSymbol";
193
- readonly type: "string";
194
- }];
195
- readonly payable: false;
196
- readonly stateMutability: "nonpayable";
197
- readonly type: "constructor";
198
- }, {
199
- readonly anonymous: false;
200
- readonly inputs: readonly [{
201
- readonly indexed: true;
202
- readonly name: "from";
203
- readonly type: "address";
204
- }, {
205
- readonly indexed: true;
206
- readonly name: "to";
207
- readonly type: "address";
208
- }, {
209
- readonly indexed: false;
210
- readonly name: "value";
211
- readonly type: "uint256";
212
- }];
213
- readonly name: "Transfer";
214
- readonly type: "event";
215
- }, {
216
- readonly anonymous: false;
217
- readonly inputs: readonly [{
218
- readonly indexed: true;
219
- readonly name: "from";
220
- readonly type: "address";
221
- }, {
222
- readonly indexed: false;
223
- readonly name: "value";
224
- readonly type: "uint256";
225
- }];
226
- readonly name: "Burn";
227
- readonly type: "event";
228
- }];
229
- /**
230
- * Type-safe ABI for TokenERC20
231
- */
232
- export type TokenERC20Abi = typeof TokenERC20Abi;
233
- /**
234
- * Contract instance type for TokenERC20
235
- */
236
- export type TokenERC20Contract = any;
237
- /**
238
- * TokenERC20 Contract Class
239
- *
240
- * Provides a class-based API similar to TypeChain for interacting with the contract.
241
- *
242
- * @example
243
- * ```typescript
244
- * import { createPublicClient, createWalletClient, http } from 'viem';
245
- * import { mainnet } from 'viem/chains';
246
- * import { TokenERC20 } from 'TokenERC20';
247
- *
248
- * const publicClient = createPublicClient({ chain: mainnet, transport: http() });
249
- * const walletClient = createWalletClient({ chain: mainnet, transport: http() });
250
- *
251
- * const contract = new TokenERC20('0x...', { publicClient, walletClient });
252
- *
253
- * // Read functions
254
- * const result = await contract.balanceOf('0x...');
255
- *
256
- * // Write functions
257
- * const hash = await contract.transfer('0x...', 1000n);
258
- *
259
- * // Simulate transactions (dry-run)
260
- * const simulation = await contract.simulate.transfer('0x...', 1000n);
261
- * console.log('Gas estimate:', simulation.request.gas);
262
- *
263
- * // Watch events
264
- * const unwatch = contract.watch.Transfer((event) => {
265
- * console.log('Transfer event:', event);
266
- * });
267
- * ```
268
- */
269
- export declare class TokenERC20 {
270
- private contract;
271
- private contractAddress;
272
- private publicClient;
273
- constructor(address: Address, clients: {
274
- publicClient: PublicClient;
275
- walletClient?: WalletClient;
276
- });
277
- /**
278
- * Get the contract address
279
- */
280
- get address(): Address;
281
- /**
282
- * Get the underlying viem contract instance.
283
- */
284
- getContract(): TokenERC20Contract;
285
- /**
286
- * name
287
- * view
288
- */
289
- name(): Promise<string>;
290
- /**
291
- * totalSupply
292
- * view
293
- */
294
- totalSupply(): Promise<bigint>;
295
- /**
296
- * decimals
297
- * view
298
- */
299
- decimals(): Promise<bigint>;
300
- /**
301
- * balanceOf
302
- * view
303
- */
304
- balanceOf(arg0: `0x${string}`): Promise<bigint>;
305
- /**
306
- * symbol
307
- * view
308
- */
309
- symbol(): Promise<string>;
310
- /**
311
- * allowance
312
- * view
313
- */
314
- allowance(arg0: `0x${string}`, arg1: `0x${string}`): Promise<bigint>;
315
- /**
316
- * approve
317
- * nonpayable
318
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
319
- */
320
- approve(_spender: `0x${string}`, _value: bigint, options?: {
321
- accessList?: import('viem').AccessList;
322
- authorizationList?: import('viem').AuthorizationList;
323
- chain?: import('viem').Chain | null;
324
- dataSuffix?: `0x${string}`;
325
- gas?: bigint;
326
- gasPrice?: bigint;
327
- maxFeePerGas?: bigint;
328
- maxPriorityFeePerGas?: bigint;
329
- nonce?: number;
330
- value?: bigint;
331
- }): Promise<`0x${string}`>;
332
- /**
333
- * transferFrom
334
- * nonpayable
335
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
336
- */
337
- transferFrom(_from: `0x${string}`, _to: `0x${string}`, _value: bigint, options?: {
338
- accessList?: import('viem').AccessList;
339
- authorizationList?: import('viem').AuthorizationList;
340
- chain?: import('viem').Chain | null;
341
- dataSuffix?: `0x${string}`;
342
- gas?: bigint;
343
- gasPrice?: bigint;
344
- maxFeePerGas?: bigint;
345
- maxPriorityFeePerGas?: bigint;
346
- nonce?: number;
347
- value?: bigint;
348
- }): Promise<`0x${string}`>;
349
- /**
350
- * burn
351
- * nonpayable
352
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
353
- */
354
- burn(_value: bigint, options?: {
355
- accessList?: import('viem').AccessList;
356
- authorizationList?: import('viem').AuthorizationList;
357
- chain?: import('viem').Chain | null;
358
- dataSuffix?: `0x${string}`;
359
- gas?: bigint;
360
- gasPrice?: bigint;
361
- maxFeePerGas?: bigint;
362
- maxPriorityFeePerGas?: bigint;
363
- nonce?: number;
364
- value?: bigint;
365
- }): Promise<`0x${string}`>;
366
- /**
367
- * burnFrom
368
- * nonpayable
369
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
370
- */
371
- burnFrom(_from: `0x${string}`, _value: bigint, options?: {
372
- accessList?: import('viem').AccessList;
373
- authorizationList?: import('viem').AuthorizationList;
374
- chain?: import('viem').Chain | null;
375
- dataSuffix?: `0x${string}`;
376
- gas?: bigint;
377
- gasPrice?: bigint;
378
- maxFeePerGas?: bigint;
379
- maxPriorityFeePerGas?: bigint;
380
- nonce?: number;
381
- value?: bigint;
382
- }): Promise<`0x${string}`>;
383
- /**
384
- * transfer
385
- * nonpayable
386
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
387
- */
388
- transfer(_to: `0x${string}`, _value: bigint, options?: {
389
- accessList?: import('viem').AccessList;
390
- authorizationList?: import('viem').AuthorizationList;
391
- chain?: import('viem').Chain | null;
392
- dataSuffix?: `0x${string}`;
393
- gas?: bigint;
394
- gasPrice?: bigint;
395
- maxFeePerGas?: bigint;
396
- maxPriorityFeePerGas?: bigint;
397
- nonce?: number;
398
- value?: bigint;
399
- }): Promise<`0x${string}`>;
400
- /**
401
- * approveAndCall
402
- * nonpayable
403
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
404
- */
405
- approveAndCall(_spender: `0x${string}`, _value: bigint, _extraData: `0x${string}`, options?: {
406
- accessList?: import('viem').AccessList;
407
- authorizationList?: import('viem').AuthorizationList;
408
- chain?: import('viem').Chain | null;
409
- dataSuffix?: `0x${string}`;
410
- gas?: bigint;
411
- gasPrice?: bigint;
412
- maxFeePerGas?: bigint;
413
- maxPriorityFeePerGas?: bigint;
414
- nonce?: number;
415
- value?: bigint;
416
- }): Promise<`0x${string}`>;
417
- /**
418
- * Simulate contract write operations (dry-run without sending transaction)
419
- *
420
- * @example
421
- * const result = await contract.simulate.transfer('0x...', 1000n);
422
- * console.log('Gas estimate:', result.request.gas);
423
- * console.log('Would succeed:', result.result);
424
- */
425
- get simulate(): {
426
- /**
427
- * Simulate approve
428
- * Returns gas estimate and result without sending transaction
429
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
430
- */
431
- approve(_spender: `0x${string}`, _value: bigint, options?: {
432
- accessList?: import("viem").AccessList;
433
- authorizationList?: import("viem").AuthorizationList;
434
- chain?: import("viem").Chain | null;
435
- dataSuffix?: `0x${string}`;
436
- gas?: bigint;
437
- gasPrice?: bigint;
438
- maxFeePerGas?: bigint;
439
- maxPriorityFeePerGas?: bigint;
440
- nonce?: number;
441
- value?: bigint;
442
- }): Promise<boolean>;
443
- /**
444
- * Simulate transferFrom
445
- * Returns gas estimate and result without sending transaction
446
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
447
- */
448
- transferFrom(_from: `0x${string}`, _to: `0x${string}`, _value: bigint, options?: {
449
- accessList?: import("viem").AccessList;
450
- authorizationList?: import("viem").AuthorizationList;
451
- chain?: import("viem").Chain | null;
452
- dataSuffix?: `0x${string}`;
453
- gas?: bigint;
454
- gasPrice?: bigint;
455
- maxFeePerGas?: bigint;
456
- maxPriorityFeePerGas?: bigint;
457
- nonce?: number;
458
- value?: bigint;
459
- }): Promise<boolean>;
460
- /**
461
- * Simulate burn
462
- * Returns gas estimate and result without sending transaction
463
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
464
- */
465
- burn(_value: bigint, options?: {
466
- accessList?: import("viem").AccessList;
467
- authorizationList?: import("viem").AuthorizationList;
468
- chain?: import("viem").Chain | null;
469
- dataSuffix?: `0x${string}`;
470
- gas?: bigint;
471
- gasPrice?: bigint;
472
- maxFeePerGas?: bigint;
473
- maxPriorityFeePerGas?: bigint;
474
- nonce?: number;
475
- value?: bigint;
476
- }): Promise<boolean>;
477
- /**
478
- * Simulate burnFrom
479
- * Returns gas estimate and result without sending transaction
480
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
481
- */
482
- burnFrom(_from: `0x${string}`, _value: bigint, options?: {
483
- accessList?: import("viem").AccessList;
484
- authorizationList?: import("viem").AuthorizationList;
485
- chain?: import("viem").Chain | null;
486
- dataSuffix?: `0x${string}`;
487
- gas?: bigint;
488
- gasPrice?: bigint;
489
- maxFeePerGas?: bigint;
490
- maxPriorityFeePerGas?: bigint;
491
- nonce?: number;
492
- value?: bigint;
493
- }): Promise<boolean>;
494
- /**
495
- * Simulate transfer
496
- * Returns gas estimate and result without sending transaction
497
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
498
- */
499
- transfer(_to: `0x${string}`, _value: bigint, options?: {
500
- accessList?: import("viem").AccessList;
501
- authorizationList?: import("viem").AuthorizationList;
502
- chain?: import("viem").Chain | null;
503
- dataSuffix?: `0x${string}`;
504
- gas?: bigint;
505
- gasPrice?: bigint;
506
- maxFeePerGas?: bigint;
507
- maxPriorityFeePerGas?: bigint;
508
- nonce?: number;
509
- value?: bigint;
510
- }): Promise<void>;
511
- /**
512
- * Simulate approveAndCall
513
- * Returns gas estimate and result without sending transaction
514
- * @param options Optional transaction parameters (value, gas, nonce, etc.)
515
- */
516
- approveAndCall(_spender: `0x${string}`, _value: bigint, _extraData: `0x${string}`, options?: {
517
- accessList?: import("viem").AccessList;
518
- authorizationList?: import("viem").AuthorizationList;
519
- chain?: import("viem").Chain | null;
520
- dataSuffix?: `0x${string}`;
521
- gas?: bigint;
522
- gasPrice?: bigint;
523
- maxFeePerGas?: bigint;
524
- maxPriorityFeePerGas?: bigint;
525
- nonce?: number;
526
- value?: bigint;
527
- }): Promise<boolean>;
528
- };
529
- /**
530
- * Watch contract events
531
- *
532
- * @example
533
- * // Watch all Transfer events
534
- * const unwatch = contract.watch.Transfer((event) => {
535
- * console.log('Transfer:', event);
536
- * });
537
- *
538
- * // Stop watching
539
- * unwatch();
540
- */
541
- get watch(): {
542
- /**
543
- * Watch Transfer events
544
- * @param callback Function to call when event is emitted
545
- * @param filter Optional filter for indexed parameters
546
- * @returns Unwatch function to stop listening
547
- */
548
- Transfer: (callback: (event: {
549
- from: `0x${string}`;
550
- to: `0x${string}`;
551
- value: bigint;
552
- }) => void, filter?: {
553
- from?: `0x${string}` | `0x${string}`[] | null;
554
- to?: `0x${string}` | `0x${string}`[] | null;
555
- }) => () => void;
556
- /**
557
- * Watch Burn events
558
- * @param callback Function to call when event is emitted
559
- * @param filter Optional filter for indexed parameters
560
- * @returns Unwatch function to stop listening
561
- */
562
- Burn: (callback: (event: {
563
- from: `0x${string}`;
564
- value: bigint;
565
- }) => void, filter?: {
566
- from?: `0x${string}` | `0x${string}`[] | null;
567
- }) => () => void;
568
- };
569
- }