You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Update migration guide
* Update docs
* Add info about added versioned classes
* Apply suggestions from code review
Co-authored-by: Wojciech Szymczyk <wojciech.szymczyk@swmansion.com>
* Improve clarity of Fees section in Using Existing Contract chapter
* Fix hyperlinks to API documentation
* Add transaction fee section
* Apply suggestions from code review
Co-authored-by: Wojciech Szymczyk <wojciech.szymczyk@swmansion.com>
* Improve auto estimation warning
* Update auto estimation warning message
* Fix failing test
* Apply suggestions from code review
Co-authored-by: Maksim Zdobnikau <43750648+DelevoXDG@users.noreply.github.com>
* Address review feedback
* Update warning under `Fees` section
Co-authored-by: Maksim Zdobnikau <43750648+DelevoXDG@users.noreply.github.com>
* Add info about auto fee estimation under Fees
---------
Co-authored-by: Wojciech Szymczyk <wojciech.szymczyk@swmansion.com>
Co-authored-by: Maksim Zdobnikau <43750648+DelevoXDG@users.noreply.github.com>
If you choose to install `starknet-devnet-rs <https://github.com/0xSpaceShard/starknet-devnet-rs>`_ using a different method, please make sure to add the executable ``starknet-devnet`` to your ``PATH`` environment variable.
Copy file name to clipboardExpand all lines: docs/guide/account_and_client.rst
+28-5Lines changed: 28 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,16 +4,41 @@ Account and Client
4
4
Executing transactions
5
5
----------------------
6
6
7
-
To execute transactions on Starknet, use :meth:`~starknet_py.net.account.account.Account.execute` method from :ref:`Account` interface.
7
+
To execute transactions on Starknet, use :meth:`~starknet_py.net.account.account.Account.execute_v1` or :meth:`~starknet_py.net.account.account.Account.execute_v3` methods from :ref:`Account` interface.
8
+
These methods will send :class:`~starknet_py.net.models.InvokeV1` and :class:`~starknet_py.net.models.InvokeV3` transactions respectively. To read about differences between transaction versions please visit `transaction types <https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/transactions>`_ from the Starknet docs.
All methods within the :ref:`Account` that involve on-chain modifications require either specifying a maximum transaction fee or using auto estimation.
18
+
In the case of V1 and V2 transactions, the transaction fee, denoted in Wei, is configured by the ``max_fee`` parameter.
19
+
For V3 transactions, however, the fee is expressed in Fri and is determined by the ``l1_resource_bounds`` parameter.
20
+
To enable auto estimation, set the ``auto_estimate`` parameter to ``True``.
There is a possibility to execute an Invoke transaction containing multiple calls.
27
-
Simply pass a list of calls to :meth:`~starknet_py.net.account.account.Account.execute` method.
52
+
Simply pass a list of calls to :meth:`~starknet_py.net.account.account.Account.execute_v1` or :meth:`~starknet_py.net.account.account.Account.execute_v3` methods.
Copy file name to clipboardExpand all lines: docs/guide/deploying_contracts.rst
+5-14Lines changed: 5 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,27 +4,21 @@ Deploying contracts
4
4
Declaring contracts
5
5
-------------------
6
6
7
-
Since Cairo 0.10.0 Declare transactions can be signed and in the future, declaring without signing the transaction
8
-
(and without paying the fee) will be impossible. That is why :ref:`Account` has
9
-
:meth:`sign_declare_transaction()` method.
7
+
A declare transaction can be issued in version 1, 2 or 3. Contracts written in Cairo 0 should be declared using version 1, while those written in Cairo 1 or higher should be declared with versions 2 or 3.
8
+
To sign a declare transaction, you should utilize the :meth:`~starknet_py.net.account.account.Account.sign_declare_v1`, :meth:`~starknet_py.net.account.account.Account.sign_declare_v2` or :meth:`~starknet_py.net.account.account.Account.sign_declare_v3` method, respectively.
@@ -34,7 +28,7 @@ through Universal Deployment Contract (UDC) to deploy a contract.
34
28
Simple deploy
35
29
-------------
36
30
37
-
If you already know the class hash of an already declared contract you want to deploy just use the :meth:`Contract.deploy_contract`.
31
+
If you know the class hash of an already declared contract you want to deploy just use the :meth:`~starknet_py.contract.Contract.deploy_contract_v1` or :meth:`~starknet_py.contract.Contract.deploy_contract_v3`.
38
32
It will deploy the contract using funds from your account. Deployment is handled by UDC.
|Starknet 0.11 introduced the ability to declare contracts written in Cairo1!
79
-
80
-
To declare a new contract, Declare v2 or Declare v3 transaction has to be sent.
71
+
To declare a contract in Cairo version 1 or higher, Declare V2 or Declare V3 transaction has to be sent.
81
72
You can see the structure of these transactions `here <https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/transactions/#declare-transaction>`_.
82
73
83
74
The main differences in the structure of the transaction from its previous version are:
When max_fee is specified when preparing a call, you can invoke it without
49
-
``max_fee``.
50
+
The ``max_fee`` argument can be also defined in :meth:`~ContractFunction.prepare_invoke_v1`. Subsequently, the :meth:`~PreparedFunctionInvokeV1.invoke` method on a prepared call can be used either with ``max_fee`` omitted or with its value overridden.
51
+
The same behavior applies to :meth:`~ContractFunction.prepare_invoke_v3` and ``l1_resource_bounds``.
If ``max_fee`` is not specified at any step it will default to ``None``,
59
-
and will raise an exception when invoking a transaction.
62
+
For V1 transactions if ``max_fee`` is not specified at any step it will default to ``None``,
63
+
and will raise an exception when invoking a transaction, unless `auto_estimate` is specified and is set to `True`. The same applies to ``l1_resource_bounds`` and V3 transactions.
60
64
61
-
Please note you will need to have enough Wei in your Starknet account otherwise
65
+
Please note you will need to have enough Wei (for V1 transaction) or Fri (for V3 transaction) in your Starknet account otherwise
62
66
transaction will be rejected.
63
67
64
68
Fee estimation
65
69
--------------
66
70
67
71
You can estimate required amount of fee that will need to be paid for transaction
68
-
using :meth:`PreparedFunctionCall.estimate_fee() <starknet_py.contract.PreparedFunctionCall.estimate_fee>`
72
+
using :meth:`PreparedFunctionInvoke.estimate_fee() <starknet_py.contract.PreparedFunctionInvoke.estimate_fee>`
For testing purposes it is possible to enable automatic fee estimation when making
79
-
a transaction. starknet.py will then use ``estimate_fee()`` internally and use value
80
-
returned by it multiplied by ``1.5`` as a ``max_fee``.
81
-
82
-
.. warning::
83
-
84
-
Do not use automatic fee estimation in production code! It may lead to
85
-
very high fees paid as the amount returned by ``estimate_fee()`` may be arbitrarily large.
83
+
For testing purposes it is possible to enable automatic fee estimation when making a transaction. Starknet.py will then call :meth:`~starknet_py.net.full_node_client.FullNodeClient.estimate_fee`
84
+
internally and use the returned value, multiplied by ``1.5`` to mitigate fluctuations in price, as a ``max_fee`` for V1 transactions. For V3 transactions,
85
+
``max_amount`` will be multiplied by ``1.1``, and ``max_price_per_unit`` by ``1.5``.
It is strongly discouraged to use automatic fee estimation in production code as it may lead to unexpectedly high fee.
91
94
92
95
.. note::
93
-
It is possible to configure the value by which the estimated fee is multiplied,
94
-
by changing ``ESTIMATED_FEE_MULTIPLIER`` in :class:`~starknet_py.net.account.account.Account`.
96
+
For V1 transactions it is possible to configure the value by which the estimated fee is multiplied,
97
+
by changing ``ESTIMATED_FEE_MULTIPLIER`` in :class:`~starknet_py.net.account.account.Account`. The same applies to
98
+
``ESTIMATED_AMOUNT_MULTIPLIER`` and ``ESTIMATED_UNIT_PRICE_MULTIPLIER`` for V3 transactions.
95
99
96
100
Account and Client interoperability
97
101
-----------------------------------
98
102
99
103
.. currentmodule:: starknet_py.contract
100
104
101
-
:ref:`Contract` methods have been designed to be
102
-
compatible with :ref:`Account` and :ref:`Client`.
105
+
:ref:`Contract` methods have been designed to be compatible with :ref:`Account` and :ref:`Client`.
103
106
104
-
:ref:`PreparedFunctionCall` returned by :meth:`ContractFunction.prepare` can be used in Account methods to create Invoke transactions.
107
+
:ref:`PreparedFunctionInvokeV1` and :ref:`PreparedFunctionInvokeV3` returned by :meth:`ContractFunction.prepare_invoke_v1` and :meth:`ContractFunction.prepare_invoke_v3` respectively can be used in Account methods to create Invoke transactions.
It can also be used in :meth:`Client.call_contract() <starknet_py.net.client.Client.call_contract>`
113
+
114
+
Similarly, :ref:`PreparedFunctionCall` returned by :meth:`ContractFunction.prepare_call` can be used in :meth:`Client.call_contract() <starknet_py.net.client.Client.call_contract>`
- :meth:`~Account.sign_declare_v3`, :meth:`~Account.sign_deploy_account_v3` and :meth:`~Account.sign_invoke_v3` have been added.
21
-
- :meth:`sign_declare_transaction`, :meth:`sign_declare_v2_transaction`, :meth:`sign_deploy_account_transaction` and :meth:`sign_invoke_transaction` have been renamed to :meth:`~Account.sign_declare_v1`, :meth:`~Account.sign_declare_v2`, :meth:`~Account.sign_deploy_account_v1` and :meth:`~Account.sign_invoke_v1` respectively.
19
+
- :meth:`~Account.execute` has been renamed to :meth:`~Account.execute_v1`
20
+
- :meth:`~Account.execute_v3` has been added
21
+
- :meth:`~Account.deploy_account` has been renamed to :meth:`~Account.deploy_account_v1`
22
+
- :meth:`~Account.deploy_account_v3` has been added
23
+
- :meth:`~Account.sign_declare_v3`, :meth:`~Account.sign_deploy_account_v3` and :meth:`~Account.sign_invoke_v3` have been added
24
+
- :meth:`sign_declare_transaction`, :meth:`sign_declare_v2_transaction`, :meth:`sign_deploy_account_transaction` and :meth:`sign_invoke_transaction` have been renamed to :meth:`~Account.sign_declare_v1`, :meth:`~Account.sign_declare_v2`, :meth:`~Account.sign_deploy_account_v1` and :meth:`~Account.sign_invoke_v1` respectively
22
25
23
26
All new functions with ``v3`` in their name operate similarly to their ``v1`` and ``v2`` counterparts.
24
-
Unlike their ``v1`` counterparts, ``v3`` transaction fees are paid in Fri (10^-18 STRK). Therefore, ``max_fee`` parameter, which is typically set in Wei, is not applicable for ``v3`` functions. Instead, ``l1_resource_bounds`` parameter is utilized to limit the Fri amount used.
27
+
Unlike their ``v1`` counterparts however, ``v3`` transaction fees are paid in Fri (10^-18 STRK). Therefore, ``max_fee`` parameter, which is typically set in Wei, is not applicable for ``v3`` functions. Instead, ``l1_resource_bounds`` parameter is utilized to limit the Fri amount used.
28
+
The same applies to the new ``v3`` methods in the :class:`~starknet_py.contract.Contract` class.
25
29
26
30
Changes in the :class:`~starknet_py.net.full_node_client.FullNodeClient`:
- :meth:`~FullNodeClient.estimate_fee` has a new parameter ``skip_validate``.
34
+
- :meth:`~FullNodeClient.estimate_fee` has a new parameter ``skip_validate``
31
35
- :meth:`~FullNodeClient.declare` accepts ``transaction`` argument of the type :class:`~starknet_py.net.models.transaction.DeclareV3`
32
36
- :meth:`~FullNodeClient.send_transaction` accepts ``transaction`` argument of the type :class:`~starknet_py.net.models.transaction.InvokeV3`
33
37
- :meth:`~FullNodeClient.deploy_account` accepts ``transaction`` argument of the type :class:`~starknet_py.net.models.transaction.DeployAccountV3`
34
38
35
-
.. warning::
36
-
:class:`~starknet_py.contract.Contract` class does not support V3 transactions in the pre-release.
39
+
Changes in the :class:`~starknet_py.contract.Contract`:
37
40
41
+
.. currentmodule:: starknet_py.contract
42
+
43
+
- :meth:`Contract.declare` has been replaced by :meth:`Contract.declare_v1`, :meth:`Contract.declare_v2` and :meth:`Contract.declare_v3`
44
+
- :meth:`Contract.deploy_contract` has been replaced by :meth:`Contract.deploy_contract_v1` and :meth:`Contract.deploy_contract_v3`. Optional parameters ``unique`` and ``salt`` have been added to both methods
45
+
- :meth:`ContractFunction.prepare` has been replaced by :meth:`ContractFunction.prepare_invoke_v1`, :meth:`ContractFunction.prepare_invoke_v3` and :meth:`ContractFunction.prepare_call`
46
+
- :meth:`ContractFunction.invoke` has been replaced by :meth:`ContractFunction.invoke_v1` and :meth:`ContractFunction.invoke_v3`
47
+
- :meth:`PreparedFunctionCall` has now only methods :meth:`PreparedFunctionCall.call` and :meth:`PreparedFunctionCall.call_raw`
48
+
- :meth:`PreparedFunctionInvokeV1` and :meth:`PreparedFunctionInvokeV3` with methods ``invoke`` and ``estimate_fee`` have been added
49
+
- :meth:`DeclareResult.deploy` has been replaced by :meth:`DeclareResult.deploy_v1` and :meth:`DeclareResult.deploy_v3`
38
50
39
51
0.19.0 Targeted versions
40
52
------------------------
@@ -44,6 +56,7 @@ Changes in the :class:`~starknet_py.net.full_node_client.FullNodeClient`:
44
56
45
57
0.19.0 Breaking changes
46
58
-----------------------
59
+
Other breaking changes not mentioned above.
47
60
48
61
.. currentmodule:: starknet_py.net.client_models
49
62
@@ -60,6 +73,9 @@ Changes in the :class:`~starknet_py.net.full_node_client.FullNodeClient`:
60
73
11. :class:`ResourceLimits` class has been renamed to :class:`ResourceBounds`.
61
74
12. :class:`~starknet_py.net.account.base_account.BaseAccount` and :class:`~starknet_py.net.account.account.Account` property ``supported_transaction_version`` has been removed.
62
75
13. ``wait_for_accept`` parameter in :meth:`Client.wait_for_tx` and :meth:`SentTransaction.wait_for_acceptance` has been removed.
76
+
14. :class:`InvokeTransaction` has been replaced by :class:`InvokeTransactionV0` and :class:`InvokeTransactionV1`.
77
+
15. :class:`DeclareTransaction` has been replaced by :class:`DeclareTransactionV0`, :class:`DeclareTransactionV1` and :class:`DeclareTransactionV3`.
78
+
16. :class:`DeployAccountTransaction` has been replaced by :class:`DeployAccountTransactionV1`.
0 commit comments