Migration guide#

0.24.3 Migration guide#

0.24.3 Minor changes#

  1. Updated crypto-cpp-py to version 1.4.5.

  1. Ledger support (see LedgerSigner) is now optional. To use it, install the package with poetry install -E ledger.

0.24.2 Migration guide#

0.24.2 Minor changes#

  1. Added KeyPair.generate() method which allows to generate key pair based on cryptographically strong pseudo-random number.

  1. abi parameter is now optional in Contract.deploy_contract_v3().

  2. Added quickfix for u96 parsing for both pre and post 2.8.0 Cairo versions.

0.24.1 Migration guide#

This version contains a quick fix to parsing ABI for Cairo v2 contracts. Due to new release of compiler, u96 is now compiled to BoundedInt in ABI.

0.24.1 Minor changes#

  1. Fixed parsing ABI that contains u96 data type.

  2. Fixed l1_address deserialization in L2toL1MessageSchema.

0.24.0 Migration guide#

  1. DevnetClient has been implemented to interact with additional features of the starknet-devnet-rs

  1. LedgerSigner has been implemented to enable signing with Ledger hardware wallet

0.24.0 Targeted versions#

0.24.0 Breaking changes#

  1. CompiledContract and ContractClass have been renamed to DeprecatedCompiledContract and DeprecatedContractClass.

  2. ContractClassSchema have been renamed to DeprecatedContractClassSchema

0.23.0 Migration guide#

Version 0.23.0 of starknet.py comes with support for SNIP-12!

0.23.0 Targeted versions#

0.23.0 Breaking changes#

  1. StarkNetDomain has been renamed to Domain

  2. TypedData field domain has been changed from dict to Domain

  3. Parameter is now abstract - StandardParameter, EnumParameter and MerkleTreeParameter should be used

0.23.0 Minor changes#

  1. Account.sign_message() now accepts parameter typed_data as both TypedData and TypedDataDict

  2. Account.verify_message() now accepts parameter typed_data as both TypedData and TypedDataDict

  3. from_keystore() has been added

0.22.0 Migration guide#

0.22.0 Targeted versions#

0.22.0 Breaking changes#

  1. Support for Goerli has been removed

  1. StarknetChainId.SEPOLIA_TESTNET has been renamed to StarknetChainId.SEPOLIA

  1. Parameter chain has been removed from the methods Account.deploy_account_v1() and Account.deploy_account_v3()

  2. Parameter chain_id has been removed from the method get_balance()

  3. L1HandlerTransactionTrace field execution_resources is now required

0.21.0 Migration guide#

Version 0.21.0 of starknet.py comes with support for RPC 0.7.0!

0.21.0 Targeted versions#

0.21.0 Breaking changes#

  1. PendingStarknetBlock and PendingStarknetBlockWithTxHashes field parent_block_hash has been renamed to parent_hash

  2. StarknetBlockCommon has been renamed to BlockHeader

  3. StarknetBlock and StarknetBlockWithTxHashes fields parent_block_hash and root have been renamed to parent_hash and new_root respectively

  4. FunctionInvocation field execution_resources has been renamed to computation_resources

0.21.0 Minor changes#

  1. EventsChunk field events is now a list of EmittedEvent instead of Event

  2. ExecutionResources has a new required field data_availability

  3. InvokeTransactionTrace, DeclareTransactionTrace and DeployAccountTransactionTrace have a new required field execution_resources

  4. EstimatedFee has new required fields data_gas_consumed and data_gas_price

  5. StarknetBlock, PendingStarknetBlock, StarknetBlockWithTxHashes, PendingStarknetBlockWithTxHashes have new required fields l1_data_gas_price and l1_da_mode

  6. SierraContractClass has an additional propery parsed_abi

0.20.0 Migration guide#

Version 0.20.0 of starknet.py comes with support for Python 3.12!

0.20.0 Targeted versions#

0.20.0 Breaking changes#

  1. Type of l1_handler in Abi model class for Cairo 2 has been changed from Function to Dict[str, Function]

  2. In Abi module the code related to Cairo 0 has been moved from starknet_py.abi to starknet_py.abi.v0

  3. StarknetEthProxyCheck has been removed from the Proxy checks

