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.
- package/CHANGELOG.md +20 -0
- package/README.md +2 -10
- package/dist/index.d.ts +27 -9
- package/dist/index.global.js +30 -13
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +30 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -1
- package/.babelrc +0 -6
- package/.commitlintrc +0 -22
- package/.eslintignore +0 -2
- package/.eslintrc +0 -28
- package/.prettierrc +0 -6
- package/.releaserc +0 -28
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -52
- package/__mocks__/Account.json +0 -25486
- package/__mocks__/ERC20.json +0 -40027
- package/__mocks__/TestDapp.json +0 -12962
- package/__mocks__/contract.json +0 -33191
- package/__mocks__/l1l2_compiled.json +0 -10107
- package/__mocks__/multicall.json +0 -8139
- package/__mocks__/naming_compiled.json +0 -53283
- package/__mocks__/starknetId_compiled.json +0 -44703
- package/__mocks__/typedDataExample.json +0 -35
- package/__mocks__/typedDataSessionExample.json +0 -42
- package/__mocks__/typedDataStructArrayExample.json +0 -44
- package/__tests__/account.test.ts +0 -345
- package/__tests__/contract.test.ts +0 -249
- package/__tests__/defaultProvider.test.ts +0 -177
- package/__tests__/fixtures.ts +0 -84
- package/__tests__/jest.setup.ts +0 -30
- package/__tests__/rpcProvider.test.ts +0 -132
- package/__tests__/sequencerProvider.test.ts +0 -123
- package/__tests__/utils/__snapshots__/ellipticalCurve.test.ts.snap +0 -5
- package/__tests__/utils/__snapshots__/utils.browser.test.ts.snap +0 -5
- package/__tests__/utils/__snapshots__/utils.test.ts.snap +0 -5
- package/__tests__/utils/address.test.ts +0 -45
- package/__tests__/utils/ellipticalCurve.test.ts +0 -91
- package/__tests__/utils/merkle.test.ts +0 -256
- package/__tests__/utils/shortString.test.ts +0 -22
- package/__tests__/utils/starknetId.test.ts +0 -53
- package/__tests__/utils/transactionHash.test.ts +0 -17
- package/__tests__/utils/typedData.test.ts +0 -223
- package/__tests__/utils/uint256.test.ts +0 -32
- package/__tests__/utils/utils.browser.test.ts +0 -29
- package/__tests__/utils/utils.test.ts +0 -141
- package/img/logo.svg +0 -17
- package/index.d.ts +0 -2683
- package/index.global.js +0 -23192
- package/index.global.js.map +0 -1
- package/index.js +0 -4910
- package/index.js.map +0 -1
- package/index.mjs +0 -4852
- package/index.mjs.map +0 -1
- package/src/account/default.ts +0 -501
- package/src/account/index.ts +0 -2
- package/src/account/interface.ts +0 -309
- package/src/constants.ts +0 -2065
- package/src/contract/contractFactory.ts +0 -88
- package/src/contract/default.ts +0 -425
- package/src/contract/index.ts +0 -3
- package/src/contract/interface.ts +0 -106
- package/src/index.ts +0 -26
- package/src/provider/default.ts +0 -187
- package/src/provider/errors.ts +0 -14
- package/src/provider/index.ts +0 -9
- package/src/provider/interface.ts +0 -281
- package/src/provider/rpc.ts +0 -482
- package/src/provider/sequencer.ts +0 -523
- package/src/provider/utils.ts +0 -100
- package/src/signer/default.ts +0 -99
- package/src/signer/index.ts +0 -2
- package/src/signer/interface.ts +0 -77
- package/src/types/account.ts +0 -43
- package/src/types/api/index.ts +0 -10
- package/src/types/api/openrpc.ts +0 -607
- package/src/types/api/rpc.ts +0 -45
- package/src/types/api/sequencer.ts +0 -369
- package/src/types/contract.ts +0 -5
- package/src/types/index.ts +0 -8
- package/src/types/lib.ts +0 -143
- package/src/types/provider.ts +0 -134
- package/src/types/signer.ts +0 -24
- package/src/utils/address.ts +0 -44
- package/src/utils/calldata.ts +0 -250
- package/src/utils/ellipticCurve.ts +0 -120
- package/src/utils/encode.ts +0 -66
- package/src/utils/events.ts +0 -32
- package/src/utils/fetchPonyfill.ts +0 -5
- package/src/utils/hash.ts +0 -235
- package/src/utils/json.ts +0 -15
- package/src/utils/merkle.ts +0 -69
- package/src/utils/number.ts +0 -98
- package/src/utils/provider.ts +0 -28
- package/src/utils/responseParser/index.ts +0 -28
- package/src/utils/responseParser/rpc.ts +0 -70
- package/src/utils/responseParser/sequencer.ts +0 -135
- package/src/utils/shortString.ts +0 -21
- package/src/utils/stark.ts +0 -57
- package/src/utils/starknetId.ts +0 -116
- package/src/utils/transaction.ts +0 -56
- package/src/utils/typedData/index.ts +0 -247
- package/src/utils/typedData/types.ts +0 -37
- package/src/utils/typedData/utils.ts +0 -16
- package/src/utils/uint256.ts +0 -32
- package/src/utils/url.ts +0 -53
- package/tsconfig.eslint.json +0 -4
- package/tsup.config.ts +0 -9
- package/www/README.md +0 -41
- package/www/babel.config.js +0 -3
- package/www/code-examples/account.js +0 -65
- package/www/code-examples/amm.js +0 -44
- package/www/code-examples/erc20.js +0 -13
- package/www/code-examples/package-lock.json +0 -336
- package/www/code-examples/package.json +0 -15
- package/www/docs/API/_category_.json +0 -5
- package/www/docs/API/account.md +0 -463
- package/www/docs/API/changelog.md +0 -15
- package/www/docs/API/contract.md +0 -135
- package/www/docs/API/contractFactory.md +0 -45
- package/www/docs/API/index.md +0 -3
- package/www/docs/API/provider.md +0 -725
- package/www/docs/API/signer.md +0 -105
- package/www/docs/API/utils.md +0 -374
- package/www/docusaurus.config.js +0 -130
- package/www/guides/account.md +0 -140
- package/www/guides/cra.md +0 -3
- package/www/guides/erc20.md +0 -163
- package/www/guides/intro.md +0 -63
- package/www/package-lock.json +0 -20405
- package/www/package.json +0 -43
- package/www/sidebars.js +0 -31
- package/www/src/components/HomepageFeatures/index.tsx +0 -67
- package/www/src/components/HomepageFeatures/styles.module.css +0 -10
- package/www/src/css/custom.css +0 -39
- package/www/src/pages/index.module.css +0 -23
- package/www/src/pages/index.tsx +0 -40
- package/www/src/pages/markdown-page.md +0 -7
- package/www/static/.nojekyll +0 -0
- package/www/static/img/docusaurus.png +0 -0
- package/www/static/img/favicon.ico +0 -0
- package/www/static/img/logo.svg +0 -17
- package/www/static/img/starknet-1.png +0 -0
- package/www/static/img/starknet-2.png +0 -0
- package/www/static/img/starknet-3.png +0 -0
- package/www/static/img/tutorial/docsVersionDropdown.png +0 -0
- package/www/static/img/tutorial/localeDropdown.png +0 -0
package/www/docs/API/provider.md
DELETED
|
@@ -1,725 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 1
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Provider
|
|
6
|
-
|
|
7
|
-
The **Provider** API allows you to interact with the StarkNet network, without signing transactions or messages.
|
|
8
|
-
|
|
9
|
-
Typically, these are _read_ calls on the blockchain.
|
|
10
|
-
|
|
11
|
-
## Default Provider
|
|
12
|
-
|
|
13
|
-
### Creating an instance
|
|
14
|
-
|
|
15
|
-
`new starknet.Provider(optionsOrProvider)`
|
|
16
|
-
|
|
17
|
-
The options for the provider depend on the network. The structure of the options object is:
|
|
18
|
-
|
|
19
|
-
- options.**sequencer** - Options for sequencer provider
|
|
20
|
-
- options.**rpc** - Options for RPC provider
|
|
21
|
-
|
|
22
|
-
The easiest way to get started is:
|
|
23
|
-
|
|
24
|
-
```typescript
|
|
25
|
-
const provider = new starknet.Provider()
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
The above snippet creates a Starknet Provider instance with `goerli-alpha` network.
|
|
29
|
-
|
|
30
|
-
However, if you want to use `mainnet-alpha` or explicitly declare the network, you can use:
|
|
31
|
-
|
|
32
|
-
```typescript
|
|
33
|
-
const provider = new starknet.Provider({
|
|
34
|
-
sequencer: {
|
|
35
|
-
network: 'mainnet-alpha' // or 'goerli-alpha'
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
If you want more control:
|
|
41
|
-
|
|
42
|
-
```typescript
|
|
43
|
-
const provider = new starknet.Provider({
|
|
44
|
-
sequencer: {
|
|
45
|
-
baseUrl: 'https://alpha4.starknet.io',
|
|
46
|
-
feederGatewayUrl: 'feeder_gateway',
|
|
47
|
-
gatewayUrl: 'gateway',
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
These are also the default options for the Provider constructor with `network: 'goerli-alpha'`.
|
|
53
|
-
|
|
54
|
-
> **Note**
|
|
55
|
-
>
|
|
56
|
-
> `network` argument should work in most cases. If you want to use the `sequencer` argument with `baseUrl`, you will not be able to use the `network` field in the object.
|
|
57
|
-
|
|
58
|
-
### Methods
|
|
59
|
-
|
|
60
|
-
#### getChainId()
|
|
61
|
-
|
|
62
|
-
provider.**getChainId**() => _Promise < StarknetChainId >_
|
|
63
|
-
|
|
64
|
-
Returns the chain Id for the current network.
|
|
65
|
-
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
#### callContract()
|
|
69
|
-
|
|
70
|
-
provider.**callContract**(call [ , blockIdentifier ]) => _Promise < CallContractResponse >_
|
|
71
|
-
|
|
72
|
-
Calls a function on the StarkNet contract.
|
|
73
|
-
|
|
74
|
-
The call object structure:
|
|
75
|
-
|
|
76
|
-
- call.**contractAddress** - Address of the contract
|
|
77
|
-
- call.**entrypoint** - Entrypoint of the call (method name)
|
|
78
|
-
- call.**calldata** - Payload for the invoking method
|
|
79
|
-
|
|
80
|
-
###### _CallContractResponse_
|
|
81
|
-
|
|
82
|
-
```typescript
|
|
83
|
-
{
|
|
84
|
-
result: string[];
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
#### getBlock()
|
|
91
|
-
|
|
92
|
-
provider.**getBlock**(blockIdentifier) => _Promise < GetBlockResponse >_
|
|
93
|
-
|
|
94
|
-
Gets the block information.
|
|
95
|
-
|
|
96
|
-
###### _GetBlockResponse_
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
{
|
|
100
|
-
accepted_time: number;
|
|
101
|
-
block_hash: string;
|
|
102
|
-
block_number: number;
|
|
103
|
-
gas_price: string;
|
|
104
|
-
new_root: string;
|
|
105
|
-
old_root?: string;
|
|
106
|
-
parent_hash: string;
|
|
107
|
-
sequencer: string;
|
|
108
|
-
status: 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
109
|
-
transactions: Array<string>;
|
|
110
|
-
starknet_version?: string;
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
---
|
|
115
|
-
|
|
116
|
-
#### getClassAt()
|
|
117
|
-
|
|
118
|
-
provider.**getClassAt**(contractAddress, blockIdentifier) => _Promise < ContractClass >_
|
|
119
|
-
|
|
120
|
-
Gets the contract class of the deployed contract.
|
|
121
|
-
|
|
122
|
-
###### _ContractClass_
|
|
123
|
-
|
|
124
|
-
```typescript
|
|
125
|
-
{
|
|
126
|
-
program: CompressedProgram;
|
|
127
|
-
entry_points_by_type: EntryPointsByType;
|
|
128
|
-
abi?: Abi;
|
|
129
|
-
}
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
---
|
|
133
|
-
|
|
134
|
-
#### getInvokeEstimateFee()
|
|
135
|
-
|
|
136
|
-
provider.**getInvokeEstimateFee**(invocationWithTxType, invocationDetails, blockIdentifier) => _Promise < EstimateFeeResponse >_
|
|
137
|
-
|
|
138
|
-
Estimate fee for invoke transaction.
|
|
139
|
-
|
|
140
|
-
###### _EstimateFeeResponse_
|
|
141
|
-
|
|
142
|
-
```typescript
|
|
143
|
-
{
|
|
144
|
-
overall_fee: BN;
|
|
145
|
-
gas_consumed?: BN;
|
|
146
|
-
gas_price?: BN;
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
---
|
|
151
|
-
|
|
152
|
-
#### getNonceForAddress()
|
|
153
|
-
|
|
154
|
-
provider.**getNonceForAddress**(contractAddress, blockIdentifier) => _Promise < BigNumberish >_
|
|
155
|
-
|
|
156
|
-
Gets the nonce of the provided contractAddress. This was renamed from `getNonce` to `getNonceForAddress` to avoid confusion when inheriting an Account from the Provider class.
|
|
157
|
-
|
|
158
|
-
---
|
|
159
|
-
|
|
160
|
-
#### getStorageAt()
|
|
161
|
-
|
|
162
|
-
provider.**getStorageAt**(contractAddress, key, blockIdentifier) => _Promise < string >_
|
|
163
|
-
|
|
164
|
-
Gets the contract's storage variable at a specific key.
|
|
165
|
-
|
|
166
|
-
---
|
|
167
|
-
|
|
168
|
-
#### getTransactionReceipt()
|
|
169
|
-
|
|
170
|
-
provider.**getTransactionReceipt**(txHash) => _Promise < GetTransactionReceiptResponse >_
|
|
171
|
-
|
|
172
|
-
Gets the status of a transaction.
|
|
173
|
-
|
|
174
|
-
###### _GetTransactionReceiptResponse_
|
|
175
|
-
|
|
176
|
-
```typescript
|
|
177
|
-
{
|
|
178
|
-
transaction_hash: string;
|
|
179
|
-
status: 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
180
|
-
actual_fee?: string;
|
|
181
|
-
status_data?: string;
|
|
182
|
-
messages_sent?: Array<MessageToL1>;
|
|
183
|
-
events?: Array<Event>;
|
|
184
|
-
l1_origin_message?: MessageToL2;
|
|
185
|
-
}
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
---
|
|
189
|
-
|
|
190
|
-
#### getTransaction()
|
|
191
|
-
|
|
192
|
-
provider.**getTransaction**(txHash) => _Promise < GetTransactionResponse >_
|
|
193
|
-
|
|
194
|
-
Gets the transaction information from a tx hash.
|
|
195
|
-
|
|
196
|
-
###### _GetTransactionResponse_
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
{
|
|
200
|
-
transaction_hash: string;
|
|
201
|
-
version?: string;
|
|
202
|
-
signature?: Signature;
|
|
203
|
-
max_fee?: string;
|
|
204
|
-
nonce?: string;
|
|
205
|
-
contract_address?: string;
|
|
206
|
-
entry_point_selector?: string;
|
|
207
|
-
calldata?: RawCalldata;
|
|
208
|
-
contract_class?: ContractClass;
|
|
209
|
-
sender_address?: string;
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
#### declareContract()
|
|
216
|
-
|
|
217
|
-
provider.**declareContract**(transaction, details) => _Promise < DeclareContractResponse >_
|
|
218
|
-
|
|
219
|
-
Declare a contract on Starknet.
|
|
220
|
-
|
|
221
|
-
###### _DeclareContractResponse_
|
|
222
|
-
|
|
223
|
-
```typescript
|
|
224
|
-
{
|
|
225
|
-
transaction_hash: string;
|
|
226
|
-
class_hash: string;
|
|
227
|
-
};
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
---
|
|
231
|
-
|
|
232
|
-
#### getDeclareEstimateFee()
|
|
233
|
-
|
|
234
|
-
provider.**getDeclareEstimateFee**(transaction, details, blockIdentifier) => _Promise < EstimateFeeResponse >_
|
|
235
|
-
|
|
236
|
-
Estimate fee for declare transaction.
|
|
237
|
-
|
|
238
|
-
###### _EstimateFeeResponse_
|
|
239
|
-
|
|
240
|
-
```typescript
|
|
241
|
-
{
|
|
242
|
-
overall_fee: BN;
|
|
243
|
-
gas_consumed?: BN;
|
|
244
|
-
gas_price?: BN;
|
|
245
|
-
};
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
---
|
|
249
|
-
|
|
250
|
-
#### waitForTransaction()
|
|
251
|
-
|
|
252
|
-
provider.**waitForTransaction**(txHash [ , retryInterval]) => _Promise < GetTransactionReceiptResponse >_
|
|
253
|
-
|
|
254
|
-
Wait for the transaction to be accepted on L2 or L1.
|
|
255
|
-
|
|
256
|
-
## SequencerProvider
|
|
257
|
-
|
|
258
|
-
On top of methods found in the [Default Provider](#default-provider) section, `SequencerProvider` has some additional ones you can use.
|
|
259
|
-
|
|
260
|
-
### Creating an instance
|
|
261
|
-
|
|
262
|
-
`new starknet.SequencerProvider(optionsOrProvider)`
|
|
263
|
-
|
|
264
|
-
The options for the provider depend on the network. The structure of the options object is:
|
|
265
|
-
|
|
266
|
-
- options.**baseUrl** - Base URL of the network
|
|
267
|
-
- options.**feederGatewayUrl** - Feeder Gateway Endpoint of the network
|
|
268
|
-
- options.**gatewayUrl** - Gateway Endpoint
|
|
269
|
-
- options.**headers** - [Optional] custom fetch headers
|
|
270
|
-
|
|
271
|
-
or
|
|
272
|
-
|
|
273
|
-
- options.**network** - Either 'mainnet-alpha' or 'goerli-alpha'
|
|
274
|
-
- options.**headers** - [Optional] custom fetch headers
|
|
275
|
-
|
|
276
|
-
Example:
|
|
277
|
-
|
|
278
|
-
```typescript
|
|
279
|
-
const provider = new starknet.SequencerProvider({
|
|
280
|
-
baseUrl: 'https://alpha4.starknet.io',
|
|
281
|
-
feederGatewayUrl: 'feeder_gateway',
|
|
282
|
-
gatewayUrl: 'gateway',
|
|
283
|
-
})
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
### Methods
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
#### getContractAddresses()
|
|
291
|
-
|
|
292
|
-
provider.**getContractAddresses**() => _Promise < GetContractAddressesResponse >_
|
|
293
|
-
|
|
294
|
-
Gets the smart contract address on the network.
|
|
295
|
-
|
|
296
|
-
###### _GetContractAddressesResponse_
|
|
297
|
-
|
|
298
|
-
```typescript
|
|
299
|
-
{
|
|
300
|
-
Starknet: string;
|
|
301
|
-
GpsStatementVerifier: string;
|
|
302
|
-
}
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
---
|
|
306
|
-
|
|
307
|
-
#### getCode()
|
|
308
|
-
|
|
309
|
-
provider.**getCode**(contractAddress, blockIdentifier) => _Promise < GetCodeResponse >_
|
|
310
|
-
|
|
311
|
-
Gets the smart contract address on the network.
|
|
312
|
-
|
|
313
|
-
###### _GetCodeResponse_
|
|
314
|
-
|
|
315
|
-
```typescript
|
|
316
|
-
{
|
|
317
|
-
bytecode: string[];
|
|
318
|
-
abi: Abi;
|
|
319
|
-
}
|
|
320
|
-
```
|
|
321
|
-
|
|
322
|
-
---
|
|
323
|
-
|
|
324
|
-
#### estimateMessageFee()
|
|
325
|
-
|
|
326
|
-
provider.**estimateMessageFee**(CallL1Handler, blockIdentifier) => _Promise < EstimateFeeResponse >_
|
|
327
|
-
|
|
328
|
-
Estimate fee for sending a message to L1.
|
|
329
|
-
|
|
330
|
-
##### _CallL1Handler_
|
|
331
|
-
|
|
332
|
-
````typescript
|
|
333
|
-
type CallL1Handler = {
|
|
334
|
-
from_address: getDecimalString(from_address),
|
|
335
|
-
to_address: getHexString(to_address),
|
|
336
|
-
entry_point_selector: getSelector(entry_point_selector),
|
|
337
|
-
payload: getHexStringArray(payload),
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
###### _EstimateFeeResponse_
|
|
341
|
-
|
|
342
|
-
```typescript
|
|
343
|
-
{
|
|
344
|
-
overall_fee: number;
|
|
345
|
-
gas_price: number;
|
|
346
|
-
gas_usage: number;
|
|
347
|
-
unit: string;
|
|
348
|
-
}
|
|
349
|
-
````
|
|
350
|
-
|
|
351
|
-
---
|
|
352
|
-
|
|
353
|
-
#### getTransactionStatus()
|
|
354
|
-
|
|
355
|
-
provider.**getTransactionStatus**(txHash) => _Promise < GetTransactionStatusResponse >_
|
|
356
|
-
|
|
357
|
-
Gets the status of a transaction.
|
|
358
|
-
|
|
359
|
-
###### _GetTransactionStatusResponse_
|
|
360
|
-
|
|
361
|
-
```typescript
|
|
362
|
-
{
|
|
363
|
-
tx_status: 'NOT_RECEIVED' | 'RECEIVED' | 'PENDING' | 'ACCEPTED_ON_L2' | 'ACCEPTED_ON_L1' | 'REJECTED';
|
|
364
|
-
block_hash: string;
|
|
365
|
-
tx_failure_reason?: {
|
|
366
|
-
tx_id: number;
|
|
367
|
-
code: string;
|
|
368
|
-
error_message: string;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
```
|
|
372
|
-
|
|
373
|
-
---
|
|
374
|
-
|
|
375
|
-
#### getTransactionTrace()
|
|
376
|
-
|
|
377
|
-
provider.**getTransactionTrace**(txHash) => _Promise < GetTransactionTraceResponse >_
|
|
378
|
-
|
|
379
|
-
Gets the transaction trace from a tx hash.
|
|
380
|
-
|
|
381
|
-
###### _GetTransactionTraceResponse_
|
|
382
|
-
|
|
383
|
-
```typescript
|
|
384
|
-
{
|
|
385
|
-
validate_invocation?: FunctionInvocation;
|
|
386
|
-
function_invocation?: FunctionInvocation;
|
|
387
|
-
fee_transfer_invocation?: FunctionInvocation;
|
|
388
|
-
signature: Signature;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
{
|
|
392
|
-
FunctionInvocation: {
|
|
393
|
-
caller_address: string;
|
|
394
|
-
contract_address: string;
|
|
395
|
-
calldata: {
|
|
396
|
-
[inputName: string]: string | string[] | { type: 'struct'; [k: string]: BigNumberish };
|
|
397
|
-
};
|
|
398
|
-
call_type?: string;
|
|
399
|
-
class_hash?: string;
|
|
400
|
-
selector?: string;
|
|
401
|
-
entry_point_type?: EntryPointType;
|
|
402
|
-
result: Array<any>;
|
|
403
|
-
execution_resources: ExecutionResources;
|
|
404
|
-
internal_calls: Array<FunctionInvocation>;
|
|
405
|
-
events: Array<any>;
|
|
406
|
-
messages: Array<any>;
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
## RpcProvider
|
|
412
|
-
|
|
413
|
-
### Creating an instance
|
|
414
|
-
|
|
415
|
-
`new starknet.RpcProvider(options)`
|
|
416
|
-
|
|
417
|
-
- options.**nodeUrl** - Starknet RPC node url
|
|
418
|
-
- options.**headers** - [Optional] custom fetch headers
|
|
419
|
-
- options.**retries** - [Optional] wait for transaction max retries
|
|
420
|
-
- options.**blockIdentifier** - [Optional] default value set to 'latest'
|
|
421
|
-
|
|
422
|
-
Example:
|
|
423
|
-
|
|
424
|
-
```typescript
|
|
425
|
-
const provider = new starknet.RpcProvider({
|
|
426
|
-
nodeUrl: 'URL_TO_STARKNET_RPC_NODE',
|
|
427
|
-
})
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
### Methods
|
|
431
|
-
|
|
432
|
-
---
|
|
433
|
-
|
|
434
|
-
#### fetch()
|
|
435
|
-
|
|
436
|
-
provider.**fetch**(method: any, params: any) => _Promise < any >_
|
|
437
|
-
|
|
438
|
-
Generic method for users to be able to experiment with RPC methods.
|
|
439
|
-
|
|
440
|
-
---
|
|
441
|
-
|
|
442
|
-
#### getChainId()
|
|
443
|
-
|
|
444
|
-
provider.**getChainId**() => _Promise < any >_
|
|
445
|
-
|
|
446
|
-
---
|
|
447
|
-
|
|
448
|
-
#### getBlock()
|
|
449
|
-
|
|
450
|
-
provider.**getBlock**(blockIdentifier) => _Promise < GetBlockResponse >_
|
|
451
|
-
|
|
452
|
-
---
|
|
453
|
-
|
|
454
|
-
#### getBlockHashAndNumber()
|
|
455
|
-
|
|
456
|
-
provider.**getBlockHashAndNumber**() => _Promise < BlockHashAndNumber >_
|
|
457
|
-
|
|
458
|
-
###### _BlockHashAndNumber_
|
|
459
|
-
|
|
460
|
-
```typescript
|
|
461
|
-
{
|
|
462
|
-
block_hash: BLOCK_HASH;
|
|
463
|
-
block_number: BLOCK_NUMBER;
|
|
464
|
-
}
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
---
|
|
468
|
-
|
|
469
|
-
#### getBlockWithTxHashes()
|
|
470
|
-
|
|
471
|
-
provider.**getBlockWithTxHashes**(blockIdentifier) => _Promise < GetBlockWithTxHashesResponse >_
|
|
472
|
-
|
|
473
|
-
###### _GetBlockWithTxHashesResponse_
|
|
474
|
-
|
|
475
|
-
```typescript
|
|
476
|
-
OPENRPC.BlockWithTxHashes
|
|
477
|
-
```
|
|
478
|
-
|
|
479
|
-
---
|
|
480
|
-
|
|
481
|
-
#### getBlockWithTxs()
|
|
482
|
-
|
|
483
|
-
provider.**getBlockWithTxs**(blockIdentifier) => _Promise < GetBlockWithTxs >_
|
|
484
|
-
|
|
485
|
-
###### _GetBlockWithTxs_
|
|
486
|
-
|
|
487
|
-
```typescript
|
|
488
|
-
OPENRPC.BlockWithTxs
|
|
489
|
-
```
|
|
490
|
-
|
|
491
|
-
---
|
|
492
|
-
|
|
493
|
-
#### getClassHashAt()
|
|
494
|
-
|
|
495
|
-
provider.**getClassHashAt**(blockIdentifier) => _Promise < ContractAddress >_
|
|
496
|
-
|
|
497
|
-
---
|
|
498
|
-
|
|
499
|
-
#### getTransactionCount()
|
|
500
|
-
|
|
501
|
-
provider.**getTransactionCount**(blockIdentifier) => _Promise < number >_
|
|
502
|
-
|
|
503
|
-
Gets the transaction count from a block.
|
|
504
|
-
|
|
505
|
-
---
|
|
506
|
-
|
|
507
|
-
#### getBlockNumber()
|
|
508
|
-
|
|
509
|
-
provider.**getBlockNumber**() => _Promise < number >_
|
|
510
|
-
|
|
511
|
-
Gets the latest block number.
|
|
512
|
-
|
|
513
|
-
---
|
|
514
|
-
|
|
515
|
-
#### getPendingTransactions()
|
|
516
|
-
|
|
517
|
-
provider.**getPendingTransactions**() => _Promise < PendingTransactions >_
|
|
518
|
-
|
|
519
|
-
###### _PendingTransactions_
|
|
520
|
-
|
|
521
|
-
```typescript
|
|
522
|
-
OPENRPC.PendingTransactions;
|
|
523
|
-
```
|
|
524
|
-
|
|
525
|
-
---
|
|
526
|
-
|
|
527
|
-
#### getStateUpdate()
|
|
528
|
-
|
|
529
|
-
provider.**getStateUpdate**(blockIdentifier) => _Promise < StateUpdate >_
|
|
530
|
-
|
|
531
|
-
###### _StateUpdate_
|
|
532
|
-
|
|
533
|
-
```typescript
|
|
534
|
-
OPENRPC.StateUpdate;
|
|
535
|
-
```
|
|
536
|
-
|
|
537
|
-
---
|
|
538
|
-
|
|
539
|
-
#### getStorageAt()
|
|
540
|
-
|
|
541
|
-
provider.**getStorageAt**(contractAddress, key, blockIdentifier) => _Promise < BigNumberish >_
|
|
542
|
-
|
|
543
|
-
---
|
|
544
|
-
|
|
545
|
-
#### getTransaction()
|
|
546
|
-
|
|
547
|
-
provider.**getTransaction**(txHash) => _Promise < GetTransactionResponse >_
|
|
548
|
-
|
|
549
|
-
---
|
|
550
|
-
|
|
551
|
-
#### getTransactionByHash()
|
|
552
|
-
|
|
553
|
-
provider.**getTransactionByHash**(txHash) => _Promise < GetTransactionByHashResponse >_
|
|
554
|
-
|
|
555
|
-
###### _GetTransactionByHashResponse_
|
|
556
|
-
|
|
557
|
-
```typescript
|
|
558
|
-
OPENRPC.Transaction;
|
|
559
|
-
```
|
|
560
|
-
|
|
561
|
-
---
|
|
562
|
-
|
|
563
|
-
#### getTransactionByBlockIdAndIndex()
|
|
564
|
-
|
|
565
|
-
provider.**getTransactionByBlockIdAndIndex**(blockIdentifier, index) => _Promise < GetTransactionByBlockIdAndIndex >_
|
|
566
|
-
|
|
567
|
-
###### _GetTransactionByBlockIdAndIndex_
|
|
568
|
-
|
|
569
|
-
```typescript
|
|
570
|
-
OPENRPC.Transaction;
|
|
571
|
-
```
|
|
572
|
-
|
|
573
|
-
---
|
|
574
|
-
|
|
575
|
-
#### getTransactionReceipt()
|
|
576
|
-
|
|
577
|
-
provider.**getTransactionReceipt**(txHash) => _Promise < GetTransactionReceiptResponse >_
|
|
578
|
-
|
|
579
|
-
---
|
|
580
|
-
|
|
581
|
-
#### getClass()
|
|
582
|
-
|
|
583
|
-
provider.**getClass**(classHash) => _Promise < ContractClass >_
|
|
584
|
-
|
|
585
|
-
###### _ContractClass_
|
|
586
|
-
|
|
587
|
-
```typescript
|
|
588
|
-
OPENRPC.ContractClass;
|
|
589
|
-
```
|
|
590
|
-
|
|
591
|
-
---
|
|
592
|
-
|
|
593
|
-
#### getClassAt()
|
|
594
|
-
|
|
595
|
-
provider.**getClassAt**(contractAddress, blockIdentifier) => _Promise < ContractClass >_
|
|
596
|
-
|
|
597
|
-
###### _ContractClass_
|
|
598
|
-
|
|
599
|
-
```typescript
|
|
600
|
-
OPENRPC.ContractClass;
|
|
601
|
-
```
|
|
602
|
-
|
|
603
|
-
---
|
|
604
|
-
|
|
605
|
-
#### getInvokeEstimateFee()
|
|
606
|
-
|
|
607
|
-
provider.**getInvokeEstimateFee**(invocation, invocationDetails, blockIdentifier) => _Promise < EstimateFeeResponse >_
|
|
608
|
-
|
|
609
|
-
###### _EstimateFeeResponse_
|
|
610
|
-
|
|
611
|
-
```typescript
|
|
612
|
-
overall_fee: BN;
|
|
613
|
-
gas_consumed?: BN;
|
|
614
|
-
gas_price?: BN;
|
|
615
|
-
```
|
|
616
|
-
|
|
617
|
-
---
|
|
618
|
-
|
|
619
|
-
#### getDeclareEstimateFee()
|
|
620
|
-
|
|
621
|
-
provider.**getDeclareEstimateFee**(DeclareContractTransaction, details, blockIdentifier) => _Promise < EstimateFeeResponse >_
|
|
622
|
-
|
|
623
|
-
###### _EstimateFeeResponse_
|
|
624
|
-
|
|
625
|
-
```typescript
|
|
626
|
-
overall_fee: BN;
|
|
627
|
-
gas_consumed?: BN;
|
|
628
|
-
gas_price?: BN;
|
|
629
|
-
```
|
|
630
|
-
|
|
631
|
-
---
|
|
632
|
-
|
|
633
|
-
#### declareContract()
|
|
634
|
-
|
|
635
|
-
provider.**declareContract**(DeclareContractTransaction, details) => _Promise < DeclareContractResponse >_
|
|
636
|
-
|
|
637
|
-
###### _DeclareContractResponse_
|
|
638
|
-
|
|
639
|
-
```typescript
|
|
640
|
-
transaction_hash: string;
|
|
641
|
-
class_hash: string;
|
|
642
|
-
```
|
|
643
|
-
|
|
644
|
-
---
|
|
645
|
-
|
|
646
|
-
#### callContract()
|
|
647
|
-
|
|
648
|
-
provider.**callContract**(call, blockIdentifier) => _Promise < CallContractResponse >_
|
|
649
|
-
|
|
650
|
-
---
|
|
651
|
-
|
|
652
|
-
#### getContractAddresses()
|
|
653
|
-
|
|
654
|
-
provider.**traceTransaction**(transactionHash) => _Promise < Trace >_
|
|
655
|
-
|
|
656
|
-
###### _Trace_
|
|
657
|
-
|
|
658
|
-
```typescript
|
|
659
|
-
OPENRPC.Trace;
|
|
660
|
-
```
|
|
661
|
-
|
|
662
|
-
---
|
|
663
|
-
|
|
664
|
-
#### traceBlockTransactions()
|
|
665
|
-
|
|
666
|
-
provider.**traceBlockTransactions**(blockHash) => _Promise < Traces >_
|
|
667
|
-
|
|
668
|
-
###### _Traces_
|
|
669
|
-
|
|
670
|
-
```typescript
|
|
671
|
-
OPENRPC.Traces;
|
|
672
|
-
```
|
|
673
|
-
|
|
674
|
-
---
|
|
675
|
-
|
|
676
|
-
#### getSyncingStats()
|
|
677
|
-
|
|
678
|
-
provider.**getSyncingStats**() => _Promise < GetSyncingStatsResponse >_
|
|
679
|
-
|
|
680
|
-
Gets syncing status of the node.
|
|
681
|
-
|
|
682
|
-
###### _GetSyncingStatsResponse_
|
|
683
|
-
|
|
684
|
-
```typescript
|
|
685
|
-
boolean |
|
|
686
|
-
{
|
|
687
|
-
starting_block_hash: string;
|
|
688
|
-
starting_block_num: string;
|
|
689
|
-
current_block_hash: string;
|
|
690
|
-
current_block_num: string;
|
|
691
|
-
highest_block_hash: string;
|
|
692
|
-
highest_block_num: string;
|
|
693
|
-
}
|
|
694
|
-
```
|
|
695
|
-
|
|
696
|
-
---
|
|
697
|
-
|
|
698
|
-
#### getEvents()
|
|
699
|
-
|
|
700
|
-
provider.**getEvents**(eventFilter) => _Promise < GetEventsResponse >_
|
|
701
|
-
|
|
702
|
-
Gets all the events filtered
|
|
703
|
-
|
|
704
|
-
##### _EventFilter_
|
|
705
|
-
|
|
706
|
-
```typescript
|
|
707
|
-
type EventFilter = {
|
|
708
|
-
fromBlock: string;
|
|
709
|
-
toBlock: string;
|
|
710
|
-
address: string;
|
|
711
|
-
keys: string[];
|
|
712
|
-
page_size: number;
|
|
713
|
-
page_number: number;
|
|
714
|
-
};
|
|
715
|
-
```
|
|
716
|
-
|
|
717
|
-
###### _GetEventsResponse_
|
|
718
|
-
|
|
719
|
-
```typescript
|
|
720
|
-
{
|
|
721
|
-
events: StarknetEmittedEvent[];
|
|
722
|
-
page_number: number;
|
|
723
|
-
is_last_page: number;
|
|
724
|
-
}
|
|
725
|
-
```
|