starknet 4.8.0 → 4.9.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 (87) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/__mocks__/ERC20.json +32561 -29055
  3. package/__tests__/account.test.ts +32 -24
  4. package/__tests__/contract.test.ts +25 -14
  5. package/__tests__/defaultProvider.test.ts +19 -43
  6. package/__tests__/fixtures.ts +9 -1
  7. package/__tests__/rpcProvider.test.ts +6 -15
  8. package/__tests__/sequencerProvider.test.ts +17 -10
  9. package/__tests__/utils/merkle.test.ts +98 -3
  10. package/__tests__/utils/typedData.test.ts +3 -3
  11. package/account/default.d.ts +10 -44
  12. package/account/default.js +255 -61
  13. package/account/interface.d.ts +78 -7
  14. package/constants.d.ts +1 -0
  15. package/constants.js +1 -0
  16. package/contract/default.js +6 -6
  17. package/dist/account/default.d.ts +10 -44
  18. package/dist/account/default.js +255 -61
  19. package/dist/account/interface.d.ts +78 -7
  20. package/dist/constants.d.ts +1 -0
  21. package/dist/constants.js +1 -0
  22. package/dist/contract/default.js +6 -6
  23. package/dist/provider/default.d.ts +8 -3
  24. package/dist/provider/default.js +31 -4
  25. package/dist/provider/interface.d.ts +67 -5
  26. package/dist/provider/rpc.d.ts +7 -2
  27. package/dist/provider/rpc.js +83 -8
  28. package/dist/provider/sequencer.d.ts +7 -2
  29. package/dist/provider/sequencer.js +71 -13
  30. package/dist/signer/default.d.ts +4 -1
  31. package/dist/signer/default.js +22 -0
  32. package/dist/signer/interface.d.ts +27 -2
  33. package/dist/types/api/openrpc.d.ts +24 -2
  34. package/dist/types/api/sequencer.d.ts +22 -7
  35. package/dist/types/lib.d.ts +23 -2
  36. package/dist/types/provider.d.ts +15 -10
  37. package/dist/types/signer.d.ts +14 -1
  38. package/dist/utils/hash.d.ts +2 -0
  39. package/dist/utils/hash.js +13 -2
  40. package/dist/utils/merkle.js +2 -4
  41. package/dist/utils/responseParser/rpc.d.ts +2 -6
  42. package/dist/utils/responseParser/rpc.js +0 -11
  43. package/dist/utils/responseParser/sequencer.js +4 -14
  44. package/package.json +1 -1
  45. package/provider/default.d.ts +8 -3
  46. package/provider/default.js +31 -4
  47. package/provider/interface.d.ts +67 -5
  48. package/provider/rpc.d.ts +7 -2
  49. package/provider/rpc.js +83 -8
  50. package/provider/sequencer.d.ts +7 -2
  51. package/provider/sequencer.js +71 -13
  52. package/signer/default.d.ts +4 -1
  53. package/signer/default.js +22 -0
  54. package/signer/interface.d.ts +27 -2
  55. package/src/account/default.ts +201 -53
  56. package/src/account/interface.ts +104 -6
  57. package/src/constants.ts +1 -0
  58. package/src/contract/default.ts +6 -6
  59. package/src/provider/default.ts +43 -5
  60. package/src/provider/interface.ts +92 -7
  61. package/src/provider/rpc.ts +86 -12
  62. package/src/provider/sequencer.ts +74 -10
  63. package/src/signer/default.ts +54 -2
  64. package/src/signer/interface.ts +31 -2
  65. package/src/types/api/openrpc.ts +28 -2
  66. package/src/types/api/sequencer.ts +32 -9
  67. package/src/types/lib.ts +30 -2
  68. package/src/types/provider.ts +27 -11
  69. package/src/types/signer.ts +18 -1
  70. package/src/utils/hash.ts +46 -1
  71. package/src/utils/merkle.ts +2 -4
  72. package/src/utils/responseParser/rpc.ts +4 -20
  73. package/src/utils/responseParser/sequencer.ts +2 -0
  74. package/types/api/openrpc.d.ts +24 -2
  75. package/types/api/sequencer.d.ts +22 -7
  76. package/types/lib.d.ts +23 -2
  77. package/types/provider.d.ts +15 -10
  78. package/types/signer.d.ts +14 -1
  79. package/utils/hash.d.ts +2 -0
  80. package/utils/hash.js +13 -2
  81. package/utils/merkle.js +2 -4
  82. package/utils/responseParser/rpc.d.ts +2 -6
  83. package/utils/responseParser/rpc.js +0 -11
  84. package/utils/responseParser/sequencer.js +4 -14
  85. package/www/docs/API/account.md +60 -1
  86. package/www/docs/API/provider.md +306 -17
  87. package/www/guides/erc20.md +13 -7