0.19.0 Migration guide#

Version 0.19.0 of starknet.py comes with support for RPC 0.6.0!

New classes added to mirror the recent changes in the RPC v0.6.0 specification include: ResourceBoundsMapping, ResourceBounds, PriceUnit, FeePayment, DAMode.

Changes in the Account:

All new functions with v3 in their name operate similarly to their v1 and v2 counterparts. 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. The same applies to the new v3 methods in the Contract class.

Changes in the FullNodeClient:

Changes in the Contract:

0.19.0 Targeted versions#

0.19.0 Breaking changes#

Other breaking changes not mentioned above.

  1. GatewayClient all related classes and fields have been removed.

  2. Client net property has been removed.

  3. Declare, DeployAccount and Invoke have been renamed to DeclareV1, DeployAccountV1 and InvokeV1 respectively.

  4. TransactionReceipt field execution_resources has been changed from dict to ExecutionResources.

  5. TransactionReceipt fields status and rejection_reason have been removed.

  6. TransactionStatus, TransactionExecutionStatus and TransactionFinalityStatus have been changed to have the same structure as in RPC specification.

  7. EstimatedFee has a new required field unit.

  8. EstimatedFee field gas_usage has been renamed to gas_consumed.

  9. FunctionInvocation has a new required field execution_resources.

  10. ResourcePrice field price_in_strk has been renamed to price_in_fri and has now become required.

  11. ResourceLimits class has been renamed to ResourceBounds.

  12. BaseAccount and Account property supported_transaction_version has been removed.

  13. wait_for_accept parameter in Client.wait_for_tx() and SentTransaction.wait_for_acceptance() has been removed.

  14. InvokeTransaction has been replaced by InvokeTransactionV0 and InvokeTransactionV1.

  15. DeclareTransaction has been replaced by DeclareTransactionV0, DeclareTransactionV1 and DeclareTransactionV3.

  16. DeployAccountTransaction has been replaced by DeployAccountTransactionV1.

0.19.0 Minor changes#

  1. L1HandlerTransaction field nonce is now required.

  2. TransactionReceipt fields actual_fee, finality_status, execution_status, execution_resources and type are now required.

0.18.3 Migration guide#

Version 0.18.3 of starknet.py comes with support for RPC 0.5.1!

0.18.3 Targeted versions#

0.18.3 Breaking changes#

  1. Support for TESTNET2 network has been removed.

  1. FullNodeClient.get_pending_transactions() method has been removed. It is advised to use FullNodeClient.get_block() method with block_number="pending" argument.

  1. PendingStarknetBlock field parent_hash is now named parent_block_hash.

  2. FunctionInvocation fields events and messages have been changed from List[Event] and List[L2toL1Message] to List[OrderedEvent] and List[OrderedMessage] respectively.

  3. cairo_version parameter in Account.sign_invoke_transaction() and Account.execute() has been removed.

0.18.3 Minor changes#

  1. StarknetBlock, StarknetBlockWithTxHashes, PendingStarknetBlock and PendingStarknetBlockWithTxHashes now have two additional fields: starknet_version and l1_gas_price.

  2. PendingStarknetBlock and PendingStarknetBlockWithTxHashes fields timestamp, sequencer_address and parent_block_hash are now required, not optional.

  3. TransactionReceipt now has an additional field - message_hash (for L1_HANDLER_TXN_RECEIPT).

  4. Most fields in TransactionTrace classes are now optional.

  5. InvokeTransactionTrace, DeclareTransactionTrace, DeployAccountTransactionTrace and L1HandlerTransactionTrace classes now have an additional field - state_diff.




0.18.2 Migration guide#

Version 0.18.2 of starknet.py comes with support of RPC v0.4.0 Trace API! Additionally, you can now properly use Cairo1 accounts! starknet.py automatically checks if your account is in Cairo1 and sets the calldata encoding accordingly.

