Account
Reference of interfaces, presets, and utilities related to account contracts.
Core
ISRC6
use openzeppelin::account::interface::ISRC6;
Interface of the SRC6 Standard Account as defined in the SNIP-6.
0x2ceccef7f994940b3962a6c67e0ba4fcd37df7d131417c604f91e03caecc1cd
__execute__(calls: Array<Call>) → Array<Span<felt252>>
external
Executes the list of calls as a transaction after validation.
Returns an array with each call’s output.
The Call struct is defined in corelib.
|
AccountComponent
use openzeppelin::account::AccountComponent;
Account component implementing ISRC6
for signatures over the Starknet curve.
Implementing SRC5Component is a requirement for this component to be implemented. |
__execute__(self: @ContractState, calls: Array<Call>) → Array<Span<felt252>>
external
See ISRC6::__execute__.
__validate__(self: @ContractState, calls: Array<Call>) → felt252
external
See ISRC6::__validate__.
is_valid_signature(self: @ContractState, hash: felt252, signature: Array<felt252>) → felt252
external
__validate_declare__(self: @ContractState, class_hash: felt252) → felt252
external
Validates a Declare
transaction.
Returns the short string 'VALID'
if valid, otherwise it reverts.
__validate_deploy__(self: @ContractState, class_hash: felt252, contract_address_salt: felt252, public_key: felt252) → felt252
external
Validates a DeployAccount
transaction.
See Counterfactual Deployments.
Returns the short string 'VALID'
if valid, otherwise it reverts.
get_public_key(self: @ContractState) → felt252
external
Returns the current public key of the account.
set_public_key(ref self: ContractState, new_public_key: felt252, signature: Span<felt252>)
external
Sets a new public key for the account. Only accessible by the account calling itself through __execute__
.
Requirements:
-
The caller must be the contract itself.
-
The signature must be valid for the new owner.
Emits both an OwnerRemoved and an OwnerAdded event.
The message to be signed is computed in Cairo as follows:
|
getPublicKey(self: @ContractState) → felt252
external
See get_public_key.
setPublicKey(ref self: ContractState, newPublicKey: felt252, signature: Span<felt252>)
external
See set_public_key.
initializer(ref self: ComponentState, public_key: felt252)
internal
Initializes the account with the given public key, and registers the ISRC6 interface ID.
Emits an OwnerAdded event.
assert_only_self(self: @ComponentState)
internal
Validates that the caller is the account itself. Otherwise it reverts.
assert_valid_new_owner(self: @ComponentState, current_owner: felt252, new_owner: felt252, signature: Span<felt252>)
internal
Validates that new_owner
accepted the ownership of the contract through a signature.
Requirements:
-
signature
must be valid for the new owner.
This function assumes that current_owner is the current owner of the contract, and
does not validate this assumption.
|
validate_transaction(self: @ComponentState) → felt252
internal
Validates a transaction signature from the global context.
Returns the short string 'VALID'
if valid, otherwise it reverts.
_set_public_key(ref self: ComponentState, new_public_key: felt252)
internal
Set the public key without validating the caller.
Emits an OwnerAdded event.
The usage of this method outside the set_public_key function is discouraged.
|
EthAccountComponent
use openzeppelin::account::eth_account::EthAccountComponent;
Account component implementing ISRC6
for signatures over the Secp256k1 curve.
Implementing SRC5Component is a requirement for this component to be implemented. |
The EthPublicKey type is an alias for starknet::secp256k1::Secp256k1Point .
|
__execute__(self: @ContractState, calls: Array<Call>) → Array<Span<felt252>>
external
See ISRC6::__execute__.
__validate__(self: @ContractState, calls: Array<Call>) → felt252
external
See ISRC6::__validate__.
is_valid_signature(self: @ContractState, hash: felt252, signature: Array<felt252>) → felt252
external
__validate_declare__(self: @ContractState, class_hash: felt252) → felt252
external
Validates a Declare
transaction.
Returns the short string 'VALID'
if valid, otherwise it reverts.
__validate_deploy__(self: @ContractState, class_hash: felt252, contract_address_salt: felt252, public_key: EthPublicKey) → felt252
external
Validates a DeployAccount
transaction.
See Counterfactual Deployments.
Returns the short string 'VALID'
if valid, otherwise it reverts.
get_public_key(self: @ContractState) → EthPublicKey
external
Returns the current public key of the account.
set_public_key(ref self: ContractState, new_public_key: EthPublicKey, signature: Span<felt252>)
external
Sets a new public key for the account. Only accessible by the account calling itself through __execute__
.
Requirements:
-
The caller must be the contract itself.
-
The signature must be valid for the new owner.
Emits both an OwnerRemoved and an OwnerAdded event.
The message to be signed is computed in Cairo as follows:
|
getPublicKey(self: @ContractState) → EthPublicKey
external
See get_public_key.
setPublicKey(ref self: ContractState, newPublicKey: EthPublicKey, signature: Span<felt252>)
external
See set_public_key.
initializer(ref self: ComponentState, public_key: EthPublicKey)
internal
Initializes the account with the given public key, and registers the ISRC6 interface ID.
Emits an OwnerAdded event.
assert_only_self(self: @ComponentState)
internal
Validates that the caller is the account itself. Otherwise it reverts.
assert_valid_new_owner(self: @ComponentState, current_owner: EthPublicKey, new_owner: EthPublicKey, signature: Span<felt252>)
internal
Validates that new_owner
accepted the ownership of the contract through a signature.
Requirements:
-
The signature must be valid for the
new_owner
.
This function assumes that current_owner is the current owner of the contract, and
does not validate this assumption.
|
validate_transaction(self: @ComponentState) → felt252
internal
Validates a transaction signature from the global context.
Returns the short string 'VALID'
if valid, otherwise it reverts.
_set_public_key(ref self: ComponentState, new_public_key: EthPublicKey)
internal
Set the public key without validating the caller.
Emits an OwnerAdded event.
The usage of this method outside the set_public_key function is discouraged.
|
Presets
AccountUpgradeable
use openzeppelin::presets::AccountUpgradeable;
Upgradeable account contract leveraging AccountComponent.
0x04343194a4a6082192502e132d9e7834b5d9bfc7a0c1dd990e95b66f85a66d46
EthAccountUpgradeable
use openzeppelin::presets::EthAccountUpgradeable;
Upgradeable account contract leveraging EthAccountComponent.
The EthPublicKey type is an alias for starknet::secp256k1::Secp256k1Point .
|
0x02203673e728fa07de1c2ea60405399ffefaf875f1b7ae54e747659e1e216d94