Skip to content

Latest commit

 

History

History
62 lines (38 loc) · 5.01 KB

smart-account-concepts.mdx

File metadata and controls

62 lines (38 loc) · 5.01 KB

Concepts

Owners

Each Safe account maintains its own list of owners in the storage in the form of Ethereum addresses. Owners can be added or removed by other owners.

Threshold

Safe Smart Account maintains a threshold, the minimum number of owners required to confirm a transaction before it gets executed. The threshold of owners required to confirm a transaction is also stored in the storage. Owners of a Safe account can change the threshold value as well. A Safe account can have any number of owners, and the threshold value can be set between one and the total number of owners.

Signature verification

Safe Smart Account, being a contract account, does not have a private key to sign transactions, and EVM cannot verify incoming transactions to a contract account. Hence, a contract account has to do the authentication and authorization in its code. When a transaction is submitted to a Safe account, it is first verified by the Safe account to ensure that the transaction is valid. If the required number of owners has signed the transaction, the transaction is allowed to be executed. If the required number of owners has not signed the transaction, the transaction reverts to the signature validation step. A Safe Smart Account verifies if each signer is an owner of the Safe account and verifies the signature based on the signature type. To learn more about the signature types supported by Safe and encoding, refer to the Signatures page.

Transaction flow

Transactions through a Safe Smart Account can be primarily divided into two types:

Safe Transaction

Safe Smart Account contract provides execTransaction function to submit and execute a Safe transaction which is signed by the owners of the Safe Smart Account.

To execute a transaction with the Safe Smart Account, the execTransaction method needs to be called with the following parameters:

  • to: The recipient address of the transaction.
  • value: The amount of Ether (in wei) to send with the transaction.
  • data: The data payload of the transaction, typically used to call a function on the recipient contract.
  • operation: Safe Smart Account supports CALL and DELEGATECALL.
  • safeTxGas: Gas that should be used for the Safe transaction.
  • baseGas: This is the amount of gas independent of the specific Safe transactions, but used for general things such as signature checks and the base transaction fee. SafeTxGas and baseGas combined are comparable to the gas limit of a regular transaction.
  • gasPrice: Same like for a regular Ethereum transaction. Setting the gas price to 0 means that no refund is paid out.
  • gasToken: For regular Ethereum transactions, gas is always paid in Ether. A Safe Smart Account enables users to pay in ERC20 tokens or Ether. The desired token is specified here. If 0x0, then Ether is used. Gas costs are calculated by (baseGas + txGas) * gasPrice.
  • refundReceiver: The refund does not necessarily have to go to the account submitting the transaction but can be paid out to any account specified here. If set to 0, tx.origin will be used.
  • signatures: All parameters are used to generate a transaction hash and signed by the owners of the Safe Smart Account. A list of hex encoded signatures is expected (execTransaction expects that the signatures are sorted by owner address. This is required to easily validate no confirmation duplicates exist).
Module Transaction

Safe Smart Account contract provides execTransactionFromModule and execTransactionFromModuleReturnData functions to accept transactions from modules. A module can be any Ethereum address and can bypass signature verification logic to execute transactions through a Safe Smart Account.

  • to: The recipient address of the transaction.
  • value: The amount of Ether (in wei) to send with the transaction.
  • data: The data payload of the transaction, typically used to call a function on the recipient contract.
  • operation: The type of operation to execute, either CALL or DELEGATECALL.

Here are some core components of a Safe Smart Account that you will learn about:

Safe Modules

Safe Modules are smart contracts that extend Safe's functionality with added custom features while the module logic remains separate from Safe's core contracts.

More information is available in the Safe Modules page.

Safe Guards

Safe Guards make checks before and after a Safe transaction.

More information is available in the Safe Guards page.

Signatures

Safe Smart Account support alternative signature schemes such as EIP-1271 and EIP-712 and relaying by making the confirmation/verification logic independent of msg.sender. Read more about the signature schemes supported by Safe.