0.18.2 Targeted versions#

0.18.2 Breaking changes#

  1. Client.get_block_traces() has been renamed to Client.trace_block_transactions() in order to match RPC specification.

0.18.2 Deprecations#

  1. cairo_version parameter in Account.sign_invoke_transaction() and Account.execute() has been deprecated.

0.18.2 Bugfixes#

  1. Fixed a bug when using proxy_config=True in Contract.from_address() method regarding Entry point EntryPointSelector(...) not found in contract.

0.18.2 Minor changes#

  1. Client.trace_block_transactions() return type has been changed from BlockTransactionTraces to Union[BlockTransactionTraces, List[BlockTransactionTrace]].

  1. include_block parameter in GatewayClient.get_state_update() now works on gateway mainnet.

  1. BaseAccount interface and Account now have an additional async property - cairo_version.

0.18.2 Development-related changes#

  1. In order to be able to run tests, you must set some environmental variables:

    • INTEGRATION_RPC_URL

    • TESTNET_RPC_URL

    • INTEGRATION_ACCOUNT_PRIVATE_KEY

    • INTEGRATION_ACCOUNT_ADDRESS

    • TESTNET_ACCOUNT_PRIVATE_KEY

    • TESTNET_ACCOUNT_ADDRESS

The best way to do that is to create test-variables.env file in starknet_py/tests/e2e/ directory, so they can be loaded by the python-dotenv library. You can find an example file test-variables.env.template in the same directory with the format of how it should look like.




0.18.1 Migration guide#

This version contains a quick fix to GatewayClient.get_state_update() method (mainnet wasn’t updated to 0.12.2 then).

Additionally, accounts in Cairo1 are now supported! You can pass additional argument cairo_version to Account.sign_invoke_transaction() method.

0.18.1 Minor changes#

  1. Parameter include_block in GatewayClient.get_state_update() doesn’t work on mainnet gateway (an error is thrown).

  1. Account.sign_invoke_transaction() now accepts additional parameter cairo_version, which allows specifying which type of calldata encoding should be used.




0.18.0 Migration guide#

This version of starknet.py brings support Starknet 0.12.1, 0.12.2 and RPC v0.4.0!

  1. TransactionReceipt dataclass properties have been changed (more details in RPC specification linked above).

0.18.0 Deprecations#

  1. status field in TransactionReceipt returned by FullNodeClient.get_transaction_receipt() has been deprecated.

0.18.0 Minor changes#

  1. FullNodeClient.get_transaction_receipt() now returns two additional fields: acceptance_status and finality_status.

  1. Added two fields to TransactionReceipt - revert_error (Gateway) and revert_reason (FullNode).

  2. hash property in Transaction is now optional.

  3. Added missing field contract_address_salt to DeployTransaction.

  1. Lowered check_interval parameter default value in Client.wait_for_tx() from 5 seconds to 2.

  1. Added fields to dataclasses that previously were missing (e.g. contract_address_salt in DeployTransaction).

  1. decode_shortstring() now is returned without \x00 in front of the decoded string.

  1. Added two new methods to GatewayClient - GatewayClient.get_public_key() and GatewayClient.get_signature().

  2. GatewayClient.get_state_update() now accepts additional parameter - include_block.

  1. KeyPair and KeyPair.from_private_key() now can accept keys in string representation.

0.18.0 Bugfixes#

  1. Fixed invalid type in BlockStateUpdate from StateDiff to Union[StateDiff, GatewayStateDiff]

  2. Fixed Contract not found error in AbiResolver




0.17.0 Migration guide#

With Starknet 0.12.0, the PENDING transaction status has been removed.

Contract now supports contracts written in Cairo1 in both old and new syntax.

To create an instance of such contract, a keyword parameter cairo_version=1 in the Contract constructor is required.

Note

Please note that while using the interface with Cairo1 contracts, it is possible for problems to occur due to some of the types being not yet implemented in the parser.

In such case, please open an issue at our GitHub or contract us on Starknet Discord server in #🐍 | starknet-py channel.

