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

Functions

__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.

__validate__(calls: Array<Call>) → felt252 external

Validates a transaction before execution.

Returns the short string 'VALID' if valid, otherwise it reverts.

is_valid_signature(hash: felt252, signature: Array<felt252>) → felt252 external

Validates whether a signature is valid or not for the given message hash.

Returns the short string 'VALID' if valid, otherwise it reverts.

Account

use openzeppelin::account::Account;

Account contract implementation extending ISRC6.

Constructor

constructor(ref self: ContractState, _public_key: felt252) constructor

Initializes the account with the given public key, and registers the ISRC6 interface ID.

Emits an OwnerAdded event.

External Functions

__validate_deploy__(self: @ContractState, class_hash: felt252, contract_address_salt: felt252, _public_key: felt252) → felt252 external

Returns the short string 'VALID' if valid, otherwise it reverts.

__execute__(ref self: ContractState, calls: Array<Call>) → Array<Span<felt252>> external

__validate__(self: @ContractState, calls: Array<Call>) → felt252 external

is_valid_signature(self: @ContractState, hash: felt252, signature: Array<felt252>) → felt252 external

supports_interface(self: @ContractState, interface_id: felt252) → bool external

__validate_declare__(self: @ContractState, class_hash: felt252) → felt252 external

Validates a Declare transaction.

Returns the short string 'VALID' if valid, otherwise it reverts.

set_public_key(ref self: ContractState, new_public_key: felt252) external

Sets a new public key for the account. Only accesible by the account calling itself through __execute__.

Emits both an OwnerRemoved and an OwnerAdded event.

get_public_key(self: @ContractState) → felt252 external

Returns the current public key of the account.

Internal Functions

initializer(ref self: ContractState, _public_key: felt252) internal

Initializes the account with the given public key, and registers the ISRC6 interface ID.

Emits an OwnerAdded event.

validate_transaction(self: @ContractState) → 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: ContractState, 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.

_is_valid_signature(self: @ContractState, hash: felt252, signature: Span<felt252>) → bool internal

Validates the provided signature for the hash, using the account current public key.

assert_only_self(self: @ContractState) internal

Validates that the caller is the account itself. Otherwise it reverts.

Events

OwnerAdded(new_owner_guid: felt252) event

Emitted when a public_key is added.

OwnerRemoved(removed_owner_guid: felt252) event

Emitted when a public_key is removed.