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
[Contract](https://starknetpy.readthedocs.io/en/latest/api/contract.html#starknet_py.contract.Contract) makes interacting with contracts deployed on Starknet much easier:
160
160
```python
161
161
from starknet_py.contract import Contract
162
+
from starknet_py.net.client_models import ResourceBounds
Copy file name to clipboardExpand all lines: docs/guide/account_and_client.rst
+6-10Lines changed: 6 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,7 @@ 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_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.
7
+
To execute transactions on Starknet, use :meth:`~starknet_py.net.account.account.Account.execute_v3` method from :ref:`Account` interface, which will send :class:`~starknet_py.net.models.InvokeV3` transaction.
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.
17
+
For V3 transaction, the fee is expressed in Fri and is determined by the ``l1_resource_bounds`` parameter.
20
18
To enable auto estimation, set the ``auto_estimate`` parameter to ``True``.
It is strongly discouraged to use automatic fee estimation in production code as it may lead to an unexpectedly high fee.
29
27
30
-
The returned estimated fee is multiplied by ``1.5`` for V1 and V2 transactions to mitigate fluctuations in price.
31
-
For V3 transactions, ``max_amount`` and ``max_price_per_unit`` are scaled by ``1.5`` and ``1.5`` respectively.
28
+
The returned estimated fee (``max_amount`` and ``max_price_per_unit``) is multiplied by ``1.5`` to mitigate fluctuations in price.
32
29
33
30
.. note::
34
31
It is possible to configure the value by which the estimated fee is multiplied,
35
-
by changing ``ESTIMATED_FEE_MULTIPLIER`` for V1 and V2 transactions in :class:`~starknet_py.net.account.account.Account`.
36
-
The same applies to ``ESTIMATED_AMOUNT_MULTIPLIER`` and ``ESTIMATED_UNIT_PRICE_MULTIPLIER`` for V3 transactions.
32
+
by changing ``ESTIMATED_AMOUNT_MULTIPLIER`` and ``ESTIMATED_UNIT_PRICE_MULTIPLIER`` in :class:`~starknet_py.net.account.account.Account`.
37
33
38
34
The fee for a specific transaction or list of transactions can be also estimated using the :meth:`~starknet_py.net.account.account.Account.estimate_fee` of the :ref:`Account` class.
39
35
@@ -61,7 +57,7 @@ Multicall
61
57
---------
62
58
63
59
There is a possibility to execute an Invoke transaction containing multiple calls.
64
-
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.
60
+
Simply pass a list of calls to :meth:`~starknet_py.net.account.account.Account.execute_v3` method.
Copy file name to clipboardExpand all lines: docs/guide/deploying_contracts.rst
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,8 @@ Deploying contracts
4
4
Declaring contracts
5
5
-------------------
6
6
7
-
A declare transaction can be issued in version 2 or 3. Contracts written in Cairo 0 cannot be declared 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_v2` or :meth:`~starknet_py.net.account.account.Account.sign_declare_v3` method, respectively.
7
+
Contracts written in Cairo 0 cannot be declared while those written in Cairo 1 or higher should be declared with transaction version 3.
8
+
To sign a declare transaction, you should utilize :meth:`~starknet_py.net.account.account.Account.sign_declare_v3` method.
9
9
10
10
Here's an example how to use it.
11
11
@@ -17,7 +17,7 @@ Here's an example how to use it.
17
17
Simple deploy
18
18
-------------
19
19
20
-
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`.
20
+
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_v3`.
21
21
It will deploy the contract using funds from your account. Deployment is handled by UDC.
To declare a contract in Cairo version 1 or higher, Declare V2 or Declare V3 transaction has to be sent.
60
+
To declare a contract in Cairo version 1 or higher, Declare V3 transaction has to be sent.
61
61
You can see the structure of these transactions `here <https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/transactions/#declare-transaction>`_.
62
62
63
63
The main differences in the structure of the transaction from its previous version are:
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``.
51
+
The ``l1_resource_bounds`` argument can be also defined in :meth:`~ContractFunction.prepare_invoke_v3`. Subsequently, the :meth:`~PreparedFunctionInvokeV3.invoke` method on a prepared call can be used either with ``l1_resource_bounds`` omitted or with its value overridden.
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.
66
+
If ``l1_resource_bounds`` is not specified at any step it will default to ``None``,
67
+
and will raise an exception when invoking a transaction, unless `auto_estimate` is specified and is set to `True`.
64
68
65
-
Please note you will need to have enough Wei (for V1 transaction) or Fri (for V3 transaction) in your Starknet account otherwise
69
+
Please note you will need to have enough Fri in your Starknet account otherwise
66
70
transaction will be rejected.
67
71
68
72
Fee estimation
@@ -73,29 +77,27 @@ using :meth:`PreparedFunctionInvoke.estimate_fee() <starknet_py.contract.Prepare
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``.
88
+
internally and use the returned value. ``max_amount`` and ``max_price_per_unit`` will be multiplied by ``1.5``.
It is strongly discouraged to use automatic fee estimation in production code as it may lead to unexpectedly high fee.
94
97
95
98
.. note::
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.
99
+
It is possible to configure the value by which the estimated fee is multiplied,
100
+
by changing ``ESTIMATED_AMOUNT_MULTIPLIER`` and ``ESTIMATED_UNIT_PRICE_MULTIPLIER``.
99
101
100
102
Account and Client interoperability
101
103
-----------------------------------
@@ -104,7 +106,7 @@ Account and Client interoperability
104
106
105
107
:ref:`Contract` methods have been designed to be compatible with :ref:`Account` and :ref:`Client`.
106
108
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.
109
+
:ref:`PreparedFunctionInvokeV3` returned by :meth:`ContractFunction.prepare_invoke_v3` can be used in Account methods to create invoke transaction.
0 commit comments