GatewayClient and Gateway / Feeder Gateway API will become deprecated in the future.

As a result, GatewayClient won’t work and will eventually be removed. Consider migrating to FullNodeClient.

FullNodeClient RPC specification has been updated from v0.3.0-rc1 to v0.3.0.

Also, four methods were added to its interface:

  • FullNodeClient.get_block_number()

  • FullNodeClient.get_block_hash_and_number()

  • FullNodeClient.get_chain_id()

  • FullNodeClient.get_syncing_status()

0.17.0 Breaking changes#

  1. Deprecated function compute_invoke_hash in starknet_py.net.models.transaction has been removed in favor of starknet_py.hash.transaction.compute_invoke_transaction_hash().

  1. Removed deprecated Deployer.create_deployment_call and Deployer.create_deployment_call_raw in favor of Deployer.create_contract_deployment() and Deployer.create_contract_deployment_raw().

  2. Removed PENDING transaction status.

0.17.0 Minor changes#

  1. DeclareResult.deploy(), PreparedFunctionCall.invoke(), PreparedFunctionCall.estimate_fee(), ContractFunction.invoke(), Contract.declare() and Contract.deploy_contract() can now accept custom nonce parameter.

  1. Account.sign_invoke_transaction(), Account.sign_declare_transaction(), Account.sign_declare_v2(), Account.sign_deploy_account_transaction() and Account.execute() can now accept custom nonce parameter.

  2. Account.get_nonce() can now be parametrized with block_number or block_hash.

  3. Account.get_balance() can now be parametrized with block_number or block_hash.

RPC related changes:

  1. L2toL1Message dataclass now has an additional field: from_address.

  2. TransactionReceipt dataclass now has two additional, optional fields: type and contract_address.

  1. FullNodeClient.get_events() keys and address parameters type are now optional.

  2. FullNodeClient.get_events() keys parameter can now also accept integers as felts.

  1. StarknetChainId changed from Enum to IntEnum.

  1. Client.wait_for_tx() has a new parameter retries describing the amount of retries before a time out when querying for a transaction.

0.17.0 Deprecations#

  1. wait_for_accept parameter in Client.wait_for_tx() and SentTransaction.wait_for_acceptance() has been deprecated.

0.17.0 Bugfixes#

  1. Fixed a bug when compute_class_hash() mutated the contract_class argument passed to a function.




0.16.1 Migration guide#

Version 0.16.1 of starknet.py brings the long-awaited Windows support!

Additionally, this release brings support for RPC v0.3.0rc1!

0.16.1 Breaking changes#

  1. FullNodeClient.get_events() keys parameter type is now List[List[str]] instead of List[str].

  2. FullNodeClient.get_state_update() return type has been changed from StateUpdate to Union[BlockStateUpdate, PendingBlockStateUpdate]

  1. StateDiff dataclass properties have been changed (more details in RPC specification linked above).

0.16.1 Minor changes#

  1. Client.estimate_fee() can take a single transaction or a list of transactions to estimate.




0.16.0 Migration guide#

Version 0.16.0 of starknet.py comes with support for Python 3.8, 3.9, 3.10 and 3.11!

The cairo-lang package has been removed as a dependency.

Also, dependencies are now optimized to include only necessary packages.

0.16.0 Bugfixes#

  1. Fixed a bug where Deployer.create_contract_deployment_raw() would use a random salt, when salt = 0 was passed.

0.16.0 Breaking changes#

  1. BaseAccount.verify_message() is no longer async.

  1. Some functions’ implementation has been changed to use crypto-cpp-py package:

  2. Deprecated utils.data_transformer module has been removed. Use Serializers module instead.

  3. Deprecated is_felt_pointer and is_uint256 functions have been removed. Use TypeParser class instead.

  4. Deprecated Compiler module has been removed. Use an external compilation tool (e.g. Starknet CLI) instead.

  5. Deprecated compilation_source and search_paths arguments has been removed from several methods. Use compiled_contract parameter instead.

  1. Deprecated ContractData.identifier_manager has been removed. Use ContractData.parsed_abi() instead.

  1. Removed deprecated typed_data parameter as dict in BaseSigner.sign_message(). Use TypedData dataclass from starknet_py.utils.typed_data.

  2. starknet_py.utils.crypto module has been removed.

  3. Changed name of starknet_py.transaction_exceptions to starknet_py.transaction_errors to match other files.