package/utils/hash.js CHANGED
@@ -28,7 +28,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  return (mod && mod.__esModule) ? mod : { "default": mod };
29
29
  };
30
30
  Object.defineProperty(exports, "__esModule", { value: true });
31
- exports.calculateContractAddressFromHash = exports.calculateTransactionHash = exports.calculateDeployTransactionHash = exports.calculateTransactionHashCommon = exports.computeHashOnElements = exports.pedersen = exports.getSelector = exports.getSelectorFromName = exports.starknetKeccak = exports.keccakBn = exports.feeTransactionVersion = exports.transactionVersion = void 0;
31
+ exports.calculateContractAddressFromHash = exports.calculateTransactionHash = exports.calculateDeployAccountTransactionHash = exports.calculateDeclareTransactionHash = exports.calculateDeployTransactionHash = exports.calculateTransactionHashCommon = exports.computeHashOnElements = exports.pedersen = exports.getSelector = exports.getSelectorFromName = exports.starknetKeccak = exports.keccakBn = exports.feeTransactionVersion = exports.transactionVersion = void 0;
32
32
  var keccak_1 = require("ethereum-cryptography/keccak");
33
33
  var utils_1 = require("ethereum-cryptography/utils");
34
34
  var minimalistic_assert_1 = __importDefault(require("minimalistic-assert"));
@@ -66,7 +66,7 @@ exports.starknetKeccak = starknetKeccak;
66
66
  * @returns hex selector of given abi function name
67
67
  */
68
68
  function getSelectorFromName(funcName) {
69
- // sometimes BigInteger pads the hex string with zeros, which isnt allowed in the starknet api
69
+ // sometimes BigInteger pads the hex string with zeros, which is not allowed in the starknet api
70
70
  return (0, number_1.toHex)(starknetKeccak(funcName));
71
71
  }
72
72
  exports.getSelectorFromName = getSelectorFromName;
@@ -132,6 +132,17 @@ function calculateDeployTransactionHash(contractAddress, constructorCalldata, ve
132
132
  return calculateTransactionHashCommon(constants_1.TransactionHashPrefix.DEPLOY, version, contractAddress, getSelectorFromName('constructor'), constructorCalldata, constants_1.ZERO, chainId);
133
133
  }
134
134
  exports.calculateDeployTransactionHash = calculateDeployTransactionHash;
135
+ function calculateDeclareTransactionHash(
136
+ // contractClass: ContractClass, // Should be used once class hash is present in ContractClass
137
+ classHash, senderAddress, version, maxFee, chainId, nonce) {
138
+ return calculateTransactionHashCommon(constants_1.TransactionHashPrefix.DECLARE, version, senderAddress, 0, [classHash], maxFee, chainId, [nonce]);
139
+ }
140
+ exports.calculateDeclareTransactionHash = calculateDeclareTransactionHash;
141
+ function calculateDeployAccountTransactionHash(contractAddress, classHash, constructorCalldata, salt, version, maxFee, chainId, nonce) {
142
+ var calldata = __spreadArray([classHash, salt], __read(constructorCalldata), false);
143
+ return calculateTransactionHashCommon(constants_1.TransactionHashPrefix.DEPLOY_ACCOUNT, version, contractAddress, 0, calldata, maxFee, chainId, [nonce]);
144
+ }
145
+ exports.calculateDeployAccountTransactionHash = calculateDeployAccountTransactionHash;
135
146
  function calculateTransactionHash(contractAddress, version, calldata, maxFee, chainId, nonce) {
136
147
  return calculateTransactionHashCommon(constants_1.TransactionHashPrefix.INVOKE, version, contractAddress, 0, calldata, maxFee, chainId, [nonce]);
137
148
  }
