Skip to content

Commit 7fc1a3c

Browse files
authored
v0.14.0 transactions reference #1636
1 parent 064ee41 commit 7fc1a3c

File tree

1 file changed

+132
-124
lines changed

1 file changed

+132
-124
lines changed

components/Starknet/modules/resources/pages/transactions-reference.adoc

Lines changed: 132 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
To review how transaction appear in the Starknet API, see https://github.com/starkware-libs/starknet-specs/blob/b5c43955b1868b8e19af6d1736178e02ec84e678/api/starknet_api_openrpc.json[starknet_api_openrpc.json^].
66
====
77

8-
== `INVOKE` transaction
8+
== `INVOKE` v3
99

10-
=== v3 transaction fields
10+
=== Transaction fields
1111

1212
include::partial$snippet_transaction_fields_master_table.adoc[]
1313

14-
=== v3 hash calculation
14+
=== Hash calculation
1515

1616
The `INVOKE` v3 transaction hash is calculated as a Poseidon hash over the given transaction elements, specifically:
1717

@@ -36,7 +36,116 @@ Where:
3636
* `invoke` is a constant prefix string, encoded in ASCII.
3737
include::partial$snippet_transaction_params.adoc[]
3838

39-
=== v1 transaction fields
39+
== `DECLARE` v3
40+
41+
:declare:
42+
43+
The `DECLARE` transaction introduces new contract classes into the state of Starknet, enabling other contracts to deploy instances of those classes or use them in a library call. For more information, see xref:architecture-and-concepts:smart-contracts/contract-classes.adoc[contract classes].
44+
45+
=== Transaction fields
46+
47+
include::partial$snippet_transaction_fields_master_table.adoc[]
48+
49+
=== Hash calculation
50+
51+
The hash of a v3 `DECLARE` transaction is computed as follows:
52+
53+
[,subs="quotes"]
54+
----
55+
declare_v3_tx_hash = _h_(
56+
"declare",
57+
version,
58+
sender_address,
59+
_h_(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds),
60+
_h_(paymaster_data),
61+
chain_id,
62+
nonce,
63+
data_availability_modes,
64+
_h_(account_deployment_data),
65+
class_hash,
66+
compiled_class_hash
67+
)
68+
----
69+
70+
Where:
71+
72+
* `declare` is a constant prefix string, encoded in ASCII.
73+
include::partial$snippet_transaction_params.adoc[]
74+
* `class_hash` is the hash of the contract class. See xref:architecture-and-concepts:smart-contracts/class-hash.adoc#computing_the_cairo_1_class_hash[Class Hash] for details about how the hash is computed
75+
* `compiled_class_hash` is the hash of the compiled class
76+
generated by the Sierra->Casm compiler that is used in Starknet
77+
78+
== `DEPLOY_ACCOUNT` v3
79+
80+
:deploy_account:
81+
82+
Since StarkNet v0.10.1 the `DEPLOY_ACCOUNT` transaction replaces the `DEPLOY` transaction for deploying account contracts.
83+
84+
To use it, you should first pre-fund your new account address so that you can pay the transaction fee. You can then send the `DEPLOY_ACCOUNT` transaction.
85+
86+
For more information, see xref:architecture-and-concepts:accounts/deploying-new-accounts.adoc[].
87+
88+
=== Transaction fields
89+
90+
include::partial$snippet_transaction_fields_master_table.adoc[]
91+
92+
=== Hash calculation
93+
94+
The hash of a `DEPLOY_ACCOUNT` transaction is computed as follows:
95+
96+
[,subs="quotes"]
97+
----
98+
deploy_account_v3_tx_hash = _h_(
99+
"deploy_account",
100+
version,
101+
contract_address,
102+
_h_(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds),
103+
_h_(paymaster_data),
104+
chain_id,
105+
nonce,
106+
data_availability_modes,
107+
_h_(constructor_calldata),
108+
class_hash,
109+
contract_address_salt
110+
)
111+
----
112+
113+
Where:
114+
115+
* `deploy_account` is a constant prefix string, encoded in ASCII.
116+
include::partial$snippet_transaction_params.adoc[]
117+
* `class_hash` is the hash of the xref:architecture-and-concepts:smart-contracts/contract-classes.adoc[contract class]. See xref:architecture-and-concepts:smart-contracts/class-hash.adoc[Class Hash] for details about how the hash is computed.
118+
* `contract_address` is the address of the newly deployed account. For information on how this address is calculated, see xref:architecture-and-concepts:smart-contracts/contract-address.adoc[Contract address].
119+
120+
== Additional information
121+
122+
=== Signature
123+
124+
While Starknet does not have a specific signature scheme built into the protocol, the Cairo language, in which smart contracts are written, does have an efficient implementation for ECDSA signature with respect to a STARK-friendly curve. For more information, see xref:architecture-and-concepts:cryptography.adoc[].
125+
126+
The generator used in the ECDSA algorithm is stem:[G=\left(g_x, g_y\right)] where:
127+
128+
stem:[g_x=874739451078007766457464989774322083649278607533249481151382481072868806602] stem:[g_y=152666792071518830868575557812948353041420400780739481342941381225525861407]
129+
130+
=== Chain ID
131+
132+
Chain IDs are given as numbers, representing the ASCII encoding of specific constant strings, as illustrated by the following Python snippet:
133+
134+
[source,python]
135+
----
136+
chain_id = int.from_bytes(value, byteorder="big", signed=False)
137+
----
138+
139+
The following constants are currently used. They correspond to the chain IDs that Starknet currently supports:
140+
141+
* `SN_MAIN` for Starknet's main network.
142+
* `SN_SEPOLIA` for Starknet's public testnet on Sepolia.
143+
144+
== Legacy information
145+
146+
=== `INVOKE` v1
147+
148+
==== Transaction fields
40149