Potentially breaking changes

Internal code of starknet_py.abi.AbiParser.parse() has changed. It should not affect users but keep in mind that the Contract can have difficulties resolving ABI. If so, please report.




0.15.0 Migration guide#

0.15.0 adds initial support for Starknet 0.11.0 and related changes. It also makes the first step to remove the cairo-lang package as starknet.py dependency!

Some classes/functions from cairo-lang package are rewritten and are a part of starknet.py:

Python version#

Unfortunately, as a result of adaptation to support cairo-lang newest package, support for Python 3.8.X has been dropped. The only supported Python version is 3.9.

0.15.0 Deprecations#

  • compute_invoke_hash is deprecated in favour of compute_transaction_hash

  • starknet_py.common.create_contract_class is deprecated in favour of starknet_py.common.create_compiled_contract

  • Client net() property.

  • create_deployment_call() is deprecated in favour of create_contract_deployment()

0.15.0 Breaking changes#

  1. InvokeFunction is replaced by the Invoke dataclass (behaviour is the same, just the name is changed).

  2. Removed from client_models.py:

    • Invoke,

    • InvokeFunction,

    • StarknetTransaction,

    • AccountTransaction,

    • ContractClass,

    • Declare,

    • DeployAccount.

  3. Transaction’s tx_type field is renamed to type.

  4. The types.py is removed (outdated file containing only imports):

    • import decode_shortstring and encode_shortstring from starknet_py.cairo.felt,

    • import Invoke and Transaction from starknet_py.net.models.transaction,

    • import parse_address from starknet_py.net.models.address,

    • import net_address_from_net from starknet_py.net.networks.

  5. Changes in the location of some of the functions:

    Function

    Old Path

    New Path

    compute_address

    starknet_py.net.models.address

    starknet_py.hash.address

    compute_transaction_hash, compute_deploy_account_transaction_hash, compute_declare_transaction_hash

    starknet_py.utils.crypto.transaction_hash

    starknet_py.hash.transaction

    compute_hash_on_elements

    starknet_py.utils.crypto.facade

    starknet_py.hash.utils

    message_signature

    starknet_py.utils.crypto.facade

    starknet_py.hash.utils

    pedersen_hash

    starknet_py.utils.crypto.facade

    starknet_py.hash.utils

    compute_class_hash

    starkware.starknet.core.os.class_hash

    starknet_py.hash.class_hash

    get_selector_from_name

    starkware.starknet.public.abi

    starknet_py.hash.selector

    get_storage_var_address

    starkware.starknet.public.abi

    starknet_py.hash.storage

  6. Removed deprecated AccountClient

  7. Removed support for making transactions with version 0.

    • Removed Deploy transaction.

    • Removed deprecated make_declare_tx.

  8. Removed client argument from Contract __init__() and from_address(). Use provider argument instead.

  9. Removed net.l1 L1<>L2 messaging module.

  10. Added chain_id argument to BaseAccount interface and implementation get_balance() method.

  11. Changed Client get_class_by_hash() return type to Union[ContractClass, SierraContractClass].

  12. Replaced contract_address with sender_address in:

    • starknet_py.net.client_models.InvokeTransaction

    • starknet_py.net.models.transaction.Invoke

    • compute_invoke_hash

  13. Replaced BlockStateUpdate.state_diff.declared_contract_hashes is now a list of DeclaredContractHash representing new Cairo classes. Old declared contract classes are still available at BlockStateUpdate.state_diff.deprecated_declared_contract_hashes.

  14. Removed version property from PreparedFunctionCall class.

  15. Removed deprecated max_steps in ProxyConfig.

  16. Removed supported_transaction_version property from BaseAccount abstract class.

Transaction dataclasses#

