SiglessTransactionExecutor

Git Source

Inherits: ISafeTx, SecuredTokenTransfer, Executor, GuardManager

Author: Ultrasound Labs - @ultrasoundlabs This contract merges the "sigless" execution (no signature check) with the full Safe transaction execution logic. It allows you to execute a SafeTx struct directly, skipping signature checks, but still performing all the other steps (gas accounting, payment, etc) as in the original Safe contract. We don't import the Safe contract to save on gas costs.

Safe account has to delegatecall this contract to execute SafeTx with a normal flow except for the signature verification

State Variables

DOMAIN_SEPARATOR_TYPEHASH

bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;

SAFE_TX_TYPEHASH

bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;

__gap

uint256[5] private __gap;

nonce

Tracks the next expected Safe transaction nonce.

uint256 public nonce;

Functions

revertWithError

Function which uses assembly to revert with the passed error message.

Currently it is expected that the error string is at max 5 bytes of length. Ex: "GSXXX"

function revertWithError(bytes5 error) internal pure;

Parameters

NameTypeDescription
errorbytes5The error string to revert with.

execTransaction

Execute a SafeTx without requiring a signature.

This function unpacks the SafeTx struct and executes the transaction using the same logic as the original Safe contract, but skips signature verification. This is useful for trusted modules or scenarios where signature checks are not needed.

function execTransaction(SafeTx calldata safeTx) public returns (bool success);

Parameters

NameTypeDescription
safeTxSafeTxThe SafeTx struct containing all transaction parameters.

Returns

NameTypeDescription
successboolTrue if the transaction was executed successfully, false otherwise.

_handlePayment

Handles the payment/refund for a Safe transaction.

*Forked from Gnosis Safe handlePayment. Slither’s arbitrary-send-eth detector reports the receiver.send(payment) call below. In the canonical Safe design this is intentional and safe:

  1. The refund occurs after successful execution of the user’s transaction.
  2. Only the entity footing the gas bill (refundReceiver or tx.origin) receives the refund.
  3. The 2 300-gas stipend of .send mitigates re-entrancy; reverting on failure matches upstream semantics and prevents silent griefing.*
function _handlePayment(
    uint256 gasUsed,
    uint256 baseGas,
    uint256 gasPrice,
    address gasToken,
    address payable refundReceiver
) private returns (uint256 payment);

Parameters

NameTypeDescription
gasUseduint256Gas used by the Safe transaction.
baseGasuint256Gas costs that are independent of the transaction execution (e.g. base transaction fee, signature check, payment of the refund).
gasPriceuint256Gas price that should be used for the payment calculation.
gasTokenaddressToken address (or 0 if ETH) that is used for the payment.
refundReceiveraddress payableAddress that will receive the refund (defaults to tx.origin).

Returns

NameTypeDescription
paymentuint256The amount of payment made in the specified token.

encodeTransactionData

Returns the pre-image of the transaction hash (see getTransactionHash).

Forked from Safe.sol

function encodeTransactionData(
    address to,
    uint256 value,
    bytes memory data,
    Enum.Operation operation,
    uint256 safeTxGas,
    uint256 baseGas,
    uint256 gasPrice,
    address gasToken,
    address refundReceiver,
    uint256 _nonce
) internal view returns (bytes memory);

Parameters

NameTypeDescription
toaddressDestination address.
valueuint256Ether value.
databytesData payload.
operationEnum.OperationOperation type.
safeTxGasuint256Gas that should be used for the safe transaction.
baseGasuint256Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)
gasPriceuint256Maximum gas price that should be used for this transaction.
gasTokenaddressToken address (or 0 if ETH) that is used for the payment.
refundReceiveraddressAddress of receiver of gas payment (or 0 if tx.origin).
_nonceuint256Transaction nonce.

Returns

NameTypeDescription
<none>bytesTransaction hash bytes.

domainSeparator

Returns the EIP-712 domain separator (chainId hard-coded to 1).

Returns the domain separator for this contract, as defined in the EIP-712 standard.

Forked from Safe.sol

function domainSeparator() public view returns (bytes32 separator);

Returns

NameTypeDescription
separatorbytes32The domain separator.

getChainId

Returns the ID of the chain the contract is currently deployed on.

Forked from Safe.sol

function getChainId() public view returns (uint256);

Returns

NameTypeDescription
<none>uint256The ID of the current chain as a uint256.

Events

ExecutionFailure

Emitted when a delegated Safe transaction reverts.

event ExecutionFailure(bytes32 indexed txHash, uint256 indexed payment);

Parameters

NameTypeDescription
txHashbytes32The EIP-712 hash of the SafeTx.
paymentuint256The gas payment that was attempted.

ExecutionSuccess

Emitted when a delegated Safe transaction executes successfully.

event ExecutionSuccess(bytes32 indexed txHash, uint256 indexed payment);

Parameters

NameTypeDescription
txHashbytes32The EIP-712 hash of the SafeTx.
paymentuint256The gas payment that was made.