41150
[%autowidth.stretch]
42151
|===
@@ -51,7 +160,7 @@ include::partial$snippet_transaction_params.adoc[]
51160
When the fields that comprise a transaction change, either with the addition of a new field or the removal of an existing field, then the transaction version increases.
52161
|===
53162

54-
=== v1 hash calculation
163+
==== Hash calculation
55164

56165
The `INVOKE` v1 transaction hash is calculated as a hash over the given transaction elements,
57166
specifically:
@@ -78,7 +187,9 @@ Where:
78187
* `_h_` is the xref:architecture:cryptography.adoc#pedersen_hash[Pedersen] hash
79188

80189

81-
=== v0 hash calculation
190+
=== `INVOKE` v0
191+
192+
==== Hash calculation
82193

83194
The hash of a v0 `INVOKE` transaction is computed as follows:
84195

@@ -103,55 +214,9 @@ Where:
103214

104215
:!invoke:
105216

106-
== `DECLARE` transaction
217+
=== `DECLARE` v2
107218

108-
:declare:
109-
110-
The `DECLARE` transaction introduces new contract classes into the state of Starknet, enabling other contracts to deploy instances of those classes or use them in a library call. For more information, see https://book.cairo-lang.org/ch100-01-contracts-classes-and-instances.html[the Cairo Book].
111-
112-
// [IMPORTANT]
113-
// ====
114-
// You can only declare Cairo classes with v2 and v3 of the `DECLARE` transaction type.
115-
//
116-
// v1, which declares Cairo 0 classes, is deprecated and will be removed in a future Starknet version.
117-
//
118-
// v0 is no longer supported.
119-
// ====
120-
121-
=== v3 transaction fields
122-
123-
include::partial$snippet_transaction_fields_master_table.adoc[]
124-
125-
=== v3 hash calculation
126-
127-
The hash of a v3 `DECLARE` transaction is computed as follows:
128-
129-
[,subs="quotes"]
130-
----
131-
declare_v3_tx_hash = _h_(
132-
"declare",
133-
version,
134-
sender_address,
135-
_h_(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds),
136-
_h_(paymaster_data),
137-
chain_id,
138-
nonce,
139-
data_availability_modes,
140-
_h_(account_deployment_data),
141-
class_hash,
142-
compiled_class_hash
143-
)
144-
----
145-
146-
Where:
147-
148-
* `declare` is a constant prefix string, encoded in ASCII.
149-
include::partial$snippet_transaction_params.adoc[]
150-
* `class_hash` is the hash of the contract class. See https://book.cairo-lang.org/ch100-01-contracts-classes-and-instances.html[the Cairo Book^] for details about how the hash is computed
151-
* `compiled_class_hash` is the hash of the compiled class
152-
generated by the Sierra->Casm compiler that is used in Starknet
153-
154-
=== v2 transaction fields
219+
==== Transaction fields
155220

156221
[%autowidth.stretch]
157222
|===
@@ -168,7 +233,7 @@ generated by the Sierra->Casm compiler that is used in Starknet
168233
When the fields that comprise a transaction change, either with the addition of a new field or the removal of an existing field, then the transaction version increases.
169234
|===
170235

171-
=== v2 hash calculation
236+
==== Hash calculation
172237

173238
The hash of a v2 `DECLARE` transaction is computed as follows:
174239

@@ -193,7 +258,9 @@ Where:
193258
* `class_hash` is the hash of the contract class. See https://book.cairo-lang.org/ch100-01-contracts-classes-and-instances.html[the Cairo Book^] for details about how the hash is computed
194259
* `compiled_class_hash` is the hash of the compiled class generated by the Sierra->Casm compiler that is used in Starknet
195260

196-
=== v1 transaction fields
261+
=== `DECLARE` v1
262+
263+
==== Transaction fields
197264