All transaction’s dataclasses can be imported from the starknet_py.net.models.transaction module. The main differences between them and those from the Cairo-lang:

  • tx_type field is renamed to type,

  • fields are not validated while creating.

All of them can be used as usual.

ContractClass#

DeclaredContract has been renamed to ContractClass. There also exists CompiledContract dataclass, which specifies abi attribute to be required.




0.14.0 Migration guide#

This version deprecates several modules and fixes underlying issues with several others.

0.14.0 Breaking changes#

  1. Renamed first parameter of ContractDeployment from udc to call, that is returned from create_deployment_call().

0.14.0 Deprecations#

  1. compiler module. It will be removed in the future. We recommend transitioning to building contracts through Starknet CLI or external tools and using only compiled contracts with starknet.py.

  2. utils.data_transformer module. It has been replaced with Serializers module.

Serializers module#

New Serializers module has been added in place of old data_transformer. See Serialization guide for more details.

auto_estimate#

The way automatic fee estimation is calculated has changed from

transaction estimated fee * 1.1

to

transaction estimated fee * 1.5

when using auto_estimate parameter in API functions (for example execute(), sign_invoke_transaction() or invoke()). It was caused by many transactions failing due to low max_fee.

Note

It is now possible to set the value by which the estimated fee is multiplied, by changing ESTIMATED_FEE_MULTIPLIER in Account.




0.13.0 Migration guide#

This version deprecates the AccountClient, which is a major change to the starknet.py. It is replaced with new BaseAccount ABC and its default implementation Account.

Unlike AccountClient, an Account is not a Client anymore. This means that methods like get_storage_at, call_contract etc. are not available in the Account interface.

However, Account now exposes a .client property, which means using an Account is just as simple as AccountClient was. For example:

# Inspecting storage

await account_client.get_storage_at(contract_address=address, key=key)

# becomes

await account.client.get_storage_at(contract_address=address, key=key)
# Sending transactions

tx = await account_client.sign_invoke_v1(call, max_fee)
await account_client.send_transaction(tx)

# becomes

tx = await account.sign_invoke_v1(call, max_fee=max_fee)
# Note that max_fee is now keyword-only argument
await account.client.send_transaction(tx)
# Using execute method

await account_client.execute_v1(call, max_fee)

# becomes

await account.execute_v1(call, max_fee=max_fee)

Replacing inheritance with composition simplifies the Account interface and will make maintaining Account simpler.

Changes in the Account interface#

  1. Removed hash_message method. Use TypedData.message_hash directly instead.

  2. Account doesn’t expose a net property.

  3. Account doesn’t accept a supported_tx_version parameter. It currently always uses version 1.

  4. Some parameters like max_fee or auto_estimate are now keyword only arguments. They have to be explicitly named like account.sign_invoke_transaction(Call(...), max_fee=1000). Writing account.sign_invoke_transaction(Call(...), 1000) will not work.

0.13.0 Deprecations#

  1. Passing a dict to BaseSigner.sign_message as parameter has been deprecated in favor of TypedData dataclass.

  2. Argument client of Contract`.__init__` and ``Contract.from_address has been deprecated and replaced with provider.

  3. Starknet <> Ethereum Messaging module has been deprecated.

  4. PreparedFunctionCall.arguments has been deprecated to simplify the upcoming serialization module.

0.13.0 Breaking changes#

  1. version parameter has been removed from the most Contract methods. Contract will now use version that the Account or AccountClient is using.

  2. DeclareResult now only accepts BaseAccount.

  3. invoke_tx has been removed from the Client.call_contract parameters. call should be used instead.

  4. All error messages have been standardized with capitalization at the beginning and a full stop at the end.




0.12.0 Migration guide#

starknet.py 0.12.0 brings support for the Cairo-lang 0.10.3 and the new TESTNET2 chainId.

0.12.0 Breaking Changes#

There should not be any breaking changes if you are using the StarknetChainId imported from the starknet_py.net.models, but if you are importing it from the Cairo-lang package, please switch to the one from starknet.py.




