Skip to content

Commit ab7aa0a

Browse files
docs: update guides for v7 (#1376)
--------- Co-authored-by: Petar Penovic <[email protected]>
1 parent eb8b10d commit ab7aa0a

21 files changed

+718
-404
lines changed

www/docs/guides/L1message.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ sidebar_position: 14
66

77
You can exchange messages between L1 & L2 networks:
88

9-
- L2 Starknet mainnet ↔️ L1 Ethereum.
10-
- L2 Starknet testnet ↔️ L1 Sepolia ETH testnet.
11-
- L2 local Starknet devnet ↔️ L1 local ETH testnet (anvil, ...).
9+
- L2 Starknet Mainnet ↔️ L1 Ethereum.
10+
- L2 Starknet Testnet ↔️ L1 Sepolia ETH testnet.
11+
- L2 local Starknet Devnet ↔️ L1 local ETH testnet (anvil, ...).
1212

13-
You can find an explanation of the global mechanism [here](https://docs.starknet.io/documentation/architecture_and_concepts/L1-L2_Communication/messaging-mechanism/).
13+
You can find an explanation of the global mechanism [here](https://docs.starknet.io/architecture-and-concepts/network-architecture/messaging-mechanism/).
1414

1515
Most of the code for this messaging process will be written in Cairo, but Starknet.js provides some functionalities for this subject.
1616

www/docs/guides/cairo_enum.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ const res14e = (await myTestContract.call('test2a', [
269269
])) as bigint;
270270
```
271271
272-
Take care that if you call a method that do not use the abi (as `CallData.compile`), you have to list all the variants of the enum, like this:
272+
Take care that if you call a method that do not use the ABI (as `CallData.compile`), you have to list all the variants of the enum, like this:
273273
274274
```typescript
275275
const orderToSend: Order = { p1: 8, p2: 10 };

www/docs/guides/connect_account.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ You need 2 pieces of data:
1515
import { Account, RpcProvider } from 'starknet';
1616
```
1717

18-
## Connect to a pre-deployed account in Starknet-devnet-rs
18+
## Connect to a pre-deployed account in Starknet Devnet
1919

20-
When you launch starknet-devnet-rs, 10 accounts are pre-deployed with 100 dummy ETH in each.
20+
When you launch `starknet-devnet`, 10 accounts are pre-deployed with 100 dummy ETH and STRK in each.
2121

2222
Addresses and private keys are displayed on the console at initialization.
2323

@@ -34,23 +34,17 @@ Public key : 0x7e52885445756b313ea16849145363ccb73fb4ab0440dbac333cf9d13de82b9
3434
Then you can use this code:
3535

3636
```typescript
37-
// initialize provider
37+
// initialize provider for Devnet v0.3.0
3838
const provider = new RpcProvider({ nodeUrl: 'http://127.0.0.1:5050/rpc' });
39-
// initialize existing pre-deployed account 0 of Devnet
40-
const privateKey = '0x71d7bb07b9a64f6f78ac4c816aff4da9';
39+
// initialize existing account 0 pre-deployed on Devnet
4140
const accountAddress = '0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691';
41+
const privateKey = '0x71d7bb07b9a64f6f78ac4c816aff4da9';
4242

4343
const account = new Account(provider, accountAddress, privateKey);
4444
```
4545

4646
Your account is now connected, and you can use it.
4747

48-
```typescript
49-
const account = new Account(provider, accountAddress, privateKey);
50-
```
51-
52-
> Take care that this added parameter is a string, NOT a number.
53-
5448
## 👛 Connect to an existing account (in any network)
5549

5650
The code is the same, you just have to:
@@ -65,7 +59,7 @@ For example, to connect an existing account on testnet, with a private key store
6559
import * as dotenv from 'dotenv';
6660
dotenv.config();
6761

68-
// initialize provider
62+
// initialize RPC v0.8 provider
6963
const provider = new RpcProvider({ nodeUrl: `${myNodeUrl}` });
7064
// initialize existing account
7165
const privateKey = process.env.OZ_NEW_ACCOUNT_PRIVKEY;
@@ -74,9 +68,25 @@ const accountAddress = '0x051158d244c7636dde39ec822873b29e6c9a758c6a9812d005b628
7468
const account = new Account(provider, accountAddress, privateKey);
7569
```
7670

71+
:::tip
72+
If you are connected to an RPC v0.7 node and you want to use ETH as fees for this account:
73+
74+
```typescript
75+
const myAccount = new Account(
76+
provider,
77+
accountAddress,
78+
privateKey,
79+
undefined,
80+
ETransactionVersion.V2
81+
);
82+
```
83+
84+
:::
85+
7786
## Connect to an account that uses Ethereum signature
7887

79-
As a consequence of account abstraction, you can find accounts that uses Ethereum signature logical.
88+
Accounts that use Ethereum signatures are possible because of account abstraction.
89+
8090
To connect to this type of account:
8191

8292
```typescript

www/docs/guides/connect_contract.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ Once your provider is initialized, you can connect a contract already deployed i
99
You need 2 pieces of data:
1010

1111
- the address of the contract
12-
- the ABI file of the contract (or the compiled/compressed contract file, that includes the abi)
12+
- the ABI file of the contract (or the compiled/compressed contract file, that includes the ABI)
1313

14-
> If you don't have the abi file, the `provider.getClassAt()` and `provider.getClassByHash()` commands will recover the compressed contract file. As these methods generate a significant workload for the sequencer/node, it's recommended to store the result on your computer to be able to reuse it later without using the provider each time:
14+
> If you don't have the ABI file, the `provider.getClassAt()` and `provider.getClassByHash()` commands will recover the compressed contract file. As these methods generate a significant workload for the node, it's recommended to store the result on your computer to be able to reuse it later without using the provider each time:
1515
1616
```typescript
1717
import fs from 'fs';
@@ -22,7 +22,7 @@ fs.writeFileSync('./myAbi.json', json.stringify(compressedContract.abi, undefine
2222

2323
> When possible, prefer to read the compiled contract from a local Json file, as it's much more faster, using the `json.parse` util provided by Starknet.js, as shown below.
2424
25-
## Get the abi from a compiled/compressed file
25+
## Get the ABI from a compiled/compressed file
2626

2727
```typescript
2828
import { RpcProvider, Contract, json } from 'starknet';

www/docs/guides/connect_network.md

Lines changed: 110 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ sidebar_position: 3
44

55
# RpcProvider object 🔌 connect to the network
66

7-
The first thing to do is to define with which network you want to interact.
7+
The first thing to do is to define with which network you want to interact (Mainnet, Testnet, Devnet, ...).
88

99
Then you need to select a node. A node is a safe way to connect with the Starknet blockchain. You can use:
1010

@@ -13,47 +13,85 @@ Then you need to select a node. A node is a safe way to connect with the Starkne
1313
- your own node, located on your local computer or in your local network.
1414
> you can spin up your own node with Pathfinder, Juno, Papyrus, Deoxys, ...
1515
- a local development node, that simulates a Starknet network. Useful for devs to perform quick tests without spending precious fee token.
16-
> Main development devnets are Starknet-devnet-rs, Madara, ...
16+
> Main development devnets are Starknet Devnet, Madara, ...
1717
18-
Each node is communicating with Starknet.js using a rpc specification. Most of the nodes are able to use 2 rpc spec versions.
19-
For example, this node is compatible with v0.6.0 & v0.7.0, using the following entry points :
18+
Starknet.js communicates with nodes in accordance to a version of the RPC specification. Most nodes are able to use two RPC versions.
19+
For example, this node is compatible with v0.7.1 and v0.8.0, using the following entry points:
2020

21-
- "https://free-rpc.nethermind.io/sepolia-juno/v0_6"
2221
- "https://free-rpc.nethermind.io/sepolia-juno/v0_7"
22+
- "https://free-rpc.nethermind.io/sepolia-juno/v0_8"
2323

24-
From rpc spec v0.5.0, you can request the rpc spec version that uses a node address :
24+
From RPC v0.5.0, you can make a request to retrieve the RPC version that a node uses:
2525

2626
```typescript
2727
const resp = await myProvider.getSpecVersion();
28-
console.log('rpc version =', resp);
29-
// result : rpc version = 0.7.0
28+
console.log('RPC version =', resp);
29+
// result: RPC version = 0.8.0
3030
```
3131

32-
On Starknet.js side, you have to select the proper version, to be in accordance with the node you want to use :
32+
The Starknet.js version must align with the RPC version supported by the chosen node as shown below:
3333

34-
| Rpc spec version of your node | Starknet.js version to use |
35-
| :---------------------------: | ---------------------------- |
36-
| v0.4.0 | Starknet.js v5.21.1 |
37-
| v0.5.0 | Starknet.js v5.23.0 |
38-
| v0.5.1 | Starknet.js v5.29.0 & v6.1.0 |
39-
| v0.6.0 | Starknet.js v6.23.1 |
40-
| v0.7.1 | Starknet.js v6.23.1 |
34+
| RPC spec version of your node | Starknet.js version to use |
35+
| :---------------------------: | ----------------------------- |
36+
| v0.4.0 | Starknet.js v5.21.1 |
37+
| v0.5.0 | Starknet.js v5.23.0 |
38+
| v0.5.1 | Starknet.js v5.29.0 or v6.1.0 |
39+
| v0.6.0 | Starknet.js v6.24.1 |
40+
| v0.7.1 | Starknet.js v6.24.1 or v7.0.1 |
41+
| v0.8.0 | Starknet.js v7.0.1 |
4142

4243
:::note
43-
Each Starknet.js version 6.x.x is compatible with 2 rpc spec versions, and recognize automatically the spec version if not provided.
44+
From version 6.x.x, Starknet.js is compatible with two RPC spec versions.
4445
:::
4546

46-
With the `RpcProvider` class, you define the Starknet Rpc node to use.
47+
With the `RpcProvider` class, you define the Starknet RPC node to use:
4748

4849
```typescript
4950
import { RpcProvider } from 'starknet';
5051
```
5152

5253
## Connect your DAPP to an RPC node provider
5354

54-
### Default Rpc node
55+
### Available nodes
5556

56-
If you don't want to use a specific node, or to handle an API key, you can use by default (using Rpc spec 0.7.0):
57+
**Mainnet network:**
58+
59+
| Node | with public url | with API key |
60+
| -----------------------: | :--------------: | :--------------: |
61+
| Alchemy | No | v0_6, v0_7 |
62+
| Infura | No | v0_7 |
63+
| Blast | v0_6, v0_7, v0_8 | v0_6, v0_7, v0_8 |
64+
| Nethermind | v0_6, v0_7, v0_8 | No |
65+
| Lava | v0_6, v0_7, v0_8 | v0_8 |
66+
| Local Pathfinder v0.16.2 | v0_6, v0_7, v0_8 | N/A |
67+
| Local Juno v0.14.2 | v0_6, v0_7, v0_8 | N/A |
68+
69+
**Sepolia Testnet network:**
70+
71+
| Node | with public url | with API key |
72+
| -----------------------: | :--------------: | :----------: |
73+
| Alchemy | No | v0_6, v0_7 |
74+
| Infura | No | v0_7 |
75+
| Blast | v0_6, v0_7, v0_8 | No |
76+
| Nethermind | v0_6, v0_7, v0_8 | No |
77+
| Lava | v0_6, v0_7, v0_8 | No |
78+
| Local Pathfinder v0.16.2 | v0_6, v0_7, v0_8 | N/A |
79+
| Local Juno v0.14.2 | v0_6, v0_7, v0_8 | N/A |
80+
81+
**Local Starknet Devnet network:**
82+
83+
| Node | with public url | with API key |
84+
| ---------------------: | :-------------: | :----------: |
85+
| starknet-devnet v0.2.4 | v0_7 | N/A |
86+
| starknet-devnet v0.3.0 | v0_8 | N/A |
87+
88+
:::note
89+
This status has been verified 02/apr/2025.
90+
:::
91+
92+
### Default RPC node
93+
94+
If you don't want to use a specific node or to handle an API key, you can use one of the defaults (using RPC spec v0.8.0):
5795

5896
```typescript
5997
const myProvider = new RpcProvider({ nodeUrl: constants.NetworkName.SN_SEPOLIA });
@@ -62,67 +100,93 @@ const myProvider = new RpcProvider({ nodeUrl: constants.NetworkName.SN_MAIN });
62100
const myProvider = new RpcProvider(); // Sepolia
63101
```
64102

65-
> when using this syntax, a random public node will be selected.
103+
> When using this syntax, a random public node will be selected.
66104
67-
Using a specific nodeUrl is the better approach, as such a node will have fewer limitations, the last version of software and will be less crowded.
105+
Using a specific `nodeUrl` is the better approach, as such nodes will have fewer limitations, their software will be more up to date, and they will be less congested.
68106

69-
Some examples of RpcProvider instantiation to connect to RPC node providers:
107+
Some examples of `RpcProvider` instantiation to connect to RPC node providers:
70108

71109
### Mainnet
72110

73111
```typescript
74-
// Infura node rpc 0.5.1 for Mainnet:
112+
// Infura node RPC 0.7.0 for Mainnet:
75113
const providerInfuraMainnet = new RpcProvider({
76114
nodeUrl: 'https://starknet-mainnet.infura.io/v3/' + infuraKey,
115+
specVersion: '0.7',
77116
});
78-
// Blast node rpc 0.7.0 for Mainnet (0.4, 0.5 & 0_6 also available):
117+
// Blast node RPC 0.8.0 for Mainnet (0.6 & 0_7 also available):
79118
const providerBlastMainnet = new RpcProvider({
80-
nodeUrl: 'https://starknet-mainnet.blastapi.io/' + blastKey + '/rpc/v0_7',
119+
nodeUrl: 'https://starknet-mainnet.blastapi.io/' + blastKey + '/rpc/v0_8',
81120
});
82-
// Lava node rpc 0.6.0 for Mainnet:
121+
// Lava node RPC 0.8.0 for Mainnet:
83122
const providerMainnetLava = new RpcProvider({
84123
nodeUrl: 'https://g.w.lavanet.xyz:443/gateway/strk/rpc-http/' + lavaMainnetKey,
85124
});
86-
// Alchemy node rpc 0.6.0 for Mainnet:
125+
// Alchemy node RPC 0.7.0 for Mainnet (0_6 also available):
87126
const providerAlchemyMainnet = new RpcProvider({
88-
nodeUrl: 'https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/v0_6/' + alchemyKey,
127+
nodeUrl: 'https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/v0_7/' + alchemyKey,
128+
specVersion: '0.7',
89129
});
90-
// Public Nethermind node rpc 0.7.0 for Mainnet (0_6 also available):
130+
// Public Nethermind node RPC 0.8.0 for Mainnet (0_6 & 0_7 also available):
91131
const providerMainnetNethermindPublic = new RpcProvider({
92-
nodeUrl: 'https://free-rpc.nethermind.io/mainnet-juno/v0_7',
132+
nodeUrl: 'https://free-rpc.nethermind.io/mainnet-juno/v0_8',
93133
});
94-
// Public Blast node rpc 0.7.0 for Mainnet (0.4, 0.5 & 0_6 also available) :
134+
// Public Blast node RPC 0.8.0 for Mainnet (0.6 & 0_7 also available):
95135
const providerBlastMainnet = new RpcProvider({
96-
nodeUrl: 'https://starknet-mainnet.public.blastapi.io/rpc/v0_7',
136+
nodeUrl: 'https://starknet-mainnet.public.blastapi.io/rpc/v0_8',
97137
});
98-
// Public Lava node rpc 0.6.0 for Mainnet:
138+
// Public Lava node RPC 0.8.0 for Mainnet (0.6 & 0_7 also available):
99139
const providerLavaMainnet = new RpcProvider({
100-
nodeUrl: 'https://json-rpc.starknet-mainnet.public.lavanet.xyz',
140+
nodeUrl: 'https://rpc.starknet.lava.build/rpc/v0_8',
101141
});
102142
```
103143

104144
> Take care to safely manage your API key. It's a confidential item!
105145
146+
:::tip
147+
If the RPC version of the node is 0.7, the `specVersion` parameter must be set:
148+
149+
```typescript
150+
const myProvider = new RpcProvider({
151+
nodeUrl: `${myNodeUrl}`,
152+
specVersion: '0.7',
153+
});
154+
```
155+
156+
If you are not sure about the RPC version (0.7 or 0.8), use:
157+
158+
```typescript
159+
const myProvider = await RpcProvider.create({ nodeUrl: `${myNodeUrl}` });
160+
```
161+
162+
Note that this approach is slower, it performs a request to the node.
163+
:::
164+
106165
### Goerli Testnet
107166

108167
:::info
109-
The Goerli testnet is no more in service.
168+
The Goerli Testnet is no longer in service.
110169
:::
111170

112171
### Sepolia Testnet
113172

114173
```typescript
115-
// Infura node rpc 0.5.1 for Sepolia Testnet :
174+
// Infura node RPC 0.7.0 for Sepolia Testnet :
116175
const providerInfuraSepoliaTestnet = new RpcProvider({
117176
nodeUrl: 'https://starknet-sepolia.infura.io/v3/' + infuraKey,
177+
specVersion: '0.7',
118178
});
119-
// Public Nethermind node rpc 0.7.0 for Sepolia Testnet (0_6 also available) :
179+
// Public Nethermind node RPC 0.8.0 for Sepolia Testnet (0_6 & 0_7 also available) :
120180
const providerSepoliaTestnetNethermindPublic = new RpcProvider({
121-
nodeUrl: 'https://free-rpc.nethermind.io/sepolia-juno/v0_7',
181+
nodeUrl: 'https://free-rpc.nethermind.io/sepolia-juno/v0_8',
182+
});
183+
// Public Blast node RPC 0.8.0 for Sepolia Testnet (0_6 & 0_7 also available) :
184+
const providerSepoliaTestnetBlastPublic = new RpcProvider({
185+
nodeUrl: 'https://starknet-sepolia.public.blastapi.io/rpc/v0_8',
122186
});
123-
// Public Blast node rpc 0.7.0 for Sepolia Testnet (0_6 also available) :
187+
// Public Lava node RPC 0.8.0 for Sepolia Testnet (0_6 & 0_7 also available) :
124188
const providerSepoliaTestnetBlastPublic = new RpcProvider({
125-
nodeUrl: 'https://starknet-sepolia.public.blastapi.io/rpc/v0_7',
189+
nodeUrl: 'https://rpc.starknet-testnet.lava.build/rpc/v0_8',
126190
});
127191
```
128192

@@ -133,35 +197,35 @@ const providerSepoliaTestnetBlastPublic = new RpcProvider({
133197
For a local [Pathfinder](https://github.com/eqlabs/pathfinder) node:
134198

135199
```typescript
136-
const provider = new RpcProvider({ nodeUrl: '127.0.0.1:9545/rpc/v0_7' });
200+
const provider = new RpcProvider({ nodeUrl: '127.0.0.1:9545/rpc/v0_8' });
137201
```
138202

139203
Your node can be located in your local network (example: Pathfinder node running on a computer in your network, launched with this additional option: `--http-rpc 0.0.0.0:9545`).
140204
You can connect with:
141205

142206
```typescript
143-
const provider = new RpcProvider({ nodeUrl: '192.168.1.99:9545/rpc/v0_7' });
207+
const provider = new RpcProvider({ nodeUrl: '192.168.1.99:9545/rpc/v0_8' });
144208
```
145209

146210
### Juno
147211

148212
For a local [Juno](https://github.com/NethermindEth/juno) node initialize the provider with:
149213

150214
```typescript
151-
const provider = new RpcProvider({ nodeUrl: 'http://127.0.0.1:6060/v0_7' });
215+
const provider = new RpcProvider({ nodeUrl: 'http://127.0.0.1:6060/v0_8' });
152216
```
153217

154218
> If Juno is running on a separate computer in your local network, don't forget to add the option `--http-host 0.0.0.0` when launching Juno.
155219
156220
## Devnet
157221

158-
Example of a connection to a local development node (rpc 0.7.0), with Starknet-devnet-rs v0.0.6:
222+
Example of a connection to a local development node (RPC 0.8.0), with starknet-devnet v0.3.0:
159223

160224
```typescript
161225
const provider = new RpcProvider({ nodeUrl: 'http://127.0.0.1:5050/rpc' });
162226
```
163227

164-
> If you have customized host and port during starknet-devnet initialization, adapt in accordance your script.
228+
> If you customized the host or port during starknet-devnet initialization, adapt the script accordingly.
165229
166230
## Batch JSON-RPC
167231

0 commit comments

Comments
 (0)