starknet 4.8.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +46 -0
- package/README.md +1 -3
- package/__mocks__/ERC20.json +32561 -29055
- package/__tests__/account.test.ts +32 -24
- package/__tests__/contract.test.ts +25 -14
- package/__tests__/defaultProvider.test.ts +91 -240
- package/__tests__/fixtures.ts +10 -2
- package/__tests__/rpcProvider.test.ts +8 -16
- package/__tests__/sequencerProvider.test.ts +17 -10
- package/__tests__/udc.test.ts +41 -0
- package/__tests__/utils/merkle.test.ts +98 -3
- package/__tests__/utils/typedData.test.ts +3 -3
- package/account/default.d.ts +12 -44
- package/account/default.js +305 -61
- package/account/interface.d.ts +96 -8
- package/constants.d.ts +8 -1
- package/constants.js +8 -1
- package/contract/default.d.ts +11 -27
- package/contract/default.js +105 -121
- package/contract/interface.d.ts +5 -2
- package/dist/account/default.d.ts +12 -44
- package/dist/account/default.js +305 -61
- package/dist/account/interface.d.ts +96 -8
- package/dist/constants.d.ts +8 -1
- package/dist/constants.js +8 -1
- package/dist/contract/default.d.ts +11 -27
- package/dist/contract/default.js +105 -121
- package/dist/contract/interface.d.ts +5 -2
- package/dist/provider/default.d.ts +8 -3
- package/dist/provider/default.js +31 -4
- package/dist/provider/interface.d.ts +67 -5
- package/dist/provider/rpc.d.ts +10 -3
- package/dist/provider/rpc.js +98 -10
- package/dist/provider/sequencer.d.ts +11 -4
- package/dist/provider/sequencer.js +89 -18
- package/dist/signer/default.d.ts +5 -2
- package/dist/signer/default.js +25 -3
- package/dist/signer/interface.d.ts +29 -2
- package/dist/types/api/index.d.ts +0 -6
- package/dist/types/api/openrpc.d.ts +24 -2
- package/dist/types/api/sequencer.d.ts +22 -7
- package/dist/types/index.d.ts +1 -1
- package/dist/types/lib.d.ts +36 -2
- package/dist/types/provider.d.ts +15 -10
- package/dist/types/signer.d.ts +14 -1
- package/dist/utils/hash.d.ts +2 -0
- package/dist/utils/hash.js +13 -2
- package/dist/utils/merkle.js +2 -4
- package/dist/utils/number.d.ts +1 -0
- package/dist/utils/number.js +3 -1
- package/dist/utils/responseParser/rpc.d.ts +2 -6
- package/dist/utils/responseParser/rpc.js +0 -11
- package/dist/utils/responseParser/sequencer.js +4 -14
- package/package.json +1 -1
- package/provider/default.d.ts +8 -3
- package/provider/default.js +31 -4
- package/provider/interface.d.ts +67 -5
- package/provider/rpc.d.ts +10 -3
- package/provider/rpc.js +98 -10
- package/provider/sequencer.d.ts +11 -4
- package/provider/sequencer.js +89 -18
- package/signer/default.d.ts +5 -2
- package/signer/default.js +25 -3
- package/signer/interface.d.ts +29 -2
- package/src/account/default.ts +243 -55
- package/src/account/interface.ts +132 -7
- package/src/constants.ts +8 -0
- package/src/contract/default.ts +124 -141
- package/src/contract/interface.ts +5 -2
- package/src/provider/default.ts +43 -5
- package/src/provider/interface.ts +92 -7
- package/src/provider/rpc.ts +93 -15
- package/src/provider/sequencer.ts +87 -14
- package/src/signer/default.ts +56 -4
- package/src/signer/interface.ts +33 -2
- package/src/types/api/index.ts +0 -4
- package/src/types/api/openrpc.ts +28 -2
- package/src/types/api/sequencer.ts +32 -9
- package/src/types/index.ts +1 -1
- package/src/types/lib.ts +43 -2
- package/src/types/provider.ts +27 -11
- package/src/types/signer.ts +18 -1
- package/src/utils/hash.ts +46 -1
- package/src/utils/merkle.ts +2 -4
- package/src/utils/number.ts +2 -0
- package/src/utils/responseParser/rpc.ts +4 -20
- package/src/utils/responseParser/sequencer.ts +2 -0
- package/types/api/index.d.ts +0 -6
- package/types/api/openrpc.d.ts +24 -2
- package/types/api/sequencer.d.ts +22 -7
- package/types/index.d.ts +1 -1
- package/types/lib.d.ts +36 -2
- package/types/provider.d.ts +15 -10
- package/types/signer.d.ts +14 -1
- package/utils/hash.d.ts +2 -0
- package/utils/hash.js +13 -2
- package/utils/merkle.js +2 -4
- package/utils/number.d.ts +1 -0
- package/utils/number.js +3 -1
- package/utils/responseParser/rpc.d.ts +2 -6
- package/utils/responseParser/rpc.js +0 -11
- package/utils/responseParser/sequencer.js +4 -14
- package/www/docs/API/account.md +170 -11
- package/www/docs/API/contract.md +39 -3
- package/www/docs/API/provider.md +310 -17
- package/www/docs/API/signer.md +56 -2
- package/www/guides/erc20.md +13 -7
package/www/docs/API/provider.md
CHANGED
|
@@ -8,7 +8,9 @@ The **Provider** API allows you to interact with the StarkNet network, without s
|
|
|
8
8
|
|
|
9
9
|
Typically, these are _read_ calls on the blockchain.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Default Provider
|
|
12
|
+
|
|
13
|
+
### Creating an instance
|
|
12
14
|
|
|
13
15
|
`new starknet.Provider(optionsOrProvider)`
|
|
14
16
|
|
|
@@ -53,7 +55,13 @@ These are also the default options for the Provider constructor with `network: '
|
|
|
53
55
|
>
|
|
54
56
|
> `network` arguement should work in most cases. If you want to use the `sequencer` arguement with `baseUrl`, you will not be able to use the `network` field in the object.
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
### Methods
|
|
59
|
+
|
|
60
|
+
<hr/>
|
|
61
|
+
|
|
62
|
+
provider.**getChainId**() => _Promise < StarknetChainId >_
|
|
63
|
+
|
|
64
|
+
Returns the chain Id for the current network.
|
|
57
65
|
|
|
58
66
|
<hr/>
|
|
59
67
|
|
|
@@ -117,6 +125,28 @@ Gets the contract class of the deployed contract.
|
|
|
117
125
|
|
|
118
126
|
<hr/>
|
|
119
127
|
|
|
128
|
+
provider.**getInvokeEstimateFee**(invocationWithTxType, invocationDetails, blockIdentifier) => _Promise < EstimateFeeResponse >_
|
|
129
|
+
|
|
130
|
+
Estimate fee for invoke transaction.
|
|
131
|
+
|
|
132
|
+
###### _EstimateFeeResponse_
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
{
|
|
136
|
+
overall_fee: BN;
|
|
137
|
+
gas_consumed?: BN;
|
|
138
|
+
gas_price?: BN;
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
<hr/>
|
|
143
|
+
|
|
144
|
+
provider.**getNonce**(contractAddress, blockIdentifier) => _Promise < BigNumberish >_
|
|
145
|
+
|
|
146
|
+
Gets the nonce of the provided contractAddress.
|
|
147
|
+
|
|
148
|
+
<hr/>
|
|
149
|
+
|
|
120
150
|
provider.**getStorageAt**(contractAddress, key, blockIdentifier) => _Promise < string >_
|
|
121
151
|
|
|
122
152
|
Gets the contract's storage variable at a specific key.
|
|
@@ -166,9 +196,24 @@ Gets the transaction information from a tx hash.
|
|
|
166
196
|
|
|
167
197
|
<hr/>
|
|
168
198
|
|
|
169
|
-
provider.**
|
|
199
|
+
provider.**deployContract**(payload [ , abi ]) => _Promise < DeployContractResponse >_
|
|
200
|
+
|
|
201
|
+
Deploys a contract on Starknet.
|
|
202
|
+
|
|
203
|
+
###### _DeployContractResponse_
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
{
|
|
207
|
+
transaction_hash: string;
|
|
208
|
+
contract_address: string;
|
|
209
|
+
};
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
<hr/>
|
|
213
|
+
|
|
214
|
+
provider.**declareContract**(transaction, details) => _Promise < DeclareContractResponse >_
|
|
170
215
|
|
|
171
|
-
|
|
216
|
+
Declare a contract on Starknet.
|
|
172
217
|
|
|
173
218
|
###### _DeclareContractResponse_
|
|
174
219
|
|
|
@@ -181,16 +226,17 @@ Declares a contract on Starknet.
|
|
|
181
226
|
|
|
182
227
|
<hr/>
|
|
183
228
|
|
|
184
|
-
provider.**
|
|
229
|
+
provider.**getDeclareEstimateFee**(transaction, details, blockIdentifier) => _Promise < EstimateFeeResponse >_
|
|
185
230
|
|
|
186
|
-
|
|
231
|
+
Estimate fee for declare transaction.
|
|
187
232
|
|
|
188
|
-
######
|
|
233
|
+
###### _EstimateFeeResponse_
|
|
189
234
|
|
|
190
235
|
```typescript
|
|
191
236
|
{
|
|
192
|
-
|
|
193
|
-
|
|
237
|
+
overall_fee: BN;
|
|
238
|
+
gas_consumed?: BN;
|
|
239
|
+
gas_price?: BN;
|
|
194
240
|
};
|
|
195
241
|
```
|
|
196
242
|
|
|
@@ -200,9 +246,11 @@ provider.**waitForTransaction**(txHash [ , retryInterval]) => _Promise < void >_
|
|
|
200
246
|
|
|
201
247
|
Wait for the transaction to be accepted on L2 or L1.
|
|
202
248
|
|
|
203
|
-
|
|
249
|
+
## SequencerProvider
|
|
250
|
+
|
|
251
|
+
On top of methods found in the [Default Provider](#default-provider) section, `SequencerProvider` has some additional ones you can use.
|
|
204
252
|
|
|
205
|
-
|
|
253
|
+
### Creating an instance
|
|
206
254
|
|
|
207
255
|
`new starknet.SequencerProvider(optionsOrProvider)`
|
|
208
256
|
|
|
@@ -211,27 +259,31 @@ The options for the provider depend on the network. The structure of the options
|
|
|
211
259
|
- options.**baseUrl** - Base URL of the network
|
|
212
260
|
- options.**feederGatewayUrl** - Feeder Gateway Endpoint of the network
|
|
213
261
|
- options.**gatewayUrl** - Gateway Endpoint
|
|
262
|
+
- options.**headers** - [Optional] custom fetch headers
|
|
214
263
|
|
|
215
264
|
or
|
|
216
265
|
|
|
217
266
|
- options.**network** - Either 'mainnet-alpha' or 'goerli-alpha'
|
|
267
|
+
- options.**headers** - [Optional] custom fetch headers
|
|
218
268
|
|
|
219
269
|
Example:
|
|
220
270
|
|
|
221
271
|
```typescript
|
|
222
|
-
const provider = new starknet.
|
|
272
|
+
const provider = new starknet.SequencerProvider({
|
|
223
273
|
baseUrl: 'https://alpha4.starknet.io',
|
|
224
274
|
feederGatewayUrl: 'feeder_gateway',
|
|
225
275
|
gatewayUrl: 'gateway',
|
|
226
276
|
})
|
|
227
277
|
```
|
|
228
278
|
|
|
229
|
-
|
|
279
|
+
### Methods
|
|
230
280
|
|
|
231
|
-
|
|
281
|
+
<hr/>
|
|
232
282
|
|
|
233
283
|
provider.**getContractAddresses**() => _Promise < GetContractAddressesResponse >_
|
|
234
284
|
|
|
285
|
+
Gets the smart contract address on the network.
|
|
286
|
+
|
|
235
287
|
###### _GetContractAddressesResponse_
|
|
236
288
|
|
|
237
289
|
```typescript
|
|
@@ -243,6 +295,48 @@ provider.**getContractAddresses**() => _Promise < GetContractAddressesResponse >
|
|
|
243
295
|
|
|
244
296
|
<hr/>
|
|
245
297
|
|
|
298
|
+
provider.**getCode**(contractAddress, blockIdentifier) => _Promise < GetCodeResponse >_
|
|
299
|
+
|
|
300
|
+
Gets the smart contract address on the network.
|
|
301
|
+
|
|
302
|
+
###### _GetCodeResponse_
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
{
|
|
306
|
+
bytecode: string[];
|
|
307
|
+
abi: Abi;
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
<hr/>
|
|
312
|
+
|
|
313
|
+
provider.**estimateMessageFee**(CallL1Handler, blockIdentifier) => _Promise < EstimateFeeResponse >_
|
|
314
|
+
|
|
315
|
+
Estimate fee for sending a message to L1.
|
|
316
|
+
|
|
317
|
+
##### _CallL1Handler_
|
|
318
|
+
|
|
319
|
+
````typescript
|
|
320
|
+
type CallL1Handler = {
|
|
321
|
+
from_address: getDecimalString(from_address),
|
|
322
|
+
to_address: getHexString(to_address),
|
|
323
|
+
entry_point_selector: getSelector(entry_point_selector),
|
|
324
|
+
payload: getHexStringArray(payload),
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
###### _EstimateFeeResponse_
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
{
|
|
331
|
+
overall_fee: number;
|
|
332
|
+
gas_price: number;
|
|
333
|
+
gas_usage: number;
|
|
334
|
+
unit: string;
|
|
335
|
+
}
|
|
336
|
+
````
|
|
337
|
+
|
|
338
|
+
<hr/>
|
|
339
|
+
|
|
246
340
|
provider.**getTransactionStatus**(txHash) => _Promise < GetTransactionStatusResponse >_
|
|
247
341
|
|
|
248
342
|
Gets the status of a transaction.
|
|
@@ -297,13 +391,15 @@ Gets the transaction trace from a tx hash.
|
|
|
297
391
|
}
|
|
298
392
|
```
|
|
299
393
|
|
|
300
|
-
|
|
394
|
+
## RpcProvider
|
|
301
395
|
|
|
302
|
-
|
|
396
|
+
### Creating an instance
|
|
303
397
|
|
|
304
398
|
`new starknet.RpcProvider(options)`
|
|
305
399
|
|
|
306
400
|
- options.**nodeUrl** - Starknet RPC node url
|
|
401
|
+
- options.**headers** - [Optional] custom fetch headers
|
|
402
|
+
- options.**retries** - [Optional] wait for transaction max retries
|
|
307
403
|
|
|
308
404
|
Example:
|
|
309
405
|
|
|
@@ -313,7 +409,60 @@ const provider = new starknet.RpcProvider({
|
|
|
313
409
|
})
|
|
314
410
|
```
|
|
315
411
|
|
|
316
|
-
|
|
412
|
+
### Methods
|
|
413
|
+
|
|
414
|
+
<hr/>
|
|
415
|
+
|
|
416
|
+
provider.**fetch**(method: any, params: any) => _Promise < any >_
|
|
417
|
+
|
|
418
|
+
Generic method for users to be able to experiment with RPC methods.
|
|
419
|
+
|
|
420
|
+
<hr/>
|
|
421
|
+
|
|
422
|
+
provider.**getChainId**() => _Promise < any >_
|
|
423
|
+
|
|
424
|
+
<hr/>
|
|
425
|
+
|
|
426
|
+
provider.**getBlock**(blockIdentifier) => _Promise < GetBlockResponse >_
|
|
427
|
+
|
|
428
|
+
<hr/>
|
|
429
|
+
|
|
430
|
+
provider.**getBlockHashAndNumber**() => _Promise < BlockHashAndNumber >_
|
|
431
|
+
|
|
432
|
+
###### _BlockHashAndNumber_
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
{
|
|
436
|
+
block_hash: BLOCK_HASH;
|
|
437
|
+
block_number: BLOCK_NUMBER;
|
|
438
|
+
}
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
<hr/>
|
|
442
|
+
|
|
443
|
+
provider.**getBlockWithTxHashes**(blockIdentifier) => _Promise < GetBlockWithTxHashesResponse >_
|
|
444
|
+
|
|
445
|
+
###### _GetBlockWithTxHashesResponse_
|
|
446
|
+
|
|
447
|
+
```typescript
|
|
448
|
+
OPENRPC.BlockWithTxHashes
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
<hr/>
|
|
452
|
+
|
|
453
|
+
provider.**getBlockWithTxs**(blockIdentifier) => _Promise < GetBlockWithTxs >_
|
|
454
|
+
|
|
455
|
+
###### _GetBlockWithTxs_
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
OPENRPC.BlockWithTxs
|
|
459
|
+
```
|
|
460
|
+
|
|
461
|
+
<hr/>
|
|
462
|
+
|
|
463
|
+
provider.**getClassHashAt**(blockIdentifier) => _Promise < ContractAddress >_
|
|
464
|
+
|
|
465
|
+
<hr/>
|
|
317
466
|
|
|
318
467
|
provider.**getTransactionCount**(blockIdentifier) => _Promise < number >_
|
|
319
468
|
|
|
@@ -333,6 +482,148 @@ Gets the nonce of the provided contractAddress
|
|
|
333
482
|
|
|
334
483
|
<hr/>
|
|
335
484
|
|
|
485
|
+
provider.**getPendingTransactions**() => _Promise < PendingTransactions >_
|
|
486
|
+
|
|
487
|
+
###### _PendingTransactions_
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
OPENRPC.PendingTransactions;
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
<hr/>
|
|
494
|
+
|
|
495
|
+
provider.**getStateUpdate**(blockIdentifier) => _Promise < StateUpdate >_
|
|
496
|
+
|
|
497
|
+
###### _StateUpdate_
|
|
498
|
+
|
|
499
|
+
```typescript
|
|
500
|
+
OPENRPC.StateUpdate;
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
<hr/>
|
|
504
|
+
|
|
505
|
+
provider.**getStorageAt**(contractAddress, key, blockIdentifier) => _Promise < BigNumberish >_
|
|
506
|
+
|
|
507
|
+
<hr/>
|
|
508
|
+
|
|
509
|
+
provider.**getTransaction**(txHash) => _Promise < GetTransactionResponse >_
|
|
510
|
+
|
|
511
|
+
<hr/>
|
|
512
|
+
|
|
513
|
+
provider.**getTransactionByHash**(txHash) => _Promise < GetTransactionByHashResponse >_
|
|
514
|
+
|
|
515
|
+
###### _GetTransactionByHashResponse_
|
|
516
|
+
|
|
517
|
+
```typescript
|
|
518
|
+
OPENRPC.Transaction;
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
<hr/>
|
|
522
|
+
|
|
523
|
+
provider.**getTransactionByBlockIdAndIndex**(blockIdentifier, index) => _Promise < GetTransactionByBlockIdAndIndex >_
|
|
524
|
+
|
|
525
|
+
###### _GetTransactionByBlockIdAndIndex_
|
|
526
|
+
|
|
527
|
+
```typescript
|
|
528
|
+
OPENRPC.Transaction;
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
<hr/>
|
|
532
|
+
|
|
533
|
+
provider.**getTransactionReceipt**(txHash) => _Promise < GetTransactionReceiptResponse >_
|
|
534
|
+
|
|
535
|
+
<hr/>
|
|
536
|
+
|
|
537
|
+
provider.**getClass**(classHash) => _Promise < ContractClass >_
|
|
538
|
+
|
|
539
|
+
###### _ContractClass_
|
|
540
|
+
|
|
541
|
+
```typescript
|
|
542
|
+
OPENRPC.ContractClass;
|
|
543
|
+
```
|
|
544
|
+
|
|
545
|
+
<hr/>
|
|
546
|
+
|
|
547
|
+
provider.**getClassAt**(contractAddress, blockIdentifier) => _Promise < ContractClass >_
|
|
548
|
+
|
|
549
|
+
###### _ContractClass_
|
|
550
|
+
|
|
551
|
+
```typescript
|
|
552
|
+
OPENRPC.ContractClass;
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
<hr/>
|
|
556
|
+
|
|
557
|
+
provider.**getInvokeEstimateFee**(invocation, invocationDetails, blockIdentifier) => _Promise < EstimateFeeResponse >_
|
|
558
|
+
|
|
559
|
+
###### _EstimateFeeResponse_
|
|
560
|
+
|
|
561
|
+
```typescript
|
|
562
|
+
overall_fee: BN;
|
|
563
|
+
gas_consumed?: BN;
|
|
564
|
+
gas_price?: BN;
|
|
565
|
+
```
|
|
566
|
+
|
|
567
|
+
<hr/>
|
|
568
|
+
|
|
569
|
+
provider.**getDeclareEstimateFee**(DeclareContractTransaction, details, blockIdentifier) => _Promise < EstimateFeeResponse >_
|
|
570
|
+
|
|
571
|
+
###### _EstimateFeeResponse_
|
|
572
|
+
|
|
573
|
+
```typescript
|
|
574
|
+
overall_fee: BN;
|
|
575
|
+
gas_consumed?: BN;
|
|
576
|
+
gas_price?: BN;
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
<hr/>
|
|
580
|
+
|
|
581
|
+
provider.**declareContract**(DeclareContractTransaction, details) => _Promise < DeclareContractResponse >_
|
|
582
|
+
|
|
583
|
+
###### _DeclareContractResponse_
|
|
584
|
+
|
|
585
|
+
```typescript
|
|
586
|
+
transaction_hash: string;
|
|
587
|
+
class_hash: string;
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
<hr/>
|
|
591
|
+
|
|
592
|
+
provider.**deployContract**(contract, constructorCalldata, addressSalt) => _Promise < DeployContractResponse >_
|
|
593
|
+
|
|
594
|
+
###### _DeployContractResponse_
|
|
595
|
+
|
|
596
|
+
```typescript
|
|
597
|
+
contract_address: string;
|
|
598
|
+
transaction_hash: string;
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
<hr/>
|
|
602
|
+
|
|
603
|
+
provider.**callContract**(call, blockIdentifier) => _Promise < CallContractResponse >_
|
|
604
|
+
|
|
605
|
+
<hr/>
|
|
606
|
+
|
|
607
|
+
provider.**traceTransaction**(transactionHash) => _Promise < Trace >_
|
|
608
|
+
|
|
609
|
+
###### _Trace_
|
|
610
|
+
|
|
611
|
+
```typescript
|
|
612
|
+
OPENRPC.Trace;
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
<hr/>
|
|
616
|
+
|
|
617
|
+
provider.**traceBlockTransactions**(blockHash) => _Promise < Traces >_
|
|
618
|
+
|
|
619
|
+
###### _Traces_
|
|
620
|
+
|
|
621
|
+
```typescript
|
|
622
|
+
OPENRPC.Traces;
|
|
623
|
+
```
|
|
624
|
+
|
|
625
|
+
<hr/>
|
|
626
|
+
|
|
336
627
|
provider.**getSyncingStats**() => _Promise < GetSyncingStatsResponse >_
|
|
337
628
|
|
|
338
629
|
Gets syncing status of the node.
|
|
@@ -355,6 +646,8 @@ boolean |
|
|
|
355
646
|
|
|
356
647
|
provider.**getEvents**(eventFilter) => _Promise < GetEventsResponse >_
|
|
357
648
|
|
|
649
|
+
Gets all the events filtered
|
|
650
|
+
|
|
358
651
|
##### _EventFilter_
|
|
359
652
|
|
|
360
653
|
```typescript
|
package/www/docs/API/signer.md
CHANGED
|
@@ -20,7 +20,15 @@ Returns the public key of the signer.
|
|
|
20
20
|
|
|
21
21
|
signer.**signTransaction**(transactions, transactionsDetail [ , abi ]) => _Promise < Signature >_
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Signs a transaction with the starknet private key and returns the signature.
|
|
24
|
+
|
|
25
|
+
The _transactions_ object for write methods may include any of:
|
|
26
|
+
|
|
27
|
+
- transactions.**contractAddress** - the address of the contract
|
|
28
|
+
- transactions.**entrypoint** - the entrypoint of the contract
|
|
29
|
+
- transactions.**calldata** - (defaults to []) the calldata
|
|
30
|
+
|
|
31
|
+
_abi_ - (optional) the abi of the contract for better displaying
|
|
24
32
|
|
|
25
33
|
###### _Signature_
|
|
26
34
|
|
|
@@ -32,7 +40,53 @@ string[]
|
|
|
32
40
|
|
|
33
41
|
signer.**signMessage**(typedData, accountAddress) => _Promise < Signature >_
|
|
34
42
|
|
|
35
|
-
|
|
43
|
+
Sign an JSON object for off-chain usage with the starknet private key and return the signature. This adds a message prefix so it cant be interchanged with transactions.
|
|
44
|
+
|
|
45
|
+
_typedData_ - JSON object to be signed
|
|
46
|
+
_accountAddress_ - calldata to be passed in deploy constructor
|
|
47
|
+
|
|
48
|
+
###### _Signature_
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
string[]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
<hr />
|
|
55
|
+
|
|
56
|
+
signer.**signDeployAccountTransaction**(transaction) => _Promise < Signature >_
|
|
57
|
+
|
|
58
|
+
Signs a DEPLOY_ACCOUNT transaction with the starknet private key and returns the signature.
|
|
59
|
+
|
|
60
|
+
The _transactions_ object for write methods may include any of:
|
|
61
|
+
|
|
62
|
+
- transactions.**contractAddress** - the address of the contract
|
|
63
|
+
- transactions.**constructorCalldata** - calldata to be passed in deploy constructor
|
|
64
|
+
- transactions.**addressSalt** - contract address salt
|
|
65
|
+
- transactions.**chainId** - the chainId to declare contract on
|
|
66
|
+
- transactions.**maxFee** - maxFee for the declare transaction
|
|
67
|
+
- transactions.**version** - transaction version
|
|
68
|
+
- transactions.**nonce** - Nonce of the declare transaction
|
|
69
|
+
|
|
70
|
+
###### _Signature_
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
string[]
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
<hr />
|
|
77
|
+
|
|
78
|
+
signer.**signDeclareTransaction**(transaction, transactionsDetail [ , abi ]) => _Promise < Signature >_
|
|
79
|
+
|
|
80
|
+
Signs a DECLARE transaction with the starknet private key and returns the signature.
|
|
81
|
+
|
|
82
|
+
The _transaction_ object for write methods may include any of:
|
|
83
|
+
|
|
84
|
+
- transactions.**classHash** - computed class hash. Will be replaced by ContractClass in future once class hash is present in CompiledContract
|
|
85
|
+
- transactions.**senderAddress** - the address of the sender
|
|
86
|
+
- transactions.**chainId** - the chainId to declare contract on
|
|
87
|
+
- transactions.**maxFee** - maxFee for the declare transaction
|
|
88
|
+
- transactions.**version** - transaction version
|
|
89
|
+
- transactions.**nonce** - Nonce of the declare transaction
|
|
36
90
|
|
|
37
91
|
###### _Signature_
|
|
38
92
|
|
package/www/guides/erc20.md
CHANGED
|
@@ -12,11 +12,17 @@ const compiledErc20 = json.parse(
|
|
|
12
12
|
);
|
|
13
13
|
const erc20Response = await defaultProvider.deployContract({
|
|
14
14
|
contract: compiledErc20,
|
|
15
|
+
constructorCalldata: [encodeShortString('TokenName'), encodeShortString('TokenSymbol'), recipient], // Here the `recipient` receives the initial 1000 tokens
|
|
15
16
|
});
|
|
17
|
+
|
|
16
18
|
console.log("Waiting for Tx to be Accepted on Starknet - ERC20 Deployment...");
|
|
17
19
|
await defaultProvider.waitForTransaction(erc20Response.transaction_hash);
|
|
18
20
|
```
|
|
19
21
|
|
|
22
|
+
> **Note**
|
|
23
|
+
>
|
|
24
|
+
> The ERC20 contract can be found [here](https://github.com/argentlabs/argent-contracts-starknet/blob/develop/contracts/lib/ERC20.cairo)
|
|
25
|
+
|
|
20
26
|
## Get the erc20 contract address and create the contact object
|
|
21
27
|
|
|
22
28
|
```javascript
|
|
@@ -35,7 +41,7 @@ erc20.connect(account);
|
|
|
35
41
|
|
|
36
42
|
const { transaction_hash: mintTxHash } = await erc20.mint(
|
|
37
43
|
account.address,
|
|
38
|
-
|
|
44
|
+
[ "1000", "0"]
|
|
39
45
|
{
|
|
40
46
|
maxFee: "1"
|
|
41
47
|
}
|
|
@@ -59,11 +65,11 @@ await defaultProvider.waitForTransaction(mintTxHash);
|
|
|
59
65
|
|
|
60
66
|
```javascript
|
|
61
67
|
console.log(`Calling StarkNet for account balance...`);
|
|
62
|
-
const balanceBeforeTransfer = await erc20.
|
|
68
|
+
const balanceBeforeTransfer = await erc20.balanceOf(account.address);
|
|
63
69
|
|
|
64
70
|
console.log(
|
|
65
71
|
`account Address ${account.address} has a balance of:`,
|
|
66
|
-
number.toBN(balanceBeforeTransfer.
|
|
72
|
+
number.toBN(balanceBeforeTransfer.balance.low, 16).toString()
|
|
67
73
|
);
|
|
68
74
|
```
|
|
69
75
|
|
|
@@ -76,7 +82,7 @@ const { transaction_hash: transferTxHash } = await account.execute(
|
|
|
76
82
|
{
|
|
77
83
|
contractAddress: erc20Address,
|
|
78
84
|
entrypoint: "transfer",
|
|
79
|
-
calldata: [erc20Address, "10"],
|
|
85
|
+
calldata: [erc20Address, "10", "0"],
|
|
80
86
|
},
|
|
81
87
|
undefined,
|
|
82
88
|
{ maxFee: "1" }
|
|
@@ -90,12 +96,12 @@ await defaultProvider.waitForTransaction(transferTxHash);
|
|
|
90
96
|
## Check balance after transfer
|
|
91
97
|
|
|
92
98
|
```javascript
|
|
93
|
-
// Check balance after transfer - should be
|
|
99
|
+
// Check balance after transfer - should be 1990 (1000 initial supply + 1000 mint - 10 transfer)
|
|
94
100
|
console.log(`Calling StarkNet for account balance...`);
|
|
95
|
-
const balanceAfterTransfer = await erc20.
|
|
101
|
+
const balanceAfterTransfer = await erc20.balanceOf(account.address);
|
|
96
102
|
|
|
97
103
|
console.log(
|
|
98
104
|
`account Address ${account.address} has a balance of:`,
|
|
99
|
-
number.toBN(balanceAfterTransfer.
|
|
105
|
+
number.toBN(balanceAfterTransfer.balance.low, 16).toString()
|
|
100
106
|
);
|
|
101
107
|
```
|