starknet 4.17.0 → 4.18.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.
Files changed (150) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +2 -10
  3. package/dist/index.d.ts +27 -9
  4. package/dist/index.global.js +30 -13
  5. package/dist/index.global.js.map +1 -1
  6. package/dist/index.js +30 -13
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +30 -13
  9. package/dist/index.mjs.map +1 -1
  10. package/package.json +5 -1
  11. package/.babelrc +0 -6
  12. package/.commitlintrc +0 -22
  13. package/.eslintignore +0 -2
  14. package/.eslintrc +0 -28
  15. package/.prettierrc +0 -6
  16. package/.releaserc +0 -28
  17. package/CODE_OF_CONDUCT.md +0 -128
  18. package/CONTRIBUTING.md +0 -52
  19. package/__mocks__/Account.json +0 -25486
  20. package/__mocks__/ERC20.json +0 -40027
  21. package/__mocks__/TestDapp.json +0 -12962
  22. package/__mocks__/contract.json +0 -33191
  23. package/__mocks__/l1l2_compiled.json +0 -10107
  24. package/__mocks__/multicall.json +0 -8139
  25. package/__mocks__/naming_compiled.json +0 -53283
  26. package/__mocks__/starknetId_compiled.json +0 -44703
  27. package/__mocks__/typedDataExample.json +0 -35
  28. package/__mocks__/typedDataSessionExample.json +0 -42
  29. package/__mocks__/typedDataStructArrayExample.json +0 -44
  30. package/__tests__/account.test.ts +0 -345
  31. package/__tests__/contract.test.ts +0 -249
  32. package/__tests__/defaultProvider.test.ts +0 -177
  33. package/__tests__/fixtures.ts +0 -84
  34. package/__tests__/jest.setup.ts +0 -30
  35. package/__tests__/rpcProvider.test.ts +0 -132
  36. package/__tests__/sequencerProvider.test.ts +0 -123
  37. package/__tests__/utils/__snapshots__/ellipticalCurve.test.ts.snap +0 -5
  38. package/__tests__/utils/__snapshots__/utils.browser.test.ts.snap +0 -5
  39. package/__tests__/utils/__snapshots__/utils.test.ts.snap +0 -5
  40. package/__tests__/utils/address.test.ts +0 -45
  41. package/__tests__/utils/ellipticalCurve.test.ts +0 -91
  42. package/__tests__/utils/merkle.test.ts +0 -256
  43. package/__tests__/utils/shortString.test.ts +0 -22
  44. package/__tests__/utils/starknetId.test.ts +0 -53
  45. package/__tests__/utils/transactionHash.test.ts +0 -17
  46. package/__tests__/utils/typedData.test.ts +0 -223
  47. package/__tests__/utils/uint256.test.ts +0 -32
  48. package/__tests__/utils/utils.browser.test.ts +0 -29
  49. package/__tests__/utils/utils.test.ts +0 -141
  50. package/img/logo.svg +0 -17
  51. package/index.d.ts +0 -2683
  52. package/index.global.js +0 -23192
  53. package/index.global.js.map +0 -1
  54. package/index.js +0 -4910
  55. package/index.js.map +0 -1
  56. package/index.mjs +0 -4852
  57. package/index.mjs.map +0 -1
  58. package/src/account/default.ts +0 -501
  59. package/src/account/index.ts +0 -2
  60. package/src/account/interface.ts +0 -309
  61. package/src/constants.ts +0 -2065
  62. package/src/contract/contractFactory.ts +0 -88
  63. package/src/contract/default.ts +0 -425
  64. package/src/contract/index.ts +0 -3
  65. package/src/contract/interface.ts +0 -106
  66. package/src/index.ts +0 -26
  67. package/src/provider/default.ts +0 -187
  68. package/src/provider/errors.ts +0 -14
  69. package/src/provider/index.ts +0 -9
  70. package/src/provider/interface.ts +0 -281
  71. package/src/provider/rpc.ts +0 -482
  72. package/src/provider/sequencer.ts +0 -523
  73. package/src/provider/utils.ts +0 -100
  74. package/src/signer/default.ts +0 -99
  75. package/src/signer/index.ts +0 -2
  76. package/src/signer/interface.ts +0 -77
  77. package/src/types/account.ts +0 -43
  78. package/src/types/api/index.ts +0 -10
  79. package/src/types/api/openrpc.ts +0 -607
  80. package/src/types/api/rpc.ts +0 -45
  81. package/src/types/api/sequencer.ts +0 -369
  82. package/src/types/contract.ts +0 -5
  83. package/src/types/index.ts +0 -8
  84. package/src/types/lib.ts +0 -143
  85. package/src/types/provider.ts +0 -134
  86. package/src/types/signer.ts +0 -24
  87. package/src/utils/address.ts +0 -44
  88. package/src/utils/calldata.ts +0 -250
  89. package/src/utils/ellipticCurve.ts +0 -120
  90. package/src/utils/encode.ts +0 -66
  91. package/src/utils/events.ts +0 -32
  92. package/src/utils/fetchPonyfill.ts +0 -5
  93. package/src/utils/hash.ts +0 -235
  94. package/src/utils/json.ts +0 -15
  95. package/src/utils/merkle.ts +0 -69
  96. package/src/utils/number.ts +0 -98
  97. package/src/utils/provider.ts +0 -28
  98. package/src/utils/responseParser/index.ts +0 -28
  99. package/src/utils/responseParser/rpc.ts +0 -70
  100. package/src/utils/responseParser/sequencer.ts +0 -135
  101. package/src/utils/shortString.ts +0 -21
  102. package/src/utils/stark.ts +0 -57
  103. package/src/utils/starknetId.ts +0 -116
  104. package/src/utils/transaction.ts +0 -56
  105. package/src/utils/typedData/index.ts +0 -247
  106. package/src/utils/typedData/types.ts +0 -37
  107. package/src/utils/typedData/utils.ts +0 -16
  108. package/src/utils/uint256.ts +0 -32
  109. package/src/utils/url.ts +0 -53
  110. package/tsconfig.eslint.json +0 -4
  111. package/tsup.config.ts +0 -9
  112. package/www/README.md +0 -41
  113. package/www/babel.config.js +0 -3
  114. package/www/code-examples/account.js +0 -65
  115. package/www/code-examples/amm.js +0 -44
  116. package/www/code-examples/erc20.js +0 -13
  117. package/www/code-examples/package-lock.json +0 -336
  118. package/www/code-examples/package.json +0 -15
  119. package/www/docs/API/_category_.json +0 -5
  120. package/www/docs/API/account.md +0 -463
  121. package/www/docs/API/changelog.md +0 -15
  122. package/www/docs/API/contract.md +0 -135
  123. package/www/docs/API/contractFactory.md +0 -45
  124. package/www/docs/API/index.md +0 -3
  125. package/www/docs/API/provider.md +0 -725
  126. package/www/docs/API/signer.md +0 -105
  127. package/www/docs/API/utils.md +0 -374
  128. package/www/docusaurus.config.js +0 -130
  129. package/www/guides/account.md +0 -140
  130. package/www/guides/cra.md +0 -3
  131. package/www/guides/erc20.md +0 -163
  132. package/www/guides/intro.md +0 -63
  133. package/www/package-lock.json +0 -20405
  134. package/www/package.json +0 -43
  135. package/www/sidebars.js +0 -31
  136. package/www/src/components/HomepageFeatures/index.tsx +0 -67
  137. package/www/src/components/HomepageFeatures/styles.module.css +0 -10
  138. package/www/src/css/custom.css +0 -39
  139. package/www/src/pages/index.module.css +0 -23
  140. package/www/src/pages/index.tsx +0 -40
  141. package/www/src/pages/markdown-page.md +0 -7
  142. package/www/static/.nojekyll +0 -0
  143. package/www/static/img/docusaurus.png +0 -0
  144. package/www/static/img/favicon.ico +0 -0
  145. package/www/static/img/logo.svg +0 -17
  146. package/www/static/img/starknet-1.png +0 -0
  147. package/www/static/img/starknet-2.png +0 -0
  148. package/www/static/img/starknet-3.png +0 -0
  149. package/www/static/img/tutorial/docsVersionDropdown.png +0 -0
  150. package/www/static/img/tutorial/localeDropdown.png +0 -0
