Class StandardAccount
-
- All Implemented Interfaces:
-
com.swmansion.starknet.account.Account
public final class StandardAccount implements Account
Standard account used in Starknet.
-
-
Field Summary
Fields Modifier and Type Field Description private final Felt
address
private final StarknetChainId
chainId
-
Constructor Summary
Constructors Constructor Description StandardAccount(Felt address, Felt privateKey, Provider provider, StarknetChainId chainId, CairoVersion cairoVersion)
StandardAccount(Felt address, Felt privateKey, Provider provider, StarknetChainId chainId)
StandardAccount(Felt address, Signer signer, Provider provider, StarknetChainId chainId, CairoVersion cairoVersion)
StandardAccount(Felt address, Signer signer, Provider provider, StarknetChainId chainId)
-
Method Summary
Modifier and Type Method Description Felt
getAddress()
StarknetChainId
getChainId()
InvokeTransactionV1
signV1(List<Call> calls, ExecutionParams params, Boolean forFeeEstimate)
InvokeTransactionV3
signV3(List<Call> calls, InvokeParamsV3 params, Boolean forFeeEstimate)
DeployAccountTransactionV1
signDeployAccountV1(Felt classHash, List<Felt> calldata, Felt salt, Felt maxFee, Felt nonce, Boolean forFeeEstimate)
DeployAccountTransactionV3
signDeployAccountV3(Felt classHash, List<Felt> calldata, Felt salt, DeployAccountParamsV3 params, Boolean forFeeEstimate)
DeclareTransactionV2
signDeclareV2(Cairo1ContractDefinition sierraContractDefinition, CasmContractDefinition casmContractDefinition, ExecutionParams params, Boolean forFeeEstimate)
DeclareTransactionV3
signDeclareV3(Cairo1ContractDefinition sierraContractDefinition, CasmContractDefinition casmContractDefinition, DeclareParamsV3 params, Boolean forFeeEstimate)
List<Felt>
signTypedData(TypedData typedData)
Request<Boolean>
verifyTypedDataSignature(TypedData typedData, List<Felt> signature)
Request<InvokeFunctionResponse>
executeV1(List<Call> calls, Felt maxFee)
Execute a list of calls using version 1 invoke transaction. Request<InvokeFunctionResponse>
executeV1(List<Call> calls, Double estimateFeeMultiplier)
Execute a list of calls using version 1 invoke transaction with automatically estimated fee that will be multiplied by the specified multiplier when max fee is calculated. Request<InvokeFunctionResponse>
executeV1(List<Call> calls)
Request<InvokeFunctionResponse>
executeV1(Call call, Felt maxFee)
Execute single call using version 1 invoke transaction. Request<InvokeFunctionResponse>
executeV1(Call call, Double estimateFeeMultiplier)
Execute single call using version 1 invoke transaction with automatically estimated fee that will be multiplied by the specified multiplier when max fee is calculated. Request<InvokeFunctionResponse>
executeV1(Call call)
Request<InvokeFunctionResponse>
executeV3(List<Call> calls, ResourceBounds l1ResourceBounds)
Execute a list of calls using version 3 invoke transaction. Request<InvokeFunctionResponse>
executeV3(List<Call> calls, Double estimateAmountMultiplier, Double estimateUnitPriceMultiplier)
Execute a list of calls using version 3 invoke transaction with automatically estimated fee that will be multiplied by the specified multipliers when resource bounds are calculated. Request<InvokeFunctionResponse>
executeV3(List<Call> calls)
Request<InvokeFunctionResponse>
executeV3(Call call, ResourceBounds l1ResourceBounds)
Execute single call using version 3 invoke transaction. Request<InvokeFunctionResponse>
executeV3(Call call, Double estimateAmountMultiplier, Double estimateUnitPriceMultiplier)
Execute single call using version 3 invoke transaction with automatically estimated fee that will be multiplied by the specified multipliers when resource bounds are calculated. Request<InvokeFunctionResponse>
executeV3(Call call)
Request<Felt>
getNonce()
Request<Felt>
getNonce(BlockTag blockTag)
Request<Felt>
getNonce(Felt blockHash)
Request<Felt>
getNonce(Integer blockNumber)
Request<EstimateFeeResponseList>
estimateFeeV1(Call call)
Request<EstimateFeeResponseList>
estimateFeeV1(Call call, Boolean skipValidate)
Estimate fee for a call as a version 1 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV1(Call call, BlockTag blockTag)
Request<EstimateFeeResponseList>
estimateFeeV1(Call call, BlockTag blockTag, Boolean skipValidate)
Estimate fee for a call as a version 1 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV1(List<Call> calls)
Estimate fee for a list of calls as a version 1 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV1(List<Call> calls, Boolean skipValidate)
Estimate fee for a list of calls as a version 1 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV1(List<Call> calls, BlockTag blockTag)
Estimate fee for a list of calls as a version 1 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV1(List<Call> calls, BlockTag blockTag, Boolean skipValidate)
Estimate fee for a list of calls using version 3 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV3(Call call)
Estimate fee for a call as a version 3 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV3(Call call, Boolean skipValidate)
Estimate fee for a call as a version 3 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV3(Call call, BlockTag blockTag)
Estimate fee for a call as a version 3 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV3(Call call, BlockTag blockTag, Boolean skipValidate)
Estimate fee for a call as a version 3 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV3(List<Call> calls)
Estimate fee for a list of calls as a version 3 invoke transaction. Request<EstimateFeeResponseList>
estimateFeeV3(List<Call> calls, Boolean skipValidate)
Request<EstimateFeeResponseList>
estimateFeeV3(List<Call> calls, BlockTag blockTag)
Estimate fee for a list of calls. Request<EstimateFeeResponseList>
estimateFeeV3(List<Call> calls, BlockTag blockTag, Boolean skipValidate)
Estimate fee for a list of calls. final static StandardAccount
create(Felt address, Signer signer, Provider provider, StarknetChainId chainId)
Factory method to create a StandardAccount instance with automatic Cairo version determination. final static StandardAccount
create(Felt address, Felt privateKey, Provider provider, StarknetChainId chainId)
Factory method to create a StandardAccount instance with a private key and automatic Cairo version determination. final static Felt
generatePrivateKey()
Generate a random private key. -
Methods inherited from class com.swmansion.starknet.account.Account
signDeclareV2, signDeclareV3, signDeployAccountV1, signDeployAccountV3, signDeployAccountV3, signV1, signV1, signV1, signV3, signV3, signV3
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
StandardAccount
StandardAccount(Felt address, Felt privateKey, Provider provider, StarknetChainId chainId, CairoVersion cairoVersion)
- Parameters:
address
- the address of the account contractprivateKey
- a private key used to create a signerprovider
- a provider used to interact with StarknetchainId
- the chain id of the Starknet networkcairoVersion
- the version of Cairo language in which account contract is written
-
StandardAccount
StandardAccount(Felt address, Felt privateKey, Provider provider, StarknetChainId chainId)
- Parameters:
address
- the address of the account contractprivateKey
- a private key used to create a signerprovider
- a provider used to interact with StarknetchainId
- the chain id of the Starknet network
-
StandardAccount
StandardAccount(Felt address, Signer signer, Provider provider, StarknetChainId chainId, CairoVersion cairoVersion)
- Parameters:
address
- the address of the account contractsigner
- a signer instance used to sign transactionsprovider
- a provider used to interact with StarknetchainId
- the chain id of the Starknet networkcairoVersion
- the version of Cairo language in which account contract is written
-
StandardAccount
StandardAccount(Felt address, Signer signer, Provider provider, StarknetChainId chainId)
- Parameters:
address
- the address of the account contractsigner
- a signer instance used to sign transactionsprovider
- a provider used to interact with StarknetchainId
- the chain id of the Starknet network
-
-
Method Detail
-
getAddress
Felt getAddress()
-
getChainId
StarknetChainId getChainId()
-
signV1
InvokeTransactionV1 signV1(List<Call> calls, ExecutionParams params, Boolean forFeeEstimate)
- Parameters:
calls
- a list of calls to be signedparams
- additional execution parameters for the transactionforFeeEstimate
- when set totrue
, it changes the version to2^128+version
so the signed transaction can only be used for fee estimation
-
signV3
InvokeTransactionV3 signV3(List<Call> calls, InvokeParamsV3 params, Boolean forFeeEstimate)
- Parameters:
calls
- a list of calls to be signedparams
- additional execution parameters for the transactionforFeeEstimate
- when set totrue
, it changes the version to2^128+version
so the signed transaction can only be used for fee estimation
-
signDeployAccountV1
DeployAccountTransactionV1 signDeployAccountV1(Felt classHash, List<Felt> calldata, Felt salt, Felt maxFee, Felt nonce, Boolean forFeeEstimate)
- Parameters:
classHash
- hash of the contract that will be deployed.calldata
- constructor calldata for the contract deploymentsalt
- salt used to calculate address of the new contractmaxFee
- max fee to be consumed by this transactionnonce
- nonceforFeeEstimate
- when set totrue
, it changes the version to2^128+version
so the signed transaction can only be used for fee estimation
-
signDeployAccountV3
DeployAccountTransactionV3 signDeployAccountV3(Felt classHash, List<Felt> calldata, Felt salt, DeployAccountParamsV3 params, Boolean forFeeEstimate)
- Parameters:
classHash
- hash of the contract that will be deployedcalldata
- constructor calldata for the contract deploymentsalt
- salt used to calculate address of the new contractparams
- additional params for the transactionforFeeEstimate
- when set totrue
, it changes the version to2^128+version
so the signed transaction can only be used for fee estimation
-
signDeclareV2
DeclareTransactionV2 signDeclareV2(Cairo1ContractDefinition sierraContractDefinition, CasmContractDefinition casmContractDefinition, ExecutionParams params, Boolean forFeeEstimate)
- Parameters:
sierraContractDefinition
- a cairo 1/2 sierra compiled definition of the contract to be declaredcasmContractDefinition
- a casm representation of cairo 1/2 compiled contract to be declaredparams
- additional execution parameters for the transactionforFeeEstimate
- when set totrue
, it changes the version to2^128+version
so the signed transaction can only be used for fee estimation
-
signDeclareV3
DeclareTransactionV3 signDeclareV3(Cairo1ContractDefinition sierraContractDefinition, CasmContractDefinition casmContractDefinition, DeclareParamsV3 params, Boolean forFeeEstimate)
- Parameters:
sierraContractDefinition
- a cairo 1/2 sierra compiled definition of the contract to be declaredcasmContractDefinition
- a casm representation of cairo 1/2 compiled contract to be declaredparams
- additional parameters for the transactionforFeeEstimate
- when set totrue
, it changes the version to2^128+version
so the signed transaction can only be used for fee estimation
-
signTypedData
List<Felt> signTypedData(TypedData typedData)
- Parameters:
typedData
- a TypedData instance to sign
-
verifyTypedDataSignature
Request<Boolean> verifyTypedDataSignature(TypedData typedData, List<Felt> signature)
- Parameters:
typedData
- a TypedData instance which signature will be verifiedsignature
- a signature of typedData
-
executeV1
Request<InvokeFunctionResponse> executeV1(List<Call> calls, Felt maxFee)
Execute a list of calls using version 1 invoke transaction.
Execute list of calls on Starknet.
- Parameters:
calls
- a list of calls to be executed.maxFee
- a max fee to pay for the transaction.
-
executeV1
Request<InvokeFunctionResponse> executeV1(List<Call> calls, Double estimateFeeMultiplier)
Execute a list of calls using version 1 invoke transaction with automatically estimated fee that will be multiplied by the specified multiplier when max fee is calculated.
- Parameters:
calls
- a list of calls to be executed.estimateFeeMultiplier
- how big multiplier should be used for the estimated fee.
-
executeV1
Request<InvokeFunctionResponse> executeV1(List<Call> calls)
- Parameters:
calls
- a list of calls to be executed.
-
executeV1
Request<InvokeFunctionResponse> executeV1(Call call, Felt maxFee)
Execute single call using version 1 invoke transaction.
Execute single call on Starknet.
- Parameters:
call
- a call to be executed.maxFee
- a max fee to pay for the transaction.
-
executeV1
Request<InvokeFunctionResponse> executeV1(Call call, Double estimateFeeMultiplier)
Execute single call using version 1 invoke transaction with automatically estimated fee that will be multiplied by the specified multiplier when max fee is calculated.
- Parameters:
call
- a call to be executed.estimateFeeMultiplier
- how big multiplier should be used for the estimated fee.
-
executeV1
Request<InvokeFunctionResponse> executeV1(Call call)
- Parameters:
call
- a call to be executed.
-
executeV3
Request<InvokeFunctionResponse> executeV3(List<Call> calls, ResourceBounds l1ResourceBounds)
Execute a list of calls using version 3 invoke transaction.
Execute list of calls on Starknet.
- Parameters:
calls
- a list of calls to be executed.l1ResourceBounds
- L1 resource bounds for the transaction.
-
executeV3
Request<InvokeFunctionResponse> executeV3(List<Call> calls, Double estimateAmountMultiplier, Double estimateUnitPriceMultiplier)
Execute a list of calls using version 3 invoke transaction with automatically estimated fee that will be multiplied by the specified multipliers when resource bounds are calculated.
- Parameters:
calls
- a list of calls to be executed.estimateAmountMultiplier
- how big multiplier should be used for the estimated amount.estimateUnitPriceMultiplier
- how big multiplier should be used for the estimated unit price.
-
executeV3
Request<InvokeFunctionResponse> executeV3(List<Call> calls)
- Parameters:
calls
- a list of calls to be executed.
-
executeV3
Request<InvokeFunctionResponse> executeV3(Call call, ResourceBounds l1ResourceBounds)
Execute single call using version 3 invoke transaction.
Execute single call on Starknet.
- Parameters:
call
- a call to be executed.l1ResourceBounds
- L1 resource bounds for the transaction.
-
executeV3
Request<InvokeFunctionResponse> executeV3(Call call, Double estimateAmountMultiplier, Double estimateUnitPriceMultiplier)
Execute single call using version 3 invoke transaction with automatically estimated fee that will be multiplied by the specified multipliers when resource bounds are calculated.
- Parameters:
call
- a call to be executed.estimateAmountMultiplier
- how big multiplier should be used for the estimated amount.estimateUnitPriceMultiplier
- how big multiplier should be used for the estimated unit price.
-
executeV3
Request<InvokeFunctionResponse> executeV3(Call call)
- Parameters:
call
- a call to be executed.
-
getNonce
Request<Felt> getNonce(BlockTag blockTag)
- Parameters:
blockTag
- block tag used for returning this value.
-
getNonce
Request<Felt> getNonce(Felt blockHash)
- Parameters:
blockHash
- block hash used for returning this value.
-
getNonce
Request<Felt> getNonce(Integer blockNumber)
- Parameters:
blockNumber
- block number used for returning this value.
-
estimateFeeV1
Request<EstimateFeeResponseList> estimateFeeV1(Call call)
- Parameters:
call
- a call used to estimate a fee.
-
estimateFeeV1
Request<EstimateFeeResponseList> estimateFeeV1(Call call, Boolean skipValidate)
Estimate fee for a call as a version 1 invoke transaction.
Estimate fee for a signed call on Starknet.
- Parameters:
call
- a call used to estimate a fee.skipValidate
- when set totrue
, the validation part of the transaction is skipped.
-
estimateFeeV1
Request<EstimateFeeResponseList> estimateFeeV1(Call call, BlockTag blockTag)
- Parameters:
call
- a call used to estimate a fee.blockTag
- a tag of the block in respect to what the query will be made.
-
estimateFeeV1
Request<EstimateFeeResponseList> estimateFeeV1(Call call, BlockTag blockTag, Boolean skipValidate)
Estimate fee for a call as a version 1 invoke transaction.
Estimate fee for a signed call on Starknet for specified block tag.
- Parameters:
call
- a call used to estimate a fee.blockTag
- a tag of the block in respect to what the query will be made.skipValidate
- when set totrue
, the validation part of the transaction is skipped.
-
estimateFeeV1
Request<EstimateFeeResponseList> estimateFeeV1(List<Call> calls)
Estimate fee for a list of calls as a version 1 invoke transaction.
Estimate fee for a signed list of calls on Starknet.
- Parameters:
calls
- a list of calls used to estimate a fee.
-
estimateFeeV1
Request<EstimateFeeResponseList> estimateFeeV1(List<Call> calls, Boolean skipValidate)
Estimate fee for a list of calls as a version 1 invoke transaction.
Estimate fee for a signed list of calls on Starknet.
- Parameters:
calls
- a list of calls used to estimate a fee.skipValidate
- when set totrue
, the validation part of the transaction is skipped.
-
estimateFeeV1
Request<EstimateFeeResponseList> estimateFeeV1(List<Call> calls, BlockTag blockTag)
Estimate fee for a list of calls as a version 1 invoke transaction.
Estimate fee for a signed list of calls on Starknet.
- Parameters:
calls
- a list of calls used to estimate a fee.blockTag
- a tag of the block in respect to what the query will be made.
-
estimateFeeV1
Request<EstimateFeeResponseList> estimateFeeV1(List<Call> calls, BlockTag blockTag, Boolean skipValidate)
Estimate fee for a list of calls using version 3 invoke transaction.
Estimate fee for a signed list of calls on Starknet.
- Parameters:
calls
- a list of calls used to estimate a fee.blockTag
- a tag of the block in respect to what the query will be made.skipValidate
- when set totrue
, the validation part of the transaction is skipped.
-
estimateFeeV3
Request<EstimateFeeResponseList> estimateFeeV3(Call call)
Estimate fee for a call as a version 3 invoke transaction.
Estimate fee for a signed call on Starknet.
- Parameters:
call
- a call used to estimate a fee.
-
estimateFeeV3
Request<EstimateFeeResponseList> estimateFeeV3(Call call, Boolean skipValidate)
Estimate fee for a call as a version 3 invoke transaction.
Estimate fee for a signed call on Starknet.
- Parameters:
call
- a call used to estimate a fee.skipValidate
- when set totrue
, the validation part of the transaction is skipped.
-
estimateFeeV3
Request<EstimateFeeResponseList> estimateFeeV3(Call call, BlockTag blockTag)
Estimate fee for a call as a version 3 invoke transaction.
Estimate fee for a signed call on Starknet for specified block tag.
- Parameters:
call
- a call used to estimate a fee.blockTag
- a tag of the block in respect to what the query will be made.
-
estimateFeeV3
Request<EstimateFeeResponseList> estimateFeeV3(Call call, BlockTag blockTag, Boolean skipValidate)
Estimate fee for a call as a version 3 invoke transaction.
Estimate fee for a signed call on Starknet for specified block tag.
- Parameters:
call
- a call used to estimate a fee.blockTag
- a tag of the block in respect to what the query will be made.skipValidate
- when set totrue
, the validation part of the transaction is skipped.
-
estimateFeeV3
Request<EstimateFeeResponseList> estimateFeeV3(List<Call> calls)
Estimate fee for a list of calls as a version 3 invoke transaction.
Estimate fee for a signed list of calls on Starknet.
- Parameters:
calls
- a list of calls used to estimate a fee.
-
estimateFeeV3
Request<EstimateFeeResponseList> estimateFeeV3(List<Call> calls, Boolean skipValidate)
- Parameters:
calls
- a list of calls used to estimate a fee.skipValidate
- when set totrue
, the validation part of the transaction is skipped.
-
estimateFeeV3
Request<EstimateFeeResponseList> estimateFeeV3(List<Call> calls, BlockTag blockTag)
Estimate fee for a list of calls.
Estimate fee for a signed list of calls on Starknet.
- Parameters:
calls
- a list of calls used to estimate a fee.blockTag
- a tag of the block in respect to what the query will be made.
-
estimateFeeV3
Request<EstimateFeeResponseList> estimateFeeV3(List<Call> calls, BlockTag blockTag, Boolean skipValidate)
Estimate fee for a list of calls.
Estimate fee for a signed list of calls on Starknet.
- Parameters:
calls
- a list of calls used to estimate a fee.blockTag
- a tag of the block in respect to what the query will be made.skipValidate
- when set totrue
, the validation part of the transaction is skipped.
-
create
final static StandardAccount create(Felt address, Signer signer, Provider provider, StarknetChainId chainId)
Factory method to create a StandardAccount instance with automatic Cairo version determination.
- Parameters:
address
- the address of the account contractsigner
- a signer instance used to sign transactionsprovider
- a provider used to interact with StarknetchainId
- the chain id of the Starknet network
-
create
final static StandardAccount create(Felt address, Felt privateKey, Provider provider, StarknetChainId chainId)
Factory method to create a StandardAccount instance with a private key and automatic Cairo version determination.
- Parameters:
address
- the address of the account contractprivateKey
- a private key used to create a signerprovider
- a provider used to interact with StarknetchainId
- the chain id of the Starknet network
-
generatePrivateKey
final static Felt generatePrivateKey()
Generate a random private key.
-
-
-
-