package/utils/merkle.js CHANGED
@@ -44,7 +44,7 @@ var MerkleTree = /** @class */ (function () {
44
44
  var newLeaves = [];
45
45
  for (var i = 0; i < leaves.length; i += 2) {
46
46
  if (i + 1 === leaves.length) {
47
- newLeaves.push(leaves[i]);
47
+ newLeaves.push(MerkleTree.hash(leaves[i], '0x0'));
48
48
  }
49
49
  else {
50
50
  newLeaves.push(MerkleTree.hash(leaves[i], leaves[i + 1]));
@@ -74,9 +74,7 @@ var MerkleTree = /** @class */ (function () {
74
74
  ? -1
75
75
  : this.branches.findIndex(function (b) { return b.length === branch.length; });
76
76
  var nextBranch = (_b = this.branches[currentBranchLevelIndex + 1]) !== null && _b !== void 0 ? _b : [this.root];
77
- return this.getProof(neededBranch === '0x0'
78
- ? leaf
79
- : MerkleTree.hash(isLeft ? leaf : neededBranch, isLeft ? neededBranch : leaf), nextBranch, newHashPath);
77
+ return this.getProof(MerkleTree.hash(isLeft ? leaf : neededBranch, isLeft ? neededBranch : leaf), nextBranch, newHashPath);
80
78
  };
81
79
  return MerkleTree;
82
80
  }());
@@ -2,7 +2,7 @@
2
2
  * Map RPC Response to common interface response
3
3
  * Intersection (sequencer response ∩ (∪ rpc responses))
4
4
  */
5
- import { CallContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionReceiptResponse, GetTransactionResponse } from '../../types';
5
+ import { CallContractResponse, EstimateFeeResponse, GetBlockResponse, GetTransactionResponse } from '../../types';
6
6
  import { RPC } from '../../types/api';
7
7
  import { ResponseParser } from '.';
8
8
  declare type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
@@ -11,13 +11,9 @@ declare type RpcGetBlockResponse = RPC.GetBlockWithTxHashesResponse & {
11
11
  declare type GetTransactionByHashResponse = RPC.GetTransactionByHashResponse & {
12
12
  [key: string]: any;
13
13
  };
14
- declare type TransactionReceipt = RPC.TransactionReceipt & {
15
- [key: string]: any;
16
- };
17
- export declare class RPCResponseParser implements Omit<ResponseParser, 'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse'> {
14
+ export declare class RPCResponseParser implements Omit<ResponseParser, 'parseDeclareContractResponse' | 'parseDeployContractResponse' | 'parseInvokeFunctionResponse' | 'parseGetTransactionReceiptResponse'> {
18
15
  parseGetBlockResponse(res: RpcGetBlockResponse): GetBlockResponse;
19
16
  parseGetTransactionResponse(res: GetTransactionByHashResponse): GetTransactionResponse;
20
- parseGetTransactionReceiptResponse(res: TransactionReceipt): GetTransactionReceiptResponse;
21
17
  parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse;
22
18
  parseCallContractResponse(res: Array<string>): CallContractResponse;
23
19
  }
@@ -27,17 +27,6 @@ var RPCResponseParser = /** @class */ (function () {
27
27
  version: res.version,
28
28
  };
29
29
  };
30
- RPCResponseParser.prototype.parseGetTransactionReceiptResponse = function (res) {
31
- return {
32
- transaction_hash: res.transaction_hash,
33
- actual_fee: res.actual_fee,
34
- status: res.status,
35
- status_data: res.status_data,
36
- messages_sent: res.messages_sent,
37
- l1_origin_message: res.l1_origin_message,
38
- events: res.events,
39
- };
40
- };
41
30
  RPCResponseParser.prototype.parseFeeEstimateResponse = function (res) {
42
31
  return {
43
32
  overall_fee: (0, number_1.toBN)(res.overall_fee),
@@ -40,25 +40,15 @@ var SequencerAPIResponseParser = /** @class */ (function (_super) {
40
40
  .filter(Boolean) });
41
41
  };
42
42
  SequencerAPIResponseParser.prototype.parseGetTransactionResponse = function (res) {
43
- return {
44
- calldata: 'calldata' in res.transaction ? res.transaction.calldata : [],
45
- contract_address: 'contract_address' in res.transaction ? res.transaction.contract_address : undefined,
46
- contract_class: 'contract_class' in res.transaction ? res.transaction.contract_class : undefined,
47
- entry_point_selector: 'entry_point_selector' in res.transaction
43
+ return __assign(__assign({}, res), { calldata: 'calldata' in res.transaction ? res.transaction.calldata : [], contract_address: 'contract_address' in res.transaction ? res.transaction.contract_address : undefined, contract_class: 'contract_class' in res.transaction ? res.transaction.contract_class : undefined, entry_point_selector: 'entry_point_selector' in res.transaction
48
44
  ? res.transaction.entry_point_selector
49
- : undefined,
50
- max_fee: 'max_fee' in res.transaction ? res.transaction.max_fee : undefined,
51
- nonce: res.transaction.nonce,
52
- sender_address: 'sender_address' in res.transaction
45
+ : undefined, max_fee: 'max_fee' in res.transaction ? res.transaction.max_fee : undefined, nonce: res.transaction.nonce, sender_address: 'sender_address' in res.transaction
53
46
  ? res.transaction.sender_address
54
- : undefined,
55
- signature: 'signature' in res.transaction ? res.transaction.signature : undefined,
56
- transaction_hash: 'transaction_hash' in res.transaction ? res.transaction.transaction_hash : undefined,
57
- version: 'version' in res.transaction ? res.transaction.version : undefined,
58
- };
47
+ : undefined, signature: 'signature' in res.transaction ? res.transaction.signature : undefined, transaction_hash: 'transaction_hash' in res.transaction ? res.transaction.transaction_hash : undefined, version: 'version' in res.transaction ? res.transaction.version : undefined });
59
48
  };
60
49
  SequencerAPIResponseParser.prototype.parseGetTransactionReceiptResponse = function (res) {
61
50
  return __assign(__assign(__assign(__assign(__assign(__assign(__assign({ transaction_hash: res.transaction_hash, status: res.status, messages_sent: res.l2_to_l1_messages, events: res.events }, ('block_hash' in res && { block_hash: res.block_hash })), ('block_number' in res && { block_number: res.block_number })), ('actual_fee' in res && { actual_fee: res.actual_fee })), ('transaction_index' in res && { transaction_index: res.transaction_index })), ('execution_resources' in res && { execution_resources: res.execution_resources })), ('l1_to_l2_consumed_message' in res && {
51
+ // eslint-disable-next-line @typescript-eslint/dot-notation
62
52
  l1_to_l2_consumed_message: res['l1_to_l2_consumed_message'],
63
53
  })), ('transaction_failure_reason' in res && {
64
54
  transaction_failure_reason: res.transaction_failure_reason,
@@ -30,7 +30,7 @@ Gets the new Nonce of the connected account for the next transaction.
30
30
 
31
31
  <hr />
32
32
 
33
- account.**estimateFee**(calls [ , options ]) => _Promise < EstimateFeeResponse >_
33
+ account.**estimateInvokeFee**(calls [ , options ]) => _Promise < EstimateFeeResponse >_
34
34
 
35
35
  Gets the estimated fee for the call(s).
36
36
 
@@ -51,6 +51,27 @@ The _options_ object may include any of:
51
51
 
52
52
  <hr />
53
53
 
54
+ account.**estimateDeclareFee**(contractPayload [ , options ]) => _Promise < EstimateFeeResponse >_
55
+
56
+ Gets the estimated fee for the declare transaction.
57
+
58
+ The _options_ object may include any of:
59
+
60
+ - options.**blockIdentifier** - Block Identifier for the transaction
61
+ - options.**nonce** - Nonce for the transaction
62
+
63
+ ###### _EstimateFeeResponse_
64
+
65
+ ```typescript
66
+ {
67
+ overall_fee: BN;
68
+ gas_consumed?: BN;
69
+ gas_price?: BN;
70
+ }
71
+ ```
72
+
73
+ <hr />
74
+
54
75
  account.**execute**(calls [ , abi , transactionsDetail ]) => _Promise < AddTransactionResponse >_
55
76
 
56
77
  Executes one or multiple calls using the account contract.
@@ -71,6 +92,44 @@ The _transactionsDetail_ object may include any of:
71
92
 
72
93
  <hr />
73
94
 
95
+ account.**declare**(payload [ , transactionsDetail ]) => _Promise < DeclareContractResponse >_
96
+
97
+ The _payload_ object consists of:
98
+
99
+ - payload.**contract** - The compiled contract
100
+ - payload.**classHash** - Hash of the compiled contract
101
+
102
+ The _transactionsDetail_ object may include any of:
103
+
104
+ - transactionsDetail.**maxFee** - Max Fee that that will be used to execute the call(s)
105
+ - transactionsDetail.**nonce** - Nonce for the transaction
106
+ - transactionsDetail.**version** - Version for the transaction (default is 1)
107
+
108
+ Declares a contract on Starknet.
109
+
110
+ > _Note:_ Once the classHash is included in CompiledContract, this parameter can be removed. Currently it can be pre-computed from starknet-cli.
111
+
112
+ Example:
113
+
114
+ ```typescript
115
+ const declareTx = await account.declare({
116
+ contract: compiledErc20,
117
+ // classHash is pre-computed from starknet-cli
118
+ classHash: '0x54328a1075b8820eb43caf0caa233923148c983742402dcfc38541dd843d01a',
119
+ });
120
+ ```
121
+
122
+ ###### _DeclareContractResponse_
123
+
124
+ ```typescript
125
+ {
126
+ transaction_hash: string;
127
+ class_hash: string;
128
+ };
129
+ ```
130
+
131
+ <hr/>
132
+
74
133
  account.**signMessage**(typedData) => _Promise < Signature >_
75
134
 
76
135
  Creates a signature from the passed data.
@@ -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
- ## Creating an instance
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
- ## Methods
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.**declareContract**(payload) => _Promise < DeclareContractResponse >_
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
- Declares a contract on Starknet.
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.**deployContract**(payload [ , abi ]) => _Promise < DeployContractResponse >_
229
+ provider.**getDeclareEstimateFee**(transaction, details, blockIdentifier) => _Promise < EstimateFeeResponse >_
185
230
 
186
- Deploys a contract on Starknet.
231
+ Estimate fee for declare transaction.
187
232
 
188
- ###### _DeployContractResponse_
233
+ ###### _EstimateFeeResponse_
189
234
 
190
235
  ```typescript
191
236
  {
192
- transaction_hash: string;
193
- contract_address?: string;
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
- # SequencerProvider
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
- ## Creating an instance
253
+ ### Creating an instance
206
254
 
207
255
  `new starknet.SequencerProvider(optionsOrProvider)`
208
256
 
@@ -219,19 +267,21 @@ or
219
267
  Example:
220
268
 
221
269
  ```typescript
222
- const provider = new starknet.Provider({
270
+ const provider = new starknet.SequencerProvider({
223
271
  baseUrl: 'https://alpha4.starknet.io',
224
272
  feederGatewayUrl: 'feeder_gateway',
225
273
  gatewayUrl: 'gateway',
226
274
  })
227
275
  ```
228
276
 
229
- ## Methods
277
+ ### Methods
230
278
 
231
- Gets the smart contract address on the network.
279
+ <hr/>
232
280
 
233
281
  provider.**getContractAddresses**() => _Promise < GetContractAddressesResponse >_
234
282
 
283
+ Gets the smart contract address on the network.
284
+
235
285
  ###### _GetContractAddressesResponse_
236
286
 
237
287
  ```typescript
@@ -243,6 +293,48 @@ provider.**getContractAddresses**() => _Promise < GetContractAddressesResponse >
243
293
 
244
294
  <hr/>
245
295
 
296
+ provider.**getCode**(contractAddress, blockIdentifier) => _Promise < GetCodeResponse >_
297
+
298
+ Gets the smart contract address on the network.
299
+
300
+ ###### _GetCodeResponse_
301
+
302
+ ```typescript
303
+ {
304
+ bytecode: string[];
305
+ abi: Abi;
306
+ }
307
+ ```
308
+
309
+ <hr/>
310
+
311
+ provider.**estimateMessageFee**(CallL1Handler, blockIdentifier) => _Promise < EstimateFeeResponse >_
312
+
313
+ Estimate fee for sending a message to L1.
314
+
315
+ ##### _CallL1Handler_
316
+
317
+ ````typescript
318
+ type CallL1Handler = {
319
+ from_address: getDecimalString(from_address),
320
+ to_address: getHexString(to_address),
321
+ entry_point_selector: getSelector(entry_point_selector),
322
+ payload: getHexStringArray(payload),
323
+ };
324
+
325
+ ###### _EstimateFeeResponse_
326
+
327
+ ```typescript
328
+ {
329
+ overall_fee: number;
330
+ gas_price: number;
331
+ gas_usage: number;
332
+ unit: string;
333
+ }
334
+ ````
335
+
336
+ <hr/>
337
+
246
338
  provider.**getTransactionStatus**(txHash) => _Promise < GetTransactionStatusResponse >_
247
339
 
248
340
  Gets the status of a transaction.
@@ -297,9 +389,9 @@ Gets the transaction trace from a tx hash.
297
389
  }
298
390
  ```
299
391
 
300
- # RpcProvider
392
+ ## RpcProvider
301
393
 
302
- ## Creating an instance
394
+ ### Creating an instance
303
395
 
304
396
  `new starknet.RpcProvider(options)`
305
397
 
@@ -313,7 +405,60 @@ const provider = new starknet.RpcProvider({
313
405
  })
314
406
  ```
315
407
 
316
- ## Methods
408
+ ### Methods
409
+
410
+ <hr/>
411
+
412
+ provider.**fetch**(method: any, params: any) => _Promise < any >_
413
+
414
+ Generic method for users to be able to experiment with RPC methods.
415
+
416
+ <hr/>
417
+
418
+ provider.**getChainId**() => _Promise < any >_
419
+
420
+ <hr/>
421
+
422
+ provider.**getBlock**(blockIdentifier) => _Promise < GetBlockResponse >_
423
+
424
+ <hr/>
425
+
426
+ provider.**getBlockHashAndNumber**() => _Promise < BlockHashAndNumber >_
427
+
428
+ ###### _BlockHashAndNumber_
429
+
430
+ ```typescript
431
+ {
432
+ block_hash: BLOCK_HASH;
433
+ block_number: BLOCK_NUMBER;
434
+ }
435
+ ```
436
+
437
+ <hr/>
438
+
439
+ provider.**getBlockWithTxHashes**(blockIdentifier) => _Promise < GetBlockWithTxHashesResponse >_
440
+
441
+ ###### _GetBlockWithTxHashesResponse_
442
+
443
+ ```typescript
444
+ OPENRPC.BlockWithTxHashes
445
+ ```
446
+
447
+ <hr/>
448
+
449
+ provider.**getBlockWithTxs**(blockIdentifier) => _Promise < GetBlockWithTxs >_
450
+
451
+ ###### _GetBlockWithTxs_
452
+
453
+ ```typescript
454
+ OPENRPC.BlockWithTxs
455
+ ```
456
+
457
+ <hr/>
458
+
459
+ provider.**getClassHashAt**(blockIdentifier) => _Promise < ContractAddress >_
460
+
461
+ <hr/>
317
462
 
318
463
  provider.**getTransactionCount**(blockIdentifier) => _Promise < number >_
319
464
 
@@ -333,6 +478,148 @@ Gets the nonce of the provided contractAddress
333
478
 
334
479
  <hr/>
335
480
 
481
+ provider.**getPendingTransactions**() => _Promise < PendingTransactions >_
482
+
483
+ ###### _PendingTransactions_
484
+
485
+ ```typescript
486
+ OPENRPC.PendingTransactions;
487
+ ```
488
+
489
+ <hr/>
490
+
491
+ provider.**getStateUpdate**(blockIdentifier) => _Promise < StateUpdate >_
492
+
493
+ ###### _StateUpdate_
494
+
495
+ ```typescript
496
+ OPENRPC.StateUpdate;
497
+ ```
498
+
499
+ <hr/>
500
+
501
+ provider.**getStorageAt**(contractAddress, key, blockIdentifier) => _Promise < BigNumberish >_
502
+
503
+ <hr/>
504
+
505
+ provider.**getTransaction**(txHash) => _Promise < GetTransactionResponse >_
506
+
507
+ <hr/>
508
+
509
+ provider.**getTransactionByHash**(txHash) => _Promise < GetTransactionByHashResponse >_
510
+
511
+ ###### _GetTransactionByHashResponse_
512
+
513
+ ```typescript
514
+ OPENRPC.Transaction;
515
+ ```
516
+
517
+ <hr/>
518
+
519
+ provider.**getTransactionByBlockIdAndIndex**(blockIdentifier, index) => _Promise < GetTransactionByBlockIdAndIndex >_
520
+
521
+ ###### _GetTransactionByBlockIdAndIndex_
522
+
523
+ ```typescript
524
+ OPENRPC.Transaction;
525
+ ```
526
+
527
+ <hr/>
528
+
529
+ provider.**getTransactionReceipt**(txHash) => _Promise < GetTransactionReceiptResponse >_
530
+
531
+ <hr/>
532
+
533
+ provider.**getClass**(classHash) => _Promise < ContractClass >_
534
+
535
+ ###### _ContractClass_
536
+
537
+ ```typescript
538
+ OPENRPC.ContractClass;
539
+ ```
540
+
541
+ <hr/>
542
+
543
+ provider.**getClassAt**(contractAddress, blockIdentifier) => _Promise < ContractClass >_
544
+
545
+ ###### _ContractClass_
546
+
547
+ ```typescript
548
+ OPENRPC.ContractClass;
549
+ ```
550
+
551
+ <hr/>
552
+
553
+ provider.**getInvokeEstimateFee**(invocation, invocationDetails, blockIdentifier) => _Promise < EstimateFeeResponse >_
554
+
555
+ ###### _EstimateFeeResponse_
556
+
557
+ ```typescript
558
+ overall_fee: BN;
559
+ gas_consumed?: BN;
560
+ gas_price?: BN;
561
+ ```
562
+
563
+ <hr/>
564
+
565
+ provider.**getDeclareEstimateFee**(DeclareContractTransaction, details, blockIdentifier) => _Promise < EstimateFeeResponse >_
566
+
567
+ ###### _EstimateFeeResponse_
568
+
569
+ ```typescript
570
+ overall_fee: BN;
571
+ gas_consumed?: BN;
572
+ gas_price?: BN;
573
+ ```
574
+
575
+ <hr/>
576
+
577
+ provider.**declareContract**(DeclareContractTransaction, details) => _Promise < DeclareContractResponse >_
578
+
579
+ ###### _DeclareContractResponse_
580
+
581
+ ```typescript
582
+ transaction_hash: string;
583
+ class_hash: string;
584
+ ```
585
+
586
+ <hr/>
587
+
588
+ provider.**deployContract**(contract, constructorCalldata, addressSalt) => _Promise < DeployContractResponse >_
589
+
590
+ ###### _DeployContractResponse_
591
+
592
+ ```typescript
593
+ contract_address: string;
594
+ transaction_hash: string;
595
+ ```
596
+
597
+ <hr/>
598
+
599
+ provider.**callContract**(call, blockIdentifier) => _Promise < CallContractResponse >_
600
+
601
+ <hr/>
602
+
603
+ provider.**traceTransaction**(transactionHash) => _Promise < Trace >_
604
+
605
+ ###### _Trace_
606
+
607
+ ```typescript
608
+ OPENRPC.Trace;
609
+ ```
610
+
611
+ <hr/>
612
+
613
+ provider.**traceBlockTransactions**(blockHash) => _Promise < Traces >_
614
+
615
+ ###### _Traces_
616
+
617
+ ```typescript
618
+ OPENRPC.Traces;
619
+ ```
620
+
621
+ <hr/>
622
+
336
623
  provider.**getSyncingStats**() => _Promise < GetSyncingStatsResponse >_
337
624
 
338
625
  Gets syncing status of the node.
@@ -355,6 +642,8 @@ boolean |
355
642
 
356
643
  provider.**getEvents**(eventFilter) => _Promise < GetEventsResponse >_
357
644
 
645
+ Gets all the events filtered
646
+
358
647
  ##### _EventFilter_
359
648
 
360
649
  ```typescript
@@ -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
- "1000",
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.balance_of(account.address);
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.res, 16).toString()
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 990
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.balance_of(account.address);
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.res, 16).toString()
105
+ number.toBN(balanceAfterTransfer.balance.low, 16).toString()
100
106
  );
101
107
  ```