Account

Trait Account 

Source
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§

Source

type SignError: Error + Send + Sync

Possible errors for signing transactions.

Required Methods§

Source

fn address(&self) -> Felt

Gets the account contract’s address.

Source

fn chain_id(&self) -> Felt

Gets the chain ID of the network where the account contract was deployed.

Source

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.

Source

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.

Source

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§

Source

fn execute_v3(&self, calls: Vec<Call>) -> ExecutionV3<'_, Self>

Generates an instance of ExecutionV3 for sending INVOKE v3 transactions. Pays transaction fees in STRK.

Source

fn execute(&self, calls: Vec<Call>) -> ExecutionV3<'_, Self>

👎Deprecated: transaction version used might change unexpectedly; use execute_v3 instead

Generates an instance of ExecutionV3 for sending INVOKE v3 transactions. Pays transaction fees in STRK.

Source

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.

Source

fn declare( &self, contract_class: Arc<FlattenedSierraClass>, compiled_class_hash: Felt, ) -> DeclarationV3<'_, Self>

👎Deprecated: transaction version used might change unexpectedly; use declare_v3 instead

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.

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.

Implementations on Foreign Types§

Source§

impl<A> Account for &A
where A: Account + Sync,

Source§

type SignError = <A as Account>::SignError

Source§

fn address(&self) -> Felt

Source§

fn chain_id(&self) -> Felt

Source§

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,

Source§

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,

Source§

fn is_signer_interactive(&self, context: SignerInteractivityContext<'_>) -> bool

Source§

impl<A> Account for Box<A>
where A: Account + Sync + Send,

Source§

type SignError = <A as Account>::SignError

Source§

fn address(&self) -> Felt

Source§

fn chain_id(&self) -> Felt

Source§

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,

Source§

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,

Source§

fn is_signer_interactive(&self, context: SignerInteractivityContext<'_>) -> bool

Source§

impl<A> Account for Arc<A>
where A: Account + Sync + Send,

Source§

type SignError = <A as Account>::SignError

Source§

fn address(&self) -> Felt

Source§

fn chain_id(&self) -> Felt

Source§

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,

Source§

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,

Source§

fn is_signer_interactive(&self, context: SignerInteractivityContext<'_>) -> bool

Implementors§