@@ -1,463 +0,0 @@
1
- ---
2
- sidebar_position: 2
3
- ---
4
-
5
- # Account
6
-
7
- An Account extends <ins>[`Provider`](/docs/API/provider)</ins> and inherits all of its methods.
8
-
9
- It also introduces new methods that allow Accounts to create and verify signatures with a custom <ins>[`Signer`](/docs/API/signer)</ins>, declare and deploy Contract and deploy new Account
10
-
11
- This API is the primary way to interact with an account contract on StarkNet.
12
-
13
- ## Creating an instance
14
-
15
- To create a new instance of the Account, first an account contract must be deployed. Also there needs to be a Provider instance that will be passed in the constructor and key pair for the account.
16
-
17
- `new starknet.Account(Provider, address, starkKeyPair)`
18
-
19
- ## Properties
20
-
21
- account.**address** => _string_
22
-
23
- The address of the account contract.
24
-
25
- ## Methods
26
-
27
- ### getNonce()
28
-
29
- account.**getNonce(blockIdentifier)** => _Promise < BigNumberish >_
30
-
31
- Gets the nonce of the account with respect to a specific block.
32
-
33
- _blockIdentifier_ - optional blockIdentifier. Defaults to 'pending'.
34
-
35
- Returns the nonce of the account.
36
-
37
- ---
38
-
39
- ### estimateInvokeFee()
40
-
41
- account.**estimateInvokeFee**(calls [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
42
-
43
- Estimate Fee for executing an INVOKE transaction on starknet.
44
-
45
- The _calls_ object structure:
46
-
47
- - calls.**contractAddress** - Address of the contract
48
- - calls.**entrypoint** - Entrypoint of the call (method name)
49
- - calls.**calldata** - Payload for the invoking method
50
-
51
- The _estimateFeeDetails_ object may include any of:
52
-
53
- - estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
54
- - estimateFeeDetails.**nonce** - Nonce for the transaction
55
-
56
- ###### _EstimateFeeResponse_
57
-
58
- ```typescript
59
- {
60
- overall_fee: BN;
61
- gas_consumed?: BN;
62
- gas_price?: BN;
63
- }
64
- ```
65
-
66
- ---
67
-
68
- ### estimateDeclareFee()
69
-
70
- account.**estimateDeclareFee**(contractPayload [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
71
-
72
- Estimate Fee for executing a DECLARE transaction on starknet.
73
-
74
- The _contractPayload_ object structure:
75
-
76
- - contractPayload.**contract** - The compiled contract
77
- - contractPayload.**classHash** - This can be obtained by using starknet-cli. Once the classHash is included in CompiledContract, this can be removed
78
-
79
- The _estimateFeeDetails_ object may include any of:
80
-
81
- - estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
82
- - estimateFeeDetails.**nonce** - Nonce for the transaction
83
-
84
- ###### _EstimateFeeResponse_
85
-
86
- ```typescript
87
- {
88
- overall_fee: BN;
89
- gas_consumed?: BN;
90
- gas_price?: BN;
91
- }
92
- ```
93
-
94
- ---
95
-
96
- ### estimateAccountDeployFee()
97
-
98
- account.**estimateAccountDeployFee**(contractPayload [ , estimateFeeDetails ]) => _Promise < EstimateFeeResponse >_
99
-
100
- Estimate Fee for executing a DEPLOY_ACCOUNT transaction on StarkNet
101
-
102
- The _contractPayload_ object structure:
103
-
104
- - contractPayload.**contract** - The compiled contract to be declared
105
- - contractPayload.**classHash** - This can be obtained by using starknet-cli. Once the classHash is included in CompiledContract, this can be removed
106
-
107
- The _estimateFeeDetails_ object may include any of:
108
-
109
- - estimateFeeDetails.**blockIdentifier** - Block Identifier for the transaction
110
- - estimateFeeDetails.**nonce** - Nonce for the transaction
111
-
112
- ###### _EstimateFeeResponse_
113
-
114
- ```typescript
115
- {
116
- overall_fee: BN;
117
- gas_consumed?: BN;
118
- gas_price?: BN;
119
- }
120
- ```
121
-
122
- ---
123
-
124
- ### execute()
125
-
126
- account.**execute**(transactions [ , abi , transactionsDetail ]) => _Promise < InvokeFunctionResponse >_
127
-
128
- Executes one or multiple calls using the account contract.
129
-
130
- The _transactions_ object structure:
131
-
132
- - contractPayload.**contractAddress** - the address of the contract
133
- - contractPayload.**entrypoint** - the entrypoint of the contract
134
- - contractPayload.**calldata** - (defaults to []) the calldata
135
- - contractPayload.**signature** - (defaults to []) the signature
136
-
137
- _abi_ - (optional) the abi of the contract for better displaying
138
-
139
- The _transactionsDetail_ object may include any of:
140
-
141
- - transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
142
- - transactionsDetail.**nonce** - Nonce for the transaction
143
- - transactionsDetail.**version** - Version for the transaction (default is 1)
144
-
145
- ###### _InvokeFunctionResponse_
146
-
147
- ```typescript
148
- {
149
- transaction_hash: string;
150
- };
151
- ```
152
-
153
- ---
154
-
155
- ### declare()
156
-
157
- account.**declare**(contractPayload [ , transactionsDetail ]) => _Promise < DeclareContractResponse >_
158
-
159
- Declares a given compiled contract (json) to starknet.
160
-
161
- The _contractPayload_ object consists of:
162
-
163
- - contractPayload.**contract** - The compiled contract
164
- - contractPayload.**classHash** - Hash of the compiled contract
165
-
166
- The _transactionsDetail_ object may include any of:
167
-
168
- - transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
169
- - transactionsDetail.**nonce** - Nonce for the transaction
170
- - transactionsDetail.**version** - Version for the transaction (default is 1)
171
-
172
- > _Note:_ Once the classHash is included in CompiledContract, this parameter can be removed. Currently it can be pre-computed from starknet-cli.
173
-
174
- Example:
175
-
176
- ```typescript
177
- const declareTx = await account.declare({
178
- contract: compiledErc20,
179
- // classHash is pre-computed from starknet-cli
180
- classHash: '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a',
181
- });
182
- ```
183
-
184
- ###### _DeclareContractResponse_
185
-
186
- ```typescript
187
- {
188
- transaction_hash: string;
189
- class_hash: string;
190
- };
191
- ```
192
-
193
- ---
194
-
195
- ### deploy()
196
-
197
- Deploys a given compiled contract (json) to starknet, wrapper around _execute_ invoke function
198
-
199
- account.**deploy**(deployContractPayload [ , transactionsDetail ]) => _Promise < InvokeFunctionResponse >_
200
-
201
- @param object **_deployContractPayload_**
202
-
203
- - **classHash**: computed class hash of compiled contract
204
- - optional constructorCalldata: constructor calldata
205
- - optional salt: address salt - default random
206
- - optional unique: bool if true ensure unique salt - default true
207
-
208
- @param object **transactionsDetail** Invocation Details
209
-
210
- - optional nonce
211
- - optional version
212
- - optional maxFee
213
-
214
- @returns **transaction_hash**
215
-
216
- Example:
217
-
218
- ```typescript
219
- const deployment = await account.deploy({
220
- classHash: erc20ClassHash,
221
- constructorCalldata: [
222
- encodeShortString('Token'),
223
- encodeShortString('ERC20'),
224
- account.address,
225
- ],
226
- salt: randomAddress(),
227
- unique: true, // Using true here so as not to clash with normal erc20 deploy in account and provider test
228
- });
229
-
230
- await provider.waitForTransaction(deployment.transaction_hash);
231
- ```
232
-
233
- Example multi-call:
234
-
235
- ```typescript
236
- TODO Example with multi-call
237
- ```
238
-
239
- ---
240
-
241
- ### deployContract()
242
-
243
- ✅ NEW
244
- High level wrapper for deploy. Doesn't require waitForTransaction. Response similar to deprecated provider deployContract.
245
-
246
- account.**deployContract**(payload [ , details ]) => _Promise < DeployContractUDCResponse >_
247
-
248
- @param object **_payload_** UniversalDeployerContractPayload
249
-
250
- - **classHash**: computed class hash of compiled contract
251
- - **constructorCalldata**: constructor calldata
252
- - optional salt: address salt - default random
253
- - optional unique: bool if true ensure unique salt - default true
254
-
255
- @param object **details** InvocationsDetails
256
-
257
- - optional nonce
258
- - optional version
259
- - optional maxFee
260
-
261
- @returns Promise DeployContractUDCResponse
262
-
263
- - contract_address
264
- - transaction_hash
265
- - address
266
- - deployer
267
- - unique
268
- - classHash
269
- - calldata_len
270
- - calldata
271
- - salt
272
-
273
- Example:
274
-
275
- ```typescript
276
- const deployResponse = await account.deployContract({
277
- classHash: erc20ClassHash,
278
- constructorCalldata: [
279
- encodeShortString('Token'),
280
- encodeShortString('ERC20'),
281
- account.address,
282
- ],
283
- });
284
- ```
285
-
286
- ---
287
-
288
- ### declareDeploy()
289
-
290
- ✅ NEW
291
- High level wrapper for declare & deploy. Doesn't require waitForTransaction. Functionality similar to deprecated provider deployContract. Declare and Deploy contract using single function.
292
-
293
- account.**declareDeploy**(payload [ , details ]) => _Promise < DeclareDeployUDCResponse >_
294
-
295
- @param object **_payload_** DeclareDeployContractPayload
296
-
297
- - **contract**: compiled contract code
298
- - **classHash**: computed class hash of compiled contract
299
- - optional constructorCalldata: constructor calldata
300
- - optional salt: address salt - default random
301
- - optional unique: bool if true ensure unique salt - default true
302
-
303
- @param object **details** InvocationsDetails
304
-
305
- - optional nonce
306
- - optional version
307
- - optional maxFee
308
-
309
- @returns Promise DeclareDeployUDCResponse
310
-
311
- - declare: CommonTransactionReceiptResponse
312
- - transaction_hash
313
- - class_hash
314
- - deploy: DeployContractUDCResponse;
315
- - contract_address
316
- - transaction_hash
317
- - address
318
- - deployer
319
- - unique
320
- - classHash
321
- - calldata_len
322
- - calldata
323
- - salt
324
- ***
325
-
326
- Example:
327
-
328
- ```typescript
329
- const declareDeploy = await account.declareDeploy({
330
- contract: compiledErc20,
331
- classHash: '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a',
332
- constructorCalldata: [
333
- encodeShortString('Token'),
334
- encodeShortString('ERC20'),
335
- account.address,
336
- ],
337
- });
338
-
339
- const declareTransactionHash = declareDeploy.declare.transaction_hash
340
- const erc20Address = declareDeploy.deploy.contract_address;
341
- ```
342
-
343
- ---
344
-
345
- ### deployAccount()
346
-
347
- account.**deployAccount**(contractPayload [ , transactionsDetail ]) => _Promise < DeployContractResponse >_
348
-
349
- Declares a given compiled contract (json) to starknet.
350
-
351
- The _contractPayload_ object consists of:
352
-
353
- - contractPayload.**classHash** - Hash of the compiled contract
354
- - contractPayload.**constructorCalldata** - optional
355
- - contractPayload.**addressSalt** - optional
356
- - contractPayload.**contractAddress** - optional
357
-
358
- The _transactionsDetail_ object may include any of:
359
-
360
- - transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
361
- - transactionsDetail.**nonce** - Nonce for the transaction
362
- - transactionsDetail.**version** - Version for the transaction (default is 1)
363
-
364
- > _Note:_ Once the classHash is included in CompiledContract, this parameter can be removed. Currently it can be pre-computed from starknet-cli.
365
-
366
- ###### _DeployContractResponse_
367
-
368
- ```typescript
369
- {
370
- contract_address: string;
371
- transaction_hash: string;
372
- };
373
- ```
374
-
375
- ---
376
-
377
- ### signMessage()
378
-
379
- account.**signMessage**(typedData) => _Promise < Signature >_
380
-
381
- 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.
382
-
383
- _typedData_ - JSON object to be signed
384
-
385
- ###### _Signature_
386
-
387
- ```typescript
388
- string[];
389
- ```
390
-
391
- ---
392
-
393
- ### hashMessage()
394
-
395
- account.**hashMessage**(typedData) => _Promise < string >_
396
-
397
- Hash a JSON object with pederson hash and return the hash. This adds a message prefix so it cant be interchanged with transactions.
398
-
399
- _typedData_ - JSON object to be signed
400
-
401
- Returns the hash of the JSON object.
402
-
403
- ---
404
-
405
- ### verifyMessageHash()
406
-
407
- account.**verifyMessageHash**(hash, signature) => _Promise < boolean >_
408
-
409
- Verify a signature of a given hash.
410
-
411
- > **WARNING**
412
- >
413
- > This method is not recommended, use `verifyMessage` instead
414
-
415
- ---
416
-
417
- ### verifyMessage()
418
-
419
- account.**verifyMessage**(typedData, signature) => _Promise < boolean >_
420
-
421
- Verify a signature of a JSON object.
422
-
423
- _typedData_ - JSON object to be verified
424
- _signature_ - signature of the JSON object
425
-
426
- Returns true if the signature is valid, false otherwise
427
-
428
- ---
429
-
430
- ### getSuggestedMaxFee()
431
-
432
- account.**getSuggestedMaxFee**(estimateFeeAction, details) => _Promise < BigNumberish >_
433
-
434
- Gets Suggested Max Fee based on the transaction type.
435
-
436
- The _details_ object may include any of:
437
-
438
- - details.**blockIdentifier**
439
- - details.**nonce**
440
-
441
- ---
442
-
443
- ### getStarkName()
444
-
445
- account.**getStarkName**(StarknetIdContract) => _Promise<string | Error>_
446
-
447
- Gets starknet.id stark name with the address of the account
448
-
449
- The _StarknetIdContract_ argument can be undefined, if it is, the function will automatically use official starknet id contracts of your network (It currently supports TESTNET 1 only).
450
-
451
- Returns directly a string (Example: `vitalik.stark`).
452
-
453
- ---
454
-
455
- ### getAddressFromStarkName()
456
-
457
- account.**getAddressFromStarkName**(name, StarknetIdContract) => _Promise<string | Error>_
458
-
459
- Gets account address with the starknet id stark name.
460
-
461
- The _StarknetIdContract_ argument can be undefined, if it is, the function will automatically use official starknet id contracts of your network (It currently supports TESTNET 1 only).
462
-
463
- Returns directly the address in a string (Example: `0xff...34`).
@@ -1,15 +0,0 @@
1
- ---
2
- sidebar_position: 7
3
- ---
4
-
5
- # CHANGELOG
6
-
7
- ### Release 3.10.2 (21.04.2022)
8
-
9
- - New hash formula for the new account contract version.
10
-
11
- **NOTE**: Update your accounts, old ones will not be supported anymore. For updating with Argent X extension you can check this [link](https://github.com/argentlabs/argent-x/pull/522)
12
-
13
- - BUGFIX: [#165](https://github.com/0xs34n/starknet.js/issues/165)
14
- - BUGFIX: [#151](https://github.com/0xs34n/starknet.js/issues/151)
15
- - BUGFIX: [#158](https://github.com/0xs34n/starknet.js/issues/158)
@@ -1,135 +0,0 @@
1
- ---
2
- sidebar_position: 4
3
- ---
4
-
5
- # Contract
6
-
7
- Contracts can do data transformations in JavaScript based on an ABI. They can also call and invoke to StarkNet through a provided Signer.
8
-
9
- Contracts allow you to transform Cairo values, like `Uint256` to `BigNumber`. It could also allow users to pass their own transformers, similar to `JSON.parse`.
10
-
11
- ## Creating an instance
12
-
13
- `new starknet.Contract(abi, address, providerOrAccount)`
14
-
15
- `contract.attach(address)` _for changing the address of the connected contract_
16
-
17
- `contract.connect(providerOrAccount)` _for changing the provider or account_
18
-
19
- ## Properties
20
-
21
- contract.**abi** => _Abi_
22
-
23
- The ABI the contract was constructed with.
24
-
25
- contract.**address** => _string_
26
-
27
- The address the contract was constructed/connected with.
28
-
29
- contract.**providerOrAccount** => _ProviderInterface | AccountInterface_
30
-
31
- Provider or account that are used to interact with the network.
32
-
33
- contract.**deployTransactionHash** => _string | null_
34
-
35
- If the Contract object is the result of a ContractFactory deployment, this is the transaction which was used to deploy the contract.
36
-
37
- ## Methods
38
-
39
- ### attach()
40
-
41
- contract.**attach**(address) => void
42
-
43
- Saves the address of the contract deployed on network that will be used for interaction.
44
-
45
- _address_ - address of the contract.
46
-
47
- ---
48
-
49
- ### connect()
50
-
51
- contract.**connect**(providerOrAccount) => void
52
-
53
- Attaches to new Provider or Account
54
-
55
- ---
56
-
57
- ### deployed()
58
-
59
- contract.**deployed**() => _Promise < Contract >_
60
-
61
- If the Contract object is the result of a ContractFactory deployment, this method will wait for the transaction to be resolved.
62
-
63
- ---
64
-
65
- ### call()
66
-
67
- contract.**call**(method, args, options) => _Promise < Result >_
68
-
69
- Calls a method on a contract.
70
-
71
- ---
72
-
73
- ### invoke()
74
-
75
- contract.**invoke**(method, args, options) => _Promise < InvokeFunctionResponse >_
76
-
77
- Invokes a method on a contract.
78
-
79
- ---
80
-
81
- ### estimate()
82
-
83
- contract.**estimate**(method, args, options) => _Promise < any >_
84
-
85
- Estimates a method on a contract.
86
-
87
- ---
88
-
89
- ### populate()
90
-
91
- contract.**populate**(method, args, options) => _Invocation_
92
-
93
- ## Meta-Class
94
-
95
- A Meta-Class is a Class which has any of its properties determined at run-time. The Contract object uses a Contract's ABI to determine what methods are available, so the following sections describe the generic ways to interact with the properties added at run-time during the Contract constructor.
96
-
97
- ### Read-Only Methods(constant)
98
-
99
- A constant method (denoted view in Cairo) is read-only and evaluates a small amount of Cairo code against the current blockchain state. It is therefore free and does not require any fee, but cannot make changes to the blockchain state...
100
-
101
- contract.**METHOD_NAME**(...args [ , overrides ]) => _Promise < Result >_
102
-
103
- The type of the result depends on the ABI. Result object will be returned with each parameter available positionally and if the parameter is named, it will also be available by its name.
104
-
105
- The _overrides_ object for a read-only method may include:
106
-
107
- - overrides.**blockIdentifier**
108
-
109
- ### Write Methods (non-constant)
110
-
111
- A non-constant method requires a transaction to be signed and requires payment in the form of a fee to be paid.
112
-
113
- contract.**METHOD_NAME**(...args [ , overrides ]) => _Promise < AddTransactionResponse >_
114
-
115
- Returns a _AddTransactionResponse_ for the transaction after it is sent to the network. This requires that Contract has a signer.
116
-
117
- The _overrides_ object for write methods may include any of:
118
-
119
- - overrides.**signature** - Signature that will be used for the transaction
120
- - overrides.**maxFee** - Max Fee for the transaction
121
- - overrides.**nonce** - Nonce for the transaction
122
-
123
- ### Write Methods Analysis
124
-
125
- There are several options to analyze properties and results of a write method without actually executing it.
126
-
127
- contract.estimateGas.**METHOD_NAME**( ...args ) => _Promise < EstimateFeeResponse >_
128
-
129
- Returns the estimate units of gas that would be required to execute the METHOD_NAME with args and overrides.
130
-
131
- contract.populateTransaction.**METHOD_NAME**( ...args [ , overrides ] ) ⇒ _Call_
132
-
133
- Returns an _Call_ object which represents the transaction that would need to be signed and submitted to the network to execute METHOD_NAME with args and overrides.
134
-
135
- The overrides are identical to the overrides above for write methods.
@@ -1,45 +0,0 @@
1
- ---
2
- sidebar_position: 5
3
- ---
4
-
5
- # Contract Factory
6
-
7
- Contract Factory allow you to deploy contracts to StarkNet. To deploy a Contract, additional information is needed that is not available on a Contract object itself.
8
-
9
- ## Creating an instance
10
-
11
- `new starknet.ContractFactory( compiledContract, classHash, account, [ , abi ] )`
12
-
13
- Creates a new instance of a ContractFactory for the contract described by the _compiledContract_.
14
-
15
- `contractFactory.connect(account)` _for changing the provider or account_
16
-
17
- `contractFactory.attach(address)` _for changing the address of the connected contract factory_
18
-
19
- ## Properties
20
-
21
- contractFactory.**compiledContract** => _CompiledContract_ (the compiled contract the contractFactory was constructed with)
22
-
23
- contractFactory.**classHash** => _string_ (contract classHash can be obtained using tool for compiling contract)
24
-
25
- contractFactory.**account** => _AccountInterface_ (account that are used to interact with the network)
26
-
27
- contractFactory.**abi** => _Abi_ (the ABI the contractFactory was constructed with)
28
-
29
- ## Methods
30
-
31
- ### attach()
32
-
33
- contractFactory.**attach**( address ) ⇒ _Contract_
34
-
35
- Return an instance of a _Contract_ attached to address. This is the same as using the _Contract_ constructor with address and this _compiledContract_ and _account_ passed in when creating the ContractFactory.
36
-
37
- ---
38
-
39
- ### deploy()
40
-
41
- contractFactory.**deploy**( args, addressSalt ) ⇒ _Promise < Contract >_
42
-
43
- Uses the provider to deploy the Contract with _args_ passed into the constructor and returns a _Contract_ which is attached to the address where this contract will be deployed.
44
-
45
- The transaction hash can be found at _contract.deployTransactionHash_, and no interactions should be made until the transaction is resolved.
@@ -1,3 +0,0 @@
1
- # StarkNet.js API
2
-
3
- This API is based on the <ins>[Starknet.js V3](https://github.com/0xs34n/starknet.js/discussions/102)</ins> Interface write up by <ins>[Janek](https://twitter.com/0xjanek)</ins> of <ins>[Argent](https://www.argent.xyz/)</ins>