Migration guide#
0.24.3 Migration guide#
0.24.3 Minor changes#
Updated crypto-cpp-py to version
1.4.5
.
Ledger support (see
LedgerSigner
) is now optional. To use it, install the package withpoetry install -E ledger
.
0.24.2 Migration guide#
0.24.2 Minor changes#
Added
KeyPair.generate()
method which allows to generate key pair based on cryptographically strong pseudo-random number.
abi
parameter is now optional inContract.deploy_contract_v3()
.Added quickfix for
u96
parsing for both pre and post2.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#
Fixed parsing ABI that contains
u96
data type.Fixed
l1_address
deserialization inL2toL1MessageSchema
.
0.24.0 Migration guide#
DevnetClient
has been implemented to interact with additional features of the starknet-devnet-rs
LedgerSigner
has been implemented to enable signing with Ledger hardware wallet
0.24.0 Targeted versions#
0.24.0 Breaking changes#
CompiledContract
andContractClass
have been renamed toDeprecatedCompiledContract
andDeprecatedContractClass
.ContractClassSchema
have been renamed toDeprecatedContractClassSchema
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#
StarkNetDomain
has been renamed toDomain
Parameter
is now abstract -StandardParameter
,EnumParameter
andMerkleTreeParameter
should be used
0.23.0 Minor changes#
Account.sign_message()
now accepts parametertyped_data
as bothTypedData
andTypedDataDict
Account.verify_message()
now accepts parametertyped_data
as bothTypedData
andTypedDataDict
from_keystore()
has been added
0.22.0 Migration guide#
0.22.0 Targeted versions#
0.22.0 Breaking changes#
Support for Goerli has been removed
StarknetChainId.SEPOLIA_TESTNET
has been renamed toStarknetChainId.SEPOLIA
Parameter
chain
has been removed from the methodsAccount.deploy_account_v1()
andAccount.deploy_account_v3()
Parameter
chain_id
has been removed from the methodget_balance()
L1HandlerTransactionTrace
fieldexecution_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#
PendingStarknetBlock
andPendingStarknetBlockWithTxHashes
fieldparent_block_hash
has been renamed toparent_hash
StarknetBlockCommon
has been renamed toBlockHeader
StarknetBlock
andStarknetBlockWithTxHashes
fieldsparent_block_hash
androot
have been renamed toparent_hash
andnew_root
respectivelyFunctionInvocation
fieldexecution_resources
has been renamed tocomputation_resources
0.21.0 Minor changes#
EventsChunk
fieldevents
is now a list ofEmittedEvent
instead ofEvent
ExecutionResources
has a new required fielddata_availability
InvokeTransactionTrace
,DeclareTransactionTrace
andDeployAccountTransactionTrace
have a new required fieldexecution_resources
EstimatedFee
has new required fieldsdata_gas_consumed
anddata_gas_price
StarknetBlock
,PendingStarknetBlock
,StarknetBlockWithTxHashes
,PendingStarknetBlockWithTxHashes
have new required fieldsl1_data_gas_price
andl1_da_mode
SierraContractClass
has an additional properyparsed_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#
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
:
execute()
has been renamed toexecute_v1()
execute_v3()
has been addeddeploy_account()
has been renamed todeploy_account_v1()
deploy_account_v3()
has been addedsign_declare_v3()
,sign_deploy_account_v3()
andsign_invoke_v3()
have been addedsign_declare_transaction()
,sign_declare_v2_transaction()
,sign_deploy_account_transaction()
andsign_invoke_transaction()
have been renamed tosign_declare_v1()
,sign_declare_v2()
,sign_deploy_account_v1()
andsign_invoke_v1()
respectively
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
:
estimate_fee()
has a new parameterskip_validate
declare()
acceptstransaction
argument of the typeDeclareV3
send_transaction()
acceptstransaction
argument of the typeInvokeV3
deploy_account()
acceptstransaction
argument of the typeDeployAccountV3
Changes in the Contract
:
Contract.declare()
has been replaced byContract.declare_v1()
,Contract.declare_v2()
andContract.declare_v3()
Contract.deploy_contract()
has been replaced byContract.deploy_contract_v1()
andContract.deploy_contract_v3()
. Optional parametersunique
andsalt
have been added to both methodsContractFunction.prepare()
has been replaced byContractFunction.prepare_invoke_v1()
,ContractFunction.prepare_invoke_v3()
andContractFunction.prepare_call()
ContractFunction.invoke()
has been replaced byContractFunction.invoke_v1()
andContractFunction.invoke_v3()
PreparedFunctionCall()
has now only methodsPreparedFunctionCall.call()
andPreparedFunctionCall.call_raw()
PreparedFunctionInvokeV1()
andPreparedFunctionInvokeV3()
with methodsinvoke
andestimate_fee
have been addedDeclareResult.deploy()
has been replaced byDeclareResult.deploy_v1()
andDeclareResult.deploy_v3()
0.19.0 Targeted versions#
0.19.0 Breaking changes#
Other breaking changes not mentioned above.
GatewayClient
all related classes and fields have been removed.Client
net
property has been removed.Declare
,DeployAccount
andInvoke
have been renamed toDeclareV1
,DeployAccountV1
andInvokeV1
respectively.TransactionReceipt
fieldexecution_resources
has been changed fromdict
toExecutionResources
.TransactionReceipt
fieldsstatus
andrejection_reason
have been removed.TransactionStatus
,TransactionExecutionStatus
andTransactionFinalityStatus
have been changed to have the same structure as in RPC specification.EstimatedFee
has a new required fieldunit
.EstimatedFee
fieldgas_usage
has been renamed togas_consumed
.FunctionInvocation
has a new required fieldexecution_resources
.ResourcePrice
fieldprice_in_strk
has been renamed toprice_in_fri
and has now become required.ResourceLimits
class has been renamed toResourceBounds
.BaseAccount
andAccount
propertysupported_transaction_version
has been removed.wait_for_accept
parameter inClient.wait_for_tx()
andSentTransaction.wait_for_acceptance()
has been removed.InvokeTransaction
has been replaced byInvokeTransactionV0
andInvokeTransactionV1
.DeclareTransaction
has been replaced byDeclareTransactionV0
,DeclareTransactionV1
andDeclareTransactionV3
.DeployAccountTransaction
has been replaced byDeployAccountTransactionV1
.
0.19.0 Minor changes#
L1HandlerTransaction
fieldnonce
is now required.TransactionReceipt
fieldsactual_fee
,finality_status
,execution_status
,execution_resources
andtype
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#
Support for
TESTNET2
network has been removed.
FullNodeClient.get_pending_transactions()
method has been removed. It is advised to useFullNodeClient.get_block()
method withblock_number="pending"
argument.
PendingStarknetBlock
fieldparent_hash
is now namedparent_block_hash
.FunctionInvocation
fieldsevents
andmessages
have been changed fromList[Event]
andList[L2toL1Message]
toList[OrderedEvent]
andList[OrderedMessage]
respectively.cairo_version
parameter inAccount.sign_invoke_transaction()
andAccount.execute()
has been removed.
0.18.3 Minor changes#
StarknetBlock
,StarknetBlockWithTxHashes
,PendingStarknetBlock
andPendingStarknetBlockWithTxHashes
now have two additional fields:starknet_version
andl1_gas_price
.PendingStarknetBlock
andPendingStarknetBlockWithTxHashes
fieldstimestamp
,sequencer_address
andparent_block_hash
are now required, not optional.TransactionReceipt
now has an additional field -message_hash
(forL1_HANDLER_TXN_RECEIPT
).Most fields in
TransactionTrace
classes are now optional.InvokeTransactionTrace
,DeclareTransactionTrace
,DeployAccountTransactionTrace
andL1HandlerTransactionTrace
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#
Client.get_block_traces()
has been renamed toClient.trace_block_transactions()
in order to match RPC specification.
0.18.2 Deprecations#
cairo_version
parameter inAccount.sign_invoke_transaction()
andAccount.execute()
has been deprecated.
0.18.2 Bugfixes#
Fixed a bug when using
proxy_config=True
inContract.from_address()
method regardingEntry point EntryPointSelector(...) not found in contract
.
0.18.2 Minor changes#
Client.trace_block_transactions()
return type has been changed fromBlockTransactionTraces
toUnion[BlockTransactionTraces, List[BlockTransactionTrace]]
.
include_block
parameter inGatewayClient.get_state_update()
now works on gateway mainnet.
BaseAccount
interface andAccount
now have an additional async property -cairo_version
.
0.18.2 Development-related changes#
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#
Parameter
include_block
inGatewayClient.get_state_update()
doesn’t work on mainnet gateway (an error is thrown).
Account.sign_invoke_transaction()
now accepts additional parametercairo_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!
TransactionReceipt
dataclass properties have been changed (more details in RPC specification linked above).
0.18.0 Deprecations#
status
field inTransactionReceipt
returned byFullNodeClient.get_transaction_receipt()
has been deprecated.
0.18.0 Minor changes#
FullNodeClient.get_transaction_receipt()
now returns two additional fields:acceptance_status
andfinality_status
.
Added two fields to
TransactionReceipt
-revert_error
(Gateway) andrevert_reason
(FullNode).hash
property inTransaction
is now optional.Added missing field
contract_address_salt
toDeployTransaction
.
Lowered
check_interval
parameter default value inClient.wait_for_tx()
from 5 seconds to 2.
Added fields to dataclasses that previously were missing (e.g.
contract_address_salt
inDeployTransaction
).
decode_shortstring()
now is returned without\x00
in front of the decoded string.
Added two new methods to
GatewayClient
-GatewayClient.get_public_key()
andGatewayClient.get_signature()
.GatewayClient.get_state_update()
now accepts additional parameter - include_block.
KeyPair
andKeyPair.from_private_key()
now can accept keys in string representation.
0.18.0 Bugfixes#
Fixed invalid type in
BlockStateUpdate
fromStateDiff
toUnion[StateDiff, GatewayStateDiff]
Fixed
Contract not found
error inAbiResolver
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#
Deprecated function
compute_invoke_hash
instarknet_py.net.models.transaction
has been removed in favor ofstarknet_py.hash.transaction.compute_invoke_transaction_hash()
.
Removed deprecated
Deployer.create_deployment_call
andDeployer.create_deployment_call_raw
in favor ofDeployer.create_contract_deployment()
andDeployer.create_contract_deployment_raw()
.Removed
PENDING
transaction status.
0.17.0 Minor changes#
DeclareResult.deploy()
,PreparedFunctionCall.invoke()
,PreparedFunctionCall.estimate_fee()
,ContractFunction.invoke()
,Contract.declare()
andContract.deploy_contract()
can now accept customnonce
parameter.
Account.sign_invoke_transaction()
,Account.sign_declare_transaction()
,Account.sign_declare_v2()
,Account.sign_deploy_account_transaction()
andAccount.execute()
can now accept customnonce
parameter.Account.get_nonce()
can now be parametrized withblock_number
orblock_hash
.Account.get_balance()
can now be parametrized withblock_number
orblock_hash
.
RPC related changes:
L2toL1Message
dataclass now has an additional field:from_address
.TransactionReceipt
dataclass now has two additional, optional fields:type
andcontract_address
.
FullNodeClient.get_events()
keys
andaddress
parameters type are now optional.FullNodeClient.get_events()
keys
parameter can now also accept integers as felts.
StarknetChainId
changed fromEnum
toIntEnum
.
Client.wait_for_tx()
has a new parameterretries
describing the amount of retries before a time out when querying for a transaction.
0.17.0 Deprecations#
wait_for_accept parameter in
Client.wait_for_tx()
andSentTransaction.wait_for_acceptance()
has been deprecated.
0.17.0 Bugfixes#
Fixed a bug when
compute_class_hash()
mutated thecontract_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#
FullNodeClient.get_events()
keys
parameter type is nowList[List[str]]
instead ofList[str]
.FullNodeClient.get_state_update()
return type has been changed fromStateUpdate
toUnion[BlockStateUpdate, PendingBlockStateUpdate]
StateDiff
dataclass properties have been changed (more details in RPC specification linked above).
0.16.1 Minor changes#
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#
Fixed a bug where
Deployer.create_contract_deployment_raw()
would use a random salt, whensalt = 0
was passed.
0.16.0 Breaking changes#
BaseAccount.verify_message()
is no longerasync
.
Some functions’ implementation has been changed to use
crypto-cpp-py
package:Deprecated
utils.data_transformer
module has been removed. Use Serializers module instead.Deprecated
is_felt_pointer
andis_uint256
functions have been removed. Use TypeParser class instead.Deprecated
Compiler
module has been removed. Use an external compilation tool (e.g. Starknet CLI) instead.Deprecated
compilation_source
andsearch_paths
arguments has been removed from several methods. Usecompiled_contract
parameter instead.
Deprecated
ContractData.identifier_manager
has been removed. UseContractData.parsed_abi()
instead.
Removed deprecated
typed_data
parameter as dict inBaseSigner.sign_message()
. Use TypedData dataclass fromstarknet_py.utils.typed_data
.starknet_py.utils.crypto
module has been removed.Changed name of
starknet_py.transaction_exceptions
tostarknet_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:
get_selector_from_name
andget_storage_var_address
functionsDeclaredContract
is now ContractClasscompute_class_hash
function
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 ofcompute_transaction_hash
starknet_py.common.create_contract_class
is deprecated in favour ofstarknet_py.common.create_compiled_contract
Client
net()
property.create_deployment_call()
is deprecated in favour ofcreate_contract_deployment()
0.15.0 Breaking changes#
InvokeFunction
is replaced by theInvoke
dataclass (behaviour is the same, just the name is changed).Removed from client_models.py:
Invoke,
InvokeFunction,
StarknetTransaction,
AccountTransaction,
ContractClass,
Declare,
DeployAccount.
Transaction’s
tx_type
field is renamed totype
.The
types.py
is removed (outdated file containing only imports):import
decode_shortstring
andencode_shortstring
fromstarknet_py.cairo.felt
,import
Invoke
andTransaction
fromstarknet_py.net.models.transaction
,import
parse_address
fromstarknet_py.net.models.address
,import
net_address_from_net
fromstarknet_py.net.networks
.
- 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
Removed deprecated
AccountClient
Removed support for making transactions with version 0.
Removed
Deploy
transaction.Removed deprecated
make_declare_tx
.
Removed
client
argument from Contract__init__()
andfrom_address()
. Useprovider
argument instead.Removed
net.l1
L1<>L2 messaging module.Added chain_id argument to BaseAccount interface and implementation
get_balance()
method.Changed Client
get_class_by_hash()
return type toUnion[ContractClass, SierraContractClass]
.Replaced
contract_address
withsender_address
in:starknet_py.net.client_models.InvokeTransaction
starknet_py.net.models.transaction.Invoke
compute_invoke_hash
Replaced
BlockStateUpdate.state_diff.declared_contract_hashes
is now a list ofDeclaredContractHash
representing new Cairo classes. Old declared contract classes are still available atBlockStateUpdate.state_diff.deprecated_declared_contract_hashes
.Removed
version
property fromPreparedFunctionCall
class.Removed deprecated
max_steps
inProxyConfig
.Removed
supported_transaction_version
property fromBaseAccount
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 totype
,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#
Renamed first parameter of
ContractDeployment
fromudc
tocall
, that is returned fromcreate_deployment_call()
.
0.14.0 Deprecations#
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.
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#
Removed
hash_message
method. UseTypedData.message_hash
directly instead.Account
doesn’t expose anet
property.Account
doesn’t accept asupported_tx_version
parameter. It currently always uses version 1.Some parameters like
max_fee
orauto_estimate
are now keyword only arguments. They have to be explicitly named likeaccount.sign_invoke_transaction(Call(...), max_fee=1000)
. Writingaccount.sign_invoke_transaction(Call(...), 1000)
will not work.
0.13.0 Deprecations#
Passing a dict to
BaseSigner.sign_message
as parameter has been deprecated in favor ofTypedData
dataclass.Argument
client
ofContract`.__init__` and ``Contract.from_address
has been deprecated and replaced withprovider
.Starknet <> Ethereum Messaging module has been deprecated.
PreparedFunctionCall.arguments
has been deprecated to simplify the upcomingserialization
module.
0.13.0 Breaking changes#
version
parameter has been removed from the mostContract
methods.Contract
will now use version that theAccount
orAccountClient
is using.DeclareResult
now only acceptsBaseAccount
.invoke_tx
has been removed from theClient.call_contract
parameters.call
should be used instead.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:
Declare a contract on Starknet using Declare transaction
Pre-fund the address of new account with enough tokens to cover transaction costs
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 versionsUse 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.