0.11.0 Migration guide#

Cairo-lang 0.10.3 dropped support for the Deploy transaction. To be compatible we had to remove some deprecated features.

0.11.0 Breaking Changes#

Removed APIs:

  • Contract.deploy. Read more about deployment in the Deploying contracts section.

  • AccountClient.create_account. Account creation docs are here to help you!

  • Client.deploy method (from the interface and all implementations)

  • make_deploy_tx

  • compute_deploy_hash

  • the Deploy transaction

Invoke Transaction#

Old InvokeFunction transaction is now aliased as Invoke. We suggest to start using the new Invoke.




0.9.0 Migration guide#

starknet.py 0.9.0 brings support for RPC 0.2.0, updates Contract.from_address() method to work with the newest proxies and removes some deprecated features.

0.9.0 Breaking Changes#

  • Removed deprecated Account.sign_transaction. Use new Account.sign_invoke_transaction.

  • Removed deprecated InvokeFunction as call_contract parameter. Use Call class instead.

  • StateDiff has declared_contract_hashes instead of declared_contracts field (only name has changed).

  • Support for RPC 0.1.0 has been dropped in favour of RPC 0.2.0.

Contract.from_address#

Check out the Guide with the new section Resolving proxy contracts to see how to easily use proxies with the starknet.py.




0.8.0 Migration guide#

Cairo-lang 0.10.1 brings support for DEPLOY_ACCOUNT transactions that will completely replace currently used DEPLOY transactions sometime in the future.

You should already modify your applications to use new deployment flow to either support deployments using new flow:

  1. Declare a contract on Starknet using Declare transaction

  2. Pre-fund the address of new account with enough tokens to cover transaction costs

  3. Send a DeployAccount transaction with the pre-funded address

or support deploying through syscall or Universal Deployer Contract.

0.8.0 Breaking Changes#

  • entry_point_selector has been removed from v1 transactions. InvokeTransaction’s field has been changed to Optional[int]

  • net.models.address.compute_address signature has been changed and use of keyword arguments is now mandatory

  • Client.estimate_fee ABC now also accepts DeployAccount transaction as tx parameter. Custom clients should be updated to reflect this change.

0.8.0 Deprecations#

  • Contract.deploy has been deprecated in favor of new DeployAccount flow

  • Client.deploy has been deprecated




0.5.0 Migration guide#

cairo-lang 0.10.0 brings a lot of new exciting changes, like:

  • new cairo syntax,

  • new transaction version (1),

  • new __validate__ endpoint in accounts.

starknet.py 0.5.0 has an experimental support for new features and tries to minimize number of breaking changes for users who want to use the old transaction version (0). Please note that support for this transaction version will be removed in the future.

Note

There is no need to upgrade starknet.py to the newest version because the old one is still compatible with Starknet. However, an upgrade is required to use the new features.

0.5.0 Breaking Changes#

New Cairo syntax#

With the update of cairo-lang to version 0.10.0, the syntax of contracts written in cairo changes significantly. You can see the new syntax here.

As a result, the old syntax is no longer supported.

Note

This only applies to you if you compile your cairo programs using starknet.py. If you use programs that are already compiled you don’t need to worry.

For the already existent programs to be compatible with the new Starknet version, they would have to be migrated using cairo-migrate command from CLI. It is a part of cairo-lang package.

To migrate old syntax to the old one in place run:

> cairo-migrate FILES_LIST -i

See cairo-lang release notes for more details about the new syntax.

Python versions#

We drop support for python 3.7.X, following cairo-lang support. You must use python 3.8+ to use starknet.py 0.5.0.

InvokeFunction and Declare#

A new required parameter, nonce, was added to them. Use None for transaction version = 0 and a proper nonce value for new transaction version = 1.

New Transaction version#

Cairo 0.10.0 brings a transaction version = 1:

  • Deploy transactions are no longer available,

  • user accounts need to have __validate__ and __validate_declare__ functions,

  • transactions have different fields,

  • contracts have a native nonce field available.

