MultiChainSignaturesModule

Git Source

Inherits: ISafeTx

Author: Ultrasound Labs

Safe module that allows the same batched signature to be replayed across multiple chains; only the transactions whose chainIds[i] match block.chainid are executed.

Note: security-contact: security@ultrasoundlabs.org

State Variables

VERSION

Human-readable contract version (kept for backwards compatibility with Safe tooling).

string public constant VERSION = "1.4.1-MCSM";

DOMAIN_SEPARATOR_TYPEHASH

bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH =
    keccak256("EIP712Domain(uint256 chainId,address verifyingContract)");

SAFE_TX_BATCH_TYPEHASH

bytes32 private constant SAFE_TX_BATCH_TYPEHASH = keccak256(
    "SafeTxBatch(address subaccount,SafeTx[] safeTxs,uint256[] chainIds)SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)"
);

SAFE_TX_TYPEHASH

bytes32 private constant SAFE_TX_TYPEHASH = keccak256(
    "SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)"
);

SIGLESS_TRANSACTION_EXECUTOR

The address of the SiglessTransactionExecutor library used for delegate-calls.

address public immutable SIGLESS_TRANSACTION_EXECUTOR;

Functions

constructor

Constructs the module.

constructor(address _siglessTransactionExecutor);

Parameters

NameTypeDescription
_siglessTransactionExecutoraddressAddress of the library that will execute SafeTx via delegatecall.

execTransactionBatch

Executes the subset of safeTxBatch targeted to the current chain.

function execTransactionBatch(address account, SafeTxBatch calldata safeTxBatch, bytes calldata signatures)
    public
    returns (bool success);

Parameters

NameTypeDescription
accountaddressThe Safe account the batch applies to.
safeTxBatchSafeTxBatchBatch struct containing transactions and their intended chainIds.
signaturesbytesConcatenated owner signatures over the EIP-712 batch preimage.

Returns

NameTypeDescription
successboolTrue if all on-chain-eligible transactions executed without failures.

encodeTransactionBatchData

Encodes the SafeTxBatch into the pre-image for signature verification following the same structure hashing rules as Safe.

function encodeTransactionBatchData(SafeTxBatch calldata safeTxBatch) public view returns (bytes memory);

Parameters

NameTypeDescription
safeTxBatchSafeTxBatchBatch struct containing the transactions and their target chainIds.

Returns

NameTypeDescription
<none>bytesencodedData The ABI-encoded EIP-712 pre-image that is signed by Safe owners.

domainSeparator

Returns the domain separator used for batch hashing (chainId hard-coded to 1).

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

Returns

NameTypeDescription
separatorbytes32The EIP-712 domain separator.

Events

SafeTxFailed

Emitted when a transaction in the batch reverts on the current chain.

event SafeTxFailed(address indexed safe, uint256 indexed index);

Parameters

NameTypeDescription
safeaddressThe Safe account that attempted the execution.
indexuint256The index of the failing transaction within the batch.

Errors

MismatchedSubaccount


Custom errors

error MismatchedSubaccount();

Structs

SafeTxBatch

struct SafeTxBatch {
    address subaccount;
    SafeTx[] safeTxs;
    uint256[] chainIds;
}