198265
[NOTE]
199266
====
@@ -213,8 +280,7 @@ The `DECLARE` v1 transaction was used to declare Cairo 0 classes.
213280
When the fields that comprise a transaction change, either with the addition of a new field or the removal of an existing field, then the transaction version increases.
214281
|===
215282

216-
217-
=== v1 hash calculation
283+
==== Hash calculation
218284

219285
The hash of a v1 `DECLARE` transaction is computed as follows:
220286

@@ -242,7 +308,9 @@ computed.
242308
* `_h_` is the xref:architecture:cryptography.adoc#pedersen_hash[Pedersen] hash
243309

244310

245-
=== v0 hash calculation
311+
=== `DECLARE` v0
312+
313+
==== Hash calculation
246314

247315
[NOTE]
248316
====
@@ -275,49 +343,9 @@ Where:
275343

276344
:!declare:
277345

278-
== `DEPLOY_ACCOUNT` transaction
279-
280-
:deploy_account:
281-
282-
Since StarkNet v0.10.1 the `DEPLOY_ACCOUNT` transaction replaces the `DEPLOY` transaction for deploying account contracts.
346+
=== `DEPLOY_ACCOUNT` v1
283347

284-
To use it, you should first pre-fund your new account address so that you can pay the transaction fee. You can then send the `DEPLOY_ACCOUNT` transaction.
285-
286-
For more information, see xref:architecture:accounts#deploying_new_accounts.adoc[Deploying new accounts].
287-
288-
=== v3 transaction fields
289-
290-
include::partial$snippet_transaction_fields_master_table.adoc[]
291-
292-
=== v3 hash calculation
293-
294-
The hash of a `DEPLOY_ACCOUNT` transaction is computed as follows:
295-
296-
[,subs="quotes"]
297-
----
298-
deploy_account_v3_tx_hash = _h_(
299-
"deploy_account",
300-
version,
301-
contract_address,
302-
_h_(tip, l1_gas_bounds, l2_gas_bounds, l1_data_gas_bounds),
303-
_h_(paymaster_data),
304-
chain_id,
305-
nonce,
306-
data_availability_modes,
307-
_h_(constructor_calldata),
308-
class_hash,
309-
contract_address_salt
310-
)
311-
----
312-
313-
Where:
314-
315-
* `deploy_account` is a constant prefix string, encoded in ASCII.
316-
include::partial$snippet_transaction_params.adoc[]
317-
* `class_hash` is the hash of the contract class. See https://book.cairo-lang.org/ch100-01-contracts-classes-and-instances.html[the Cairo Book^] for details about how the hash is computed.
318-
* `contract_address` is the address of the newly deployed account. For information on how this address is calculated, see https://book.cairo-lang.org/ch100-01-contracts-classes-and-instances.html[the Cairo Book^].
319-
320-
=== v1 transaction fields
348+
==== Transaction fields
321349

322350
[%autowidth]
323351
|===
@@ -332,7 +360,7 @@ include::partial$snippet_transaction_params.adoc[]
332360
| `version` | `FieldElement` | The transaction's version. The value is 1. +
333361
|===
334362

335-
=== v1 hash calculation
363+
==== Hash calculation
336364

337365
The hash of a `DEPLOY_ACCOUNT` transaction is computed as follows:
338366

@@ -360,9 +388,9 @@ Where:
360388

361389
:!deploy_account:
362390

363-
== `DEPLOY` transaction
391+
=== `DEPLOY` v0
364392

365-
=== v0 hash calculation
393+
==== Hash calculation
366394

367395
If you need to retrieve the hash of an existing `DEPLOY` transaction, you can use this information to calculate the hash of the transaction.
368396

@@ -389,23 +417,3 @@ Where:
389417
`sn_keccak` is xref:architecture:cryptography.adoc#starknet_keccak[Starknet Keccak].
390418
* `chain_id` is a constant value that specifies the network to which this transaction is sent. For more information, see xref:#chain_id[].
391419
* `contract_address` is calculated as described see https://book.cairo-lang.org/ch100-01-contracts-classes-and-instances.html[the Cairo Book^].
392-
393-
== Additional information
394-
395-
=== Signature
396-
397-
While Starknet does not have a specific signature scheme built into the protocol, the Cairo language, in which smart contracts are written, does have an efficient implementation for ECDSA signature with respect to a STARK-friendly curve. For more information, see xref:architecture:cryptography.adoc[].
398-
399-
=== Chain ID
400-
401-
Chain IDs are given as numbers, representing the ASCII encoding of specific constant strings, as illustrated by the following Python snippet:
402-
403-
[source,python]
404-
----
405-
chain_id = int.from_bytes(value, byteorder="big", signed=False)
406-
----
407-
408-
The following constants are currently used. They correspond to the chain IDs that Starknet currently supports:
409-
410-
* `SN_MAIN` for Starknet's main network.
411-
* `SN_SEPOLIA` for Starknet's public testnet on Sepolia.

0 commit comments

Comments
 (0)