You can still use the old transaction version, but please note it will be removed in the future. Please refer to deprecation warnings to see required changes.

For now both (0 nad 1) transaction versions will be accepted but there will be a DeprecationWarning while using version 0.

AccountClient constructor#

AccountClient’s constructor has a new parameter now. supported_tx_version is used to differentiate between old and new accounts. It is set to 0 as default so there is no need to set it while using old account.

Note

In the future versions default value of supported_tx_version will be changed to 1. This will happen when transaction version = 0 is removed.

Deprecated Features#

InvokeFunction as call_contract parameter#

InvokeFunction has been deprecated as a call_contract parameter. Users should use Call instead.

Transaction version 0#

Although transactions version 0 are still valid, users should switch to Accounts supporting transaction version 1.

AccountClient’s methods#

The following AccountClient’s methods has been deprecated:

  • prepare_invoke_function(), sign_invoke_transaction() should be used instead.

  • sign_transaction(), sign_invoke_transaction() should be used instead.

Unsigned declare transaction#

make_declare_tx is deprecated, because in the future versions of Starknet unsigned declare transactions will not be supported. sign_declare_transaction() should be used to create and sign declare transaction.

Deploy transaction#

Deploy transactions will not be supported in the future versions of Starknet, so make_deploy_tx is deprecated. Contracts should be deployed through cairo syscall.




0.4.0 Migration guide#

0.4.0 of starknet.py brings multiple changes including breaking changes to API. To ensure smooth migration to this version please familiarize yourself with this migration guide.

Overlook of the changes#

0.4.0 brings support for the Starknet rpc interface.

This required us to introduce some big changes to the clients. API methods has remained mostly the same, but their parameters changed. Also, we’ve introduced custom dataclasses for every endpoint, that are simplified from these from cairo-lang library.

This provides uniform interface for both Starknet gateway (only supported way of interacting with Starknet in previous starknet.py versions), as well as JSON-RPC.

Clients#

Client has been separated into two specialized modules.

  • Use GatewayClient to interact with Starknet like you did in previous starknet.py versions

  • Use FullNodeClient to interact with JSON-RPC

Note

It is no longer possible to create an instance of Client. Doing so will cause errors in runtime.

API Changes#

Client methods has had some of the parameters removed, so it provided uniform interface for both gateway and rpc methods. Please refer to GatewayClient and FullNodeClient to see what has changed. There is no longer add_transaction method in the Client interface. It was renamed to send_transaction.

Note

Please note that send_transaction only sends a transaction, it doesn’t sign it, even when using AccountClient.

Sending transactions#

Sending transactions is currently only supported in GatewayClient. We’ve also changed the flow of creating transactions through clients:

Client.deploy and Client.declare no longer accept contract source as their input. Instead they require a prepared transactions. These can be created using Transactions module

from starknet_py.transactions.declare import make_declare_tx

client = GatewayClient("testnet")

contract_source_code = "..."
declare_tx = make_declare_tx(compilation_source=contract_source_code)
await client.declare(declare_tx)

Interface of Contract remains unchanged and it is still the recommended way of using starknet.py

AccountClient#

AccountClient now implements Client interface: parameters of some of its methods were changed. It also doesn’t have add_transaction method (like the rest of the clients).

Quick summary about the new methods:

  • prepare_invoke_function - it can be used to create InvokeFunction from one or few calls (without signature)

  • sign_transaction - takes list of calls and creates signed InvokeFunction from them

  • send_transaction - implements Client interface (takes Invoke function and sends it without changes)

  • execute - can take list of calls, sign them and send

Client errors changes#

BadRequest class has been removed and replaced with Client errors module and starknet_py.net.client_errors.ClientError or more specified errors can now be used for handling client errors. See Handling client errors in guide for an example.

Facade.py#

sign_calldata method has been removed entirely. See guide on how how you can now prepare and send transactions to Starknet.

Contract changes#

Transaction’s status is not checked while invoking through Contract interface, because RPC write API doesn’t return “code” parameter. To check if the transaction passed use wait_for_acceptance on InvokeResult.