pub trait Account: ExecutionEncoder + Sized {
type SignError: Error + Send + Sync;
// Required methods
fn address(&self) -> Felt;
fn chain_id(&self) -> Felt;
fn sign_execution_v3<'life0, 'life1, 'async_trait>(
&'life0 self,
execution: &'life1 RawExecutionV3,
query_only: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<Felt>, Self::SignError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn sign_declaration_v3<'life0, 'life1, 'async_trait>(
&'life0 self,
declaration: &'life1 RawDeclarationV3,
query_only: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<Felt>, Self::SignError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn is_signer_interactive(
&self,
context: SignerInteractivityContext<'_>,
) -> bool;
// Provided methods
fn execute_v3(&self, calls: Vec<Call>) -> ExecutionV3<'_, Self> { ... }
fn execute(&self, calls: Vec<Call>) -> ExecutionV3<'_, Self> { ... }
fn declare_v3(
&self,
contract_class: Arc<FlattenedSierraClass>,
compiled_class_hash: Felt,
) -> DeclarationV3<'_, Self> { ... }
fn declare(
&self,
contract_class: Arc<FlattenedSierraClass>,
compiled_class_hash: Felt,
) -> DeclarationV3<'_, Self> { ... }
}Expand description
The standard Starknet account contract interface. It makes no assumption about the underlying
signer or provider. Account implementations that come with an active connection to the network
should also implement ConnectedAccount for useful functionalities like estimating fees and
sending transactions.
Required Associated Types§
Required Methods§
Sourcefn chain_id(&self) -> Felt
fn chain_id(&self) -> Felt
Gets the chain ID of the network where the account contract was deployed.
Sourcefn sign_execution_v3<'life0, 'life1, 'async_trait>(
&'life0 self,
execution: &'life1 RawExecutionV3,
query_only: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<Felt>, Self::SignError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign_execution_v3<'life0, 'life1, 'async_trait>(
&'life0 self,
execution: &'life1 RawExecutionV3,
query_only: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<Felt>, Self::SignError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Signs an execution request to authorize an INVOKE v3 transaction that pays transaction
fees in STRK.
If query_only is true, the commitment must be constructed in a way that a real state-
changing transaction cannot be authenticated. This is to prevent replay attacks.
Sourcefn sign_declaration_v3<'life0, 'life1, 'async_trait>(
&'life0 self,
declaration: &'life1 RawDeclarationV3,
query_only: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<Felt>, Self::SignError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn sign_declaration_v3<'life0, 'life1, 'async_trait>(
&'life0 self,
declaration: &'life1 RawDeclarationV3,
query_only: bool,
) -> Pin<Box<dyn Future<Output = Result<Vec<Felt>, Self::SignError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Signs an execution request to authorize an DECLARE v3 transaction that pays transaction
fees in STRK for declaring Cairo 1 classes.
If query_only is true, the commitment must be constructed in a way that a real state-
changing transaction cannot be authenticated. This is to prevent replay attacks.
Sourcefn is_signer_interactive(&self, context: SignerInteractivityContext<'_>) -> bool
fn is_signer_interactive(&self, context: SignerInteractivityContext<'_>) -> bool
Whether the underlying signer implementation is interactive, such as a hardware wallet.
Implementations should return true if the signing operation is very expensive, even if not
strictly “interactive” as in requiring human input.
This affects how an account makes decision on whether to request a real signature for estimation/simulation purposes.
Provided Methods§
Sourcefn execute_v3(&self, calls: Vec<Call>) -> ExecutionV3<'_, Self>
fn execute_v3(&self, calls: Vec<Call>) -> ExecutionV3<'_, Self>
Generates an instance of ExecutionV3 for sending INVOKE v3 transactions. Pays
transaction fees in STRK.
Sourcefn execute(&self, calls: Vec<Call>) -> ExecutionV3<'_, Self>
👎Deprecated: transaction version used might change unexpectedly; use execute_v3 instead
fn execute(&self, calls: Vec<Call>) -> ExecutionV3<'_, Self>
execute_v3 insteadGenerates an instance of ExecutionV3 for sending INVOKE v3 transactions. Pays
transaction fees in STRK.
Sourcefn declare_v3(
&self,
contract_class: Arc<FlattenedSierraClass>,
compiled_class_hash: Felt,
) -> DeclarationV3<'_, Self>
fn declare_v3( &self, contract_class: Arc<FlattenedSierraClass>, compiled_class_hash: Felt, ) -> DeclarationV3<'_, Self>
Generates an instance of DeclarationV3 for sending DECLARE v3 transactions. Pays
transaction fees in STRK.
To declare a Sierra (Cairo 1) class, a compiled_class_hash must be provided. This can be
obtained by compiling the Sierra class to obtain a CASM class, and then hashing it.
The compilation of Sierra to CASM can either be done interactively via the
starknet-sierra-compile command from the Cairo toolchain, or programmatically through the
Cairo crates.
Hashing the resulting CASM class is supported in the starknet-core crate. It can also be
done interactively via Starkli with its starkli class-hash command.
This method is only used for declaring Sierra (Cairo 1) classes. Declaring legacy (Cairo 0) classes is no longer supported.
Sourcefn declare(
&self,
contract_class: Arc<FlattenedSierraClass>,
compiled_class_hash: Felt,
) -> DeclarationV3<'_, Self>
👎Deprecated: transaction version used might change unexpectedly; use declare_v3 instead
fn declare( &self, contract_class: Arc<FlattenedSierraClass>, compiled_class_hash: Felt, ) -> DeclarationV3<'_, Self>
declare_v3 insteadGenerates an instance of DeclarationV3 for sending DECLARE v3 transactions. Pays
transaction fees in STRK.
To declare a Sierra (Cairo 1) class, a compiled_class_hash must be provided. This can be
obtained by compiling the Sierra class to obtain a CASM class, and then hashing it.
The compilation of Sierra to CASM can either be done interactively via the
starknet-sierra-compile command from the Cairo toolchain, or programmatically through the
Cairo crates.
Hashing the resulting CASM class is supported in the starknet-core crate. It can also be
done interactively via Starkli with its starkli class-hash command.
This method is only used for declaring Sierra (Cairo 1) classes. Declaring legacy (Cairo 0) classes is no longer supported.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.