Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

This article covers ERC7964, which proposes omitting chainId from the EIP712 domain and encoding chain-specific operations as an array so that operations across multiple chains can be securely verified with a single signature.

The following explanation is based on the proposal below.

Overview

ERC7964 proposes using EIP712 signatures to authorize operations across multiple blockchains with a single signature.

Ethereum signatures can include a chainId indicating the chain on which they are intended to be used. When this field is present, the signature is valid only on that chain. ERC7964 deliberately omits chainId from the signature domain. Instead, the message includes an array of chain-specific operations, and each chain verifies only the operations relevant to it.

The defining feature of the proposal is that it uses only standard EIP712 encoding. No specialized wallet support is needed: existing wallets supporting EIP712 can create and display cross-chain signatures. When signing, users can inspect all the operations and their target chains in their wallet.

Motivation

The problem with requiring a signature for each chain

Existing account abstraction solutions require separate signatures for each blockchain network. For example, to operate on both Ethereum and Arbitrum, a user must create one signature for each chain, for a total of two signatures. Operations on five chains require five signatures.

Account abstraction

Traditional Ethereum EOAs sign transactions directly using private keys. Account abstraction allows a smart contract to act as an account and customize its signature verification logic.

This constraint is particularly detrimental to the user experience in several cases.

  • Cross-chain intents When trading assets across chains, users may want to express an operation such as selling USDC on Ethereum and receiving ETH on Arbitrum as a single intent, yet they must provide a signature for each chain.
  • Multi-chain DAO governance Voting on a protocol deployed across several chains requires signing and voting separately for the DAO contract on each chain.
  • Unified account management If the same smart account is deployed on multiple chains, adding a signer or changing the threshold must be done separately for each chain.
  • Cross-chain social recovery Even when users want to recover an account across multiple chains in one operation, they need a signature for each chain.

Limitations of existing approaches

Existing approaches to solving the cross-chain signature problem can broadly be divided into two methods.

The Merkle tree approach encodes each chain's operation as a leaf in a Merkle tree and signs the root. Standard EIP712 wallets, however, cannot display the leaves of a Merkle tree. Users sign an opaque Merkle root hash rather than inspecting the actual operations in their wallet. If a malicious application embeds an unauthorized operation in a leaf, users cannot detect it.

Another approach defines a custom encoding scheme, but adoption has been limited because it requires special wallet support.

ERC7964 addresses this problem using standard EIP712 array encoding. All operations are displayed transparently as part of the message, allowing users to review them in their wallet before signing.

Specification

Defining a cross-chain domain

EIP712 signatures include identifying information in a domain separator (EIP712Domain). Typically, chainId is specified to make the signature valid only on a specific chain.

ERC7964 omits the chainId field from the domain separator. The EIP712 specification already defines chainId as optional, so omitting it remains compliant. Omitting chainId indicates that the signature is intended for use across multiple chains.

Typically, the domain separator includes only name and version. The verifyingContract field can be used to bind the signature to an application deterministically deployed at the same address on every chain. In this case, the contract address need not be specified in each chain-specific struct.

The following is an example of a cross-chain domain definition.

javascript
EIP712Domain: [
  { name: "name", type: "string" },
  { name: "version", type: "string" }
  // chainId は省略 → クロスチェーン署名
]

Since chainId is omitted, this signature can be submitted on any chain. However, the operations executed on each chain are specified by the array in the message itself; the signature does not authorize arbitrary operations.

Message array encoding

Cross-chain operations are encoded as an array of message structs. Each element represents an operation on one chain and includes information such as the chain ID, target contract address, and execution data.

The following is an example of a struct defining a chain-specific operation.

javascript
ChainOperation: [
  { name: "domain", type: "EIP712ChainDomain" },
  { name: "target", type: "address" },
  { name: "value", type: "uint256" },
  { name: "data", type: "bytes" }
],
EIP712ChainDomain: [
  { name: "chainId", type: "uint256" },
  { name: "verifyingContract", type: "address" }
]

Each chain-specific struct contains an EIP712ChainDomain. Including chainId and verifyingContract identifies the chain and contract targeted by each operation.

The key is the two-level design: the main domain (EIP712Domain) omits chainId, while the domain struct for each operation (EIP712ChainDomain) includes it. This makes the signature as a whole chain-independent while binding each individual operation to a specific chain.

Under the EIP712 specification, arrays are encoded as follows.

text
keccak256(encodeData(element[0]) ‖ encodeData(element[1]) ‖ ... ‖ encodeData(element[n]))

Each element is a struct, so it is hashed recursively. In practice, compute the struct hash (bytes32, 32 bytes) of each chain's operation, concatenate the hashes, and hash them using keccak256.

The following Mermaid diagram illustrates the message array encoding flow.

graph TD
    A["ChainOperation[0]<br/>chainId: 1 (Ethereum)"] --> D["hashStruct(op[0])<br/>= bytes32 ハッシュ"]
    B["ChainOperation[1]<br/>chainId: 42161 (Arbitrum)"] --> E["hashStruct(op[1])<br/>= bytes32 ハッシュ"]
    C["ChainOperation[2]<br/>chainId: 137 (Polygon)"] --> F["hashStruct(op[2])<br/>= bytes32 ハッシュ"]
    D --> G["abi.encodePacked(hash0, hash1, hash2)"]
    E --> G
    F --> G
    G --> H["keccak256(...)<br/>= 配列ハッシュ"]

Each chain's operation is hashed individually, and the results are combined into a single array hash.

Struct hash

The signature is computed over the entire main struct, not just the array of operations. In addition to the operations array, the main struct can contain shared fields such as nonce (a replay protection value) and deadline (an expiration time).

The following is an example of a main struct for a cross-chain intent.

javascript
bytes32 constant CROSSCHAIN_INTENT_TYPEHASH = keccak256(
    "CrossChainIntent(ChainOperation[] operations,uint256 nonce,uint256 deadline)ChainOperation(EIP712ChainDomain domain,address target,uint256 value,bytes data)EIP712ChainDomain(uint256 chainId,address verifyingContract)"
);

fullStructHash = keccak256(abi.encode(
    CROSSCHAIN_INTENT_TYPEHASH,
    keccak256(abi.encodePacked(chainOperationsArray)),
    nonce,
    deadline
));

CROSSCHAIN_INTENT_TYPEHASH is a fixed hash identifying the type of the main struct. This type hash also includes the definitions of nested structs such as ChainOperation and EIP712ChainDomain.

The main struct hash is computed by encoding the type hash, operations array hash, nonce, and deadline, and hashing the result using keccak256. The application uses the same type hash on every chain where it is deployed.

The application can freely define the main struct's primaryType, such as CrossChainIntent or MultiChainVote. The proposal does not mandate a specific primaryType, allowing flexible implementations.

On-chain verification

To verify a cross-chain signature, an application must attach metadata to the signature data. The proposal defines a specific binary encoding format to support standard ECDSA verification and ERC1271 isValidSignature calls.

ERC1271

This standard interface allows contract wallets to verify signatures. It enables a smart contract, rather than an EOA (Externally Owned Account), to determine whether a signature is valid.

Signature encoding structure

Signature data is encoded using the following binary structure.

Field Size Description
magic 9 bytes Fixed value 0x796479647964796479 identifying a cross-chain signature
fields 1 byte Types of fields included in the EIP712 domain (per ERC5267)
structIndex 2 bytes Index in the operations array corresponding to the current chain
application 20 bytes Address of the ERC5267 contract providing EIP712 domain information
structsArrayOffset 32 bytes Byte offset to the start of structsArray
structsArrayLength 32 bytes Number of elements in structsArray
structsArray N × 32 bytes Array of struct hashes for chain-specific operations
crossChainSignatureOffset 32 bytes Byte offset to the start of crossChainSignature
crossChainSignatureLength 32 bytes Length of crossChainSignature in bytes
crossChainSignature Variable Actual signature data

ERC5267

This standard interface retrieves EIP712 domain separator information. Calling eip712Domain() returns domain information such as name, version, chainId, and verifyingContract.

The first 32 bytes contain the packed header (magic, fields, structIndex, and application), followed by the ABI-encoded structsArray and crossChainSignature.

javascript
bytes32 header = bytes32(abi.encodePacked(
    CrossChainSignatureChecker.ERC7964_MAGIC,
    fields,
    structIndex,
    address(application)
));
abi.encode(header, structsArray, crossChainSignature);
Verification flow

The application identifies a cross-chain signature by checking whether its first 9 bytes match the magic value 0x796479647964796479. If it is identified as a cross-chain signature, verification proceeds as follows.

The following Mermaid diagram illustrates the overall verification flow.

sequenceDiagram
    participant App as アプリケーション
    participant Sig as 署名データ
    participant ERC5267 as ERC5267コントラクト
    participant Verify as 署名検証

    App->>Sig: 1. メタデータをパース
    App->>App: 2. structsArray[structIndex]と<br/>現在のチェーンの操作ハッシュを照合
    App->>ERC5267: 3. eip712Domain()を呼び出し
    ERC5267-->>App: ドメイン情報を返す
    App->>App: 4. ドメイン+メイン構造体ハッシュ+<br/>配列ハッシュからEIP712ハッシュを再構築
    App->>Verify: 5. crossChainSignatureを検証
    Verify-->>App: 検証結果
  1. Parse the metadata (fields, structIndex, application, structsArray, and crossChainSignature) from the signature data.
  2. Check whether structsArray[structIndex] matches the operation hash for the current chain.
  3. Retrieve EIP712 domain information from the ERC5267 contract specified by application.
  4. Reconstruct the full EIP712 hash from the domain information, main struct hash, and array hash.
  5. Verify crossChainSignature against the reconstructed hash.

Wallet display

Because ERC7964 uses only standard EIP712 encoding, existing wallets supporting EIP712 can display cross-chain messages without modification.

The wallet's signing screen displays the operations array as part of the message. Users can inspect the operations to be executed on each chain before signing, rather than having unauthorized operations concealed from them.

Wallet developers can further improve the user experience by grouping operations by chain or displaying chain names (such as Ethereum and Arbitrum) instead of numeric chain IDs.

Additional considerations

Comparing arrays with Merkle trees

Two approaches to cross-chain signatures are the array approach adopted by ERC7964 and the existing Merkle tree approach. The two have different trade-offs.

The following figure illustrates the differences between them.

comparison.png

Transparency

The main advantage of the array approach is transparency. With the Merkle tree approach, users sign a Merkle root hash and cannot inspect the actual operations in a standard wallet. To display all leaves, the wallet needs additional logic to retrieve the leaves from the application, verify the construction of the Merkle tree, display every operation, and check for unauthorized operations. In other words, users need to trust that the application provides the leaves correctly.

With the array approach, every operation is displayed as a standard part of the EIP712 message. No special wallet support is needed, and the structure does not permit unauthorized operations to be hidden within an opaque root.

On-chain overhead

In terms of data size, the Merkle tree approach is theoretically more efficient. However, for typical cross-chain operations involving 2–5 chains, the difference is small.

Number of chains Array approach (N × 32 bytes) Merkle tree approach (⌈log₂(N)⌉ × 32 bytes) Difference
2 64 bytes (2 × 32) 32 bytes (1 × 32) 32 bytes (one hash)
3 96 bytes (3 × 32) 64 bytes (2 × 32) 32 bytes (one hash)
4 128 bytes (4 × 32) 64 bytes (2 × 32) 64 bytes (two hashes)
5 160 bytes (5 × 32) 96 bytes (3 × 32) 64 bytes (two hashes)
8 256 bytes (8 × 32) 96 bytes (3 × 32) 160 bytes (five hashes)

For 2–5 chains, the Merkle tree approach saves only 32–64 bytes of data (one or two hashes). The Merkle tree approach becomes significantly more advantageous at eight or more chains. However, operations across that many chains are rare, and splitting them into multiple signatures may be more appropriate for user comprehension and troubleshooting.

Why omit chainId?

One alternative would be setting chainId to 0, but ERC7964 omits the field entirely. Setting it to 0 would assign that value the special meaning of cross-chain use. Omitting the field instead clearly communicates that no chain ID is specified, so the domain is chain-independent. All domain fields in EIP712 are optional, making omission valid under the specification.

Signature encoding design

The signature encoding format is designed to minimize calldata (data sent to a contract) and memory overhead.

The magic value (0x796479647964796479) occupies 9 bytes. Together with fields (1 byte), structIndex (2 bytes), and application (20 bytes), it fits exactly into 32 bytes (one word). Although the 9-byte magic value is shorter than a 32-byte hash, the probability of accidentally generating a valid ECDSA or ERC1271 signature matching these first 9 bytes is 2^-72 (approximately one in 4.7 × 10^21), making accidental collisions negligible in practice.

The application address points to any contract implementing the ERC5267 eip712Domain() function. It does not need to execute the operations itself; it may be a dedicated contract that only provides EIP712 domain information. A separate immutable domain separator contract can also be deployed to ensure consistent domain information across every chain.

Compatibility

Because ERC7964 uses standard EIP712 without extending or modifying it, existing EIP712-compatible wallets and applications can handle cross-chain signatures. However, to understand cross-chain-specific semantics, applications must implement the verification pattern defined by the proposal.

As a safe default, applications that verify signatures using a domain containing a specific chainId automatically reject cross-chain signatures whose domain omits it. Applications that do not support cross-chain signatures will reject them, avoiding unintended behavior from accepting such signatures. Applications that want to support cross-chain signatures must explicitly implement the proposal's verification pattern.

Security

Cross-chain replay

ERC7964 intentionally allows signatures to be reused on multiple chains. Binding a signature to the user's account address through the verifyingContract field prevents unauthorized use on another user's account. To prevent replay on the same chain, however, applications must implement their own replay protection by including fields such as nonce (a one-time value) and deadline (an expiration time) in the message.

Account verification

The application verifying a signature must check whether the signer's account exists on the current chain. For example, accepting a signature from an account on Ethereum on Polygon could authorize operations for an account that does not exist there. For undeployed counterfactual accounts (accounts whose future address is known but whose contract has not yet been deployed), use ERC6492 for signature verification.

See the following article for more about ERC6492.

ERC6492: Signature Verification for Undeployed Contract Accounts

Differences in code and state

Even at the same address, the code and state of a contract can differ from one chain to another. A successful isValidSignature() call (the ERC1271 signature verification function) on one chain can fail on another because of state differences or chain-specific logic. For example, a nonce included in a message may already have been consumed on one chain. Applications must handle signature verification failures appropriately rather than assuming uniform behavior across every chain.

Partial execution risk

Cross-chain signatures do not guarantee atomic execution (all operations succeeding or all failing). A signature may be verified and an operation executed on some chains, while operations on other chains fail. For example, in a cross-chain trade, an asset could be sold on one chain while acquisition of the asset on another chain fails.

Network congestion and differences in block production rates may also cause cross-chain operations to execute in an unintended order. Applications must either design operations to be order-independent or implement an appropriate ordering mechanism. Providing a refund mechanism for partial failures is also recommended.

Signature expiration

A signature without an explicit expiration time is theoretically valid indefinitely. An operation that was not executed on some chains may consequently execute at an unexpected time later. To prevent this, the message should include a deadline or validUntil field.

Before signing a cross-chain message, users should review every operation in the message array, check that each targets the correct chain ID, and verify the amounts and addresses on each chain. Users should also understand that operations execute independently on each chain and are not atomic.

Reference implementation

The CrossChainSignatureChecker library

The following is a reference implementation of a library for verifying cross-chain signatures. It uses OpenZeppelin's SignatureChecker, MessageHashUtils, IERC5267, and related components.

CrossChainSignatureChecker.sol
import {SignatureChecker} from "@openzeppelin/contracts/utils/cryptography/SignatureChecker.sol";
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {IERC5267} from "@openzeppelin/contracts/interfaces/IERC5267.sol";
import {Calldata} from "@openzeppelin/contracts/utils/Calldata.sol";

library CrossChainSignatureChecker {
    bytes9 internal constant ERC7964_MAGIC = 0x796479647964796479;

    function isValidCrossChainSignatureNow(
        address signer,
        bytes32 hash,
        bytes calldata erc7964Signature,
        function(bytes32) internal view returns (bytes32) structHash
    ) internal view returns (bool) {
        (
            bool success,
            bytes1 fields,
            uint16 structIndex,
            address application,
            bytes32[] calldata structsArray,
            bytes calldata crossChainSignature
        ) = parseCrossChainSignature(erc7964Signature);
        if (!success || structsArray[structIndex] != hash) return false;

        string memory name;
        string memory version;
        uint256 chainId;
        address verifyingContract;
        bytes32 domainSalt;
        (, name, version, chainId, verifyingContract, domainSalt, ) =
            IERC5267(application).eip712Domain();

        bytes32 typedHash = MessageHashUtils.toTypedDataHash(
            MessageHashUtils.toDomainSeparator(
                fields, name, version, chainId, verifyingContract, domainSalt
            ),
            structHash(keccak256(abi.encodePacked(structsArray)))
        );
        return SignatureChecker.isValidSignatureNowCalldata(
            signer, typedHash, crossChainSignature
        );
    }

    function parseCrossChainSignature(
        bytes calldata erc7964Signature
    )
        internal
        pure
        returns (
            bool success,
            bytes1 fields,
            uint16 structIndex,
            address application,
            bytes32[] calldata structsArray,
            bytes calldata crossChainSignature
        )
    {
        if (
            erc7964Signature.length < 0x9f ||
            bytes9(erc7964Signature[0:9]) != ERC7964_MAGIC
        ) {
            return (
                false, 0, 0, address(0),
                _empty32BytesArrayCalldata(), Calldata.emptyBytes()
            );
        }
        fields = erc7964Signature[9];
        structIndex = uint16(bytes2(erc7964Signature[10:]));
        application = address(bytes20(erc7964Signature[12:]));

        uint256 structsArrayOffset = uint256(bytes32(erc7964Signature[0x20:]));
        uint256 structsArrayDataOffset = structsArrayOffset + 32;
        if (
            structsArrayOffset < 0x60 ||
            structsArrayDataOffset > erc7964Signature.length
        ) {
            return (
                false, 0, 0, address(0),
                _empty32BytesArrayCalldata(), Calldata.emptyBytes()
            );
        }
        uint256 structsArrayLength = uint256(
            bytes32(erc7964Signature[structsArrayOffset:])
        );
        if (
            structsArrayDataOffset + structsArrayLength * 32 >
            erc7964Signature.length
        ) {
            return (
                false, 0, 0, address(0),
                _empty32BytesArrayCalldata(), Calldata.emptyBytes()
            );
        }

        uint256 crossChainSignatureOffset =
            structsArrayDataOffset + structsArrayLength * 32;
        uint256 crossChainSignatureDataOffset = crossChainSignatureOffset + 32;
        if (
            crossChainSignatureOffset < 0x60 ||
            crossChainSignatureDataOffset > erc7964Signature.length
        ) {
            return (
                false, 0, 0, address(0),
                _empty32BytesArrayCalldata(), Calldata.emptyBytes()
            );
        }
        uint256 crossChainSignatureLength = uint256(
            bytes32(erc7964Signature[crossChainSignatureOffset:])
        );
        if (
            crossChainSignatureDataOffset + crossChainSignatureLength >
            erc7964Signature.length
        ) {
            return (
                false, 0, 0, address(0),
                _empty32BytesArrayCalldata(), Calldata.emptyBytes()
            );
        }

        assembly ("memory-safe") {
            structsArray.offset := add(
                erc7964Signature.offset, structsArrayDataOffset
            )
            structsArray.length := structsArrayLength
        }
        crossChainSignature = erc7964Signature[
            crossChainSignatureDataOffset:
            crossChainSignatureDataOffset + crossChainSignatureLength
        ];
        return (
            true, fields, structIndex, application,
            structsArray, crossChainSignature
        );
    }

    function _empty32BytesArrayCalldata()
        private
        pure
        returns (bytes32[] calldata result)
    {
        assembly ("memory-safe") {
            result.offset := 0
            result.length := 0
        }
    }
}

isValidCrossChainSignatureNow takes the signer address, the operation hash for the current chain, the encoded signature, and a callback for computing the main struct hash. Internally, it parses the signature, checks that structsArray[structIndex] matches the supplied hash, reconstructs the EIP712 hash using domain information retrieved through ERC5267, and verifies the signature.

parseCrossChainSignature parses the encoded signature data and extracts the header (fields, structIndex, and application) and dynamic data (structsArray and crossChainSignature). It checks data integrity at each step, including the validity of offsets and array length overflow, returning success = false for invalid data.

Cross-chain intent example

The following example shows a user executing a cross-chain trade to sell USDC on Ethereum and receive ETH on Arbitrum.

Message to sign
javascript
{
  types: {
    EIP712Domain: [
      { name: "name", type: "string" },
      { name: "version", type: "string" }
      // chainId は省略
    ],
    CrossChainIntent: [
      { name: "operations", type: "ChainOperation[]" },
      { name: "nonce", type: "uint256" },
      { name: "deadline", type: "uint256" }
    ],
    ChainOperation: [
      { name: "domain", type: "EIP712ChainDomain" },
      { name: "target", type: "address" },
      { name: "value", type: "uint256" },
      { name: "data", type: "bytes" }
    ],
    EIP712ChainDomain: [
      { name: "chainId", type: "uint256" },
      { name: "verifyingContract", type: "address" }
    ]
  },
  primaryType: "CrossChainIntent",
  domain: {
    name: "CrossChainDEX",
    version: "1"
  },
  message: {
    operations: [
      {
        domain: {
          chainId: 1,                    // Ethereum
          verifyingContract: "0x123321..." // Ethereum上のアカウント
        },
        target: "0xA0b86a33E6776885F5Db...", // USDCコントラクト
        value: 0,
        data: "0xa9059cbb..."               // transfer(settler, 1000 USDC)
      },
      {
        domain: {
          chainId: 42161,                // Arbitrum
          verifyingContract: "0x123321..." // Arbitrum上のアカウント
        },
        target: "0xArbitrumSettler...",
        value: 0,
        data: "0x3ccfd60b..."               // claim(最低0.5 ETH)
      }
    ],
    nonce: 42,
    deadline: 1704067200
  }
}

The wallet displays this message so the user can review the complete operation: send USDC on Ethereum and receive at least 0.5 ETH on Arbitrum.

On-chain verification contract
CrossChainDEX.sol
import {EIP712} from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
import {Nonces} from "@openzeppelin/contracts/utils/Nonces.sol";
import {CrossChainSignatureChecker} from "./CrossChainSignatureChecker.sol";

contract CrossChainDEX is EIP712, Nonces {
    using CrossChainSignatureChecker for address;

    bytes32 public constant EIP712_CHAIN_DOMAIN_TYPEHASH =
        keccak256(
            "EIP712ChainDomain(uint256 chainId,address verifyingContract)"
        );
    bytes32 public constant CHAIN_OPERATION_TYPEHASH =
        keccak256(
            "ChainOperation(EIP712ChainDomain domain,address target,"
            "uint256 value,bytes data)"
            "EIP712ChainDomain(uint256 chainId,address verifyingContract)"
        );
    bytes32 public constant CROSSCHAIN_INTENT_TYPEHASH =
        keccak256(
            "CrossChainIntent(ChainOperation[] operations,"
            "uint256 nonce,uint256 deadline)"
            "ChainOperation(EIP712ChainDomain domain,address target,"
            "uint256 value,bytes data)"
            "EIP712ChainDomain(uint256 chainId,address verifyingContract)"
        );

    mapping(bytes32 operationHash => uint256) private _deadlines;

    constructor() EIP712("CrossChainDEX", "1") {}

    function executeIntent(
        address account,
        ChainOperation calldata currentOp,
        uint256 nonce,
        uint256 deadline,
        bytes calldata signature
    ) external {
        bytes32 currentOpHash = _structHash(currentOp);

        _useCheckedNonce(account, nonce);
        _deadlines[currentOpHash] = deadline;

        require(
            account.isValidCrossChainSignatureNowCalldata(
                currentOpHash,
                signature,
                _crossChainStructHash
            ),
            "Invalid signature"
        );

        (bool success, ) = currentOp.target.call{value: currentOp.value}(
            currentOp.data
        );
        require(success, "Execution failed");
    }

    function _crossChainStructHash(
        bytes32 operationsHash
    ) internal view returns (bytes32) {
        return keccak256(abi.encode(
            CROSSCHAIN_INTENT_TYPEHASH,
            operationsHash,
            nonces(account),
            _deadlines[operationsHash]
        ));
    }

    function _structHash(
        ChainOperation calldata op
    ) internal view returns (bytes32) {
        return keccak256(abi.encode(
            CHAIN_OPERATION_TYPEHASH,
            keccak256(abi.encode(
                EIP712_CHAIN_DOMAIN_TYPEHASH,
                block.chainid,
                address(this)
            )),
            op.target,
            op.value,
            keccak256(op.data)
        ));
    }
}

This reference implementation is simplified to demonstrate the concept. In a real implementation, the account reference inside _crossChainStructHash must be obtained appropriately from storage variables or the execution context.

executeIntent first computes the operation hash for the current chain, consumes the nonce, and records the deadline. It then uses CrossChainSignatureChecker to verify the cross-chain signature.

Each chain receives only the full data for its own operation. Operations for other chains are included in structsArray as 32-byte hashes, minimizing the amount of data sent to the contract. For example, the settler contract on Arbitrum uses the same signature and verifies it with structIndex set to 1.

Multi-chain governance example

This example shows a DAO member voting on protocol instances across multiple chains in a single operation.

javascript
{
  types: {
    EIP712Domain: [
      { name: "name", type: "string" },
      { name: "version", type: "string" }
    ],
    MultiChainVote: [
      { name: "votes", type: "ChainVote[]" },
      { name: "nonce", type: "uint256" }
    ],
    ChainVote: [
      { name: "domain", type: "EIP712ChainDomain" },
      { name: "proposalId", type: "uint256" },
      { name: "support", type: "uint8" },
      { name: "reason", type: "string" }
    ],
    EIP712ChainDomain: [
      { name: "chainId", type: "uint256" },
      { name: "verifyingContract", type: "address" }
    ]
  },
  primaryType: "MultiChainVote",
  domain: {
    name: "MultiChainDAO",
    version: "1"
  },
  message: {
    votes: [
      {
        domain: {
          chainId: 1,                    // Ethereum
          verifyingContract: "0x123321..." // EthereumのDAOコントラクト
        },
        proposalId: 42,
        support: 1,  // 賛成
        reason: "This upgrade improves security"
      },
      {
        domain: {
          chainId: 137,                  // Polygon
          verifyingContract: "0x321321..." // PolygonのDAOコントラクト
        },
        proposalId: 42,
        support: 1,  // 賛成
        reason: "This upgrade improves security"
      }
    ],
    nonce: 7
  }
}

A single signature can be used to vote in both the DAO on Ethereum and the DAO on Polygon. Each chain's DAO contract receives the same signature and verifies and executes only the voting data for its own chain.

Unified account management example

This example adds a new signer to a multisig wallet across multiple chains in one operation.

javascript
{
  types: {
    EIP712Domain: [
      { name: "name", type: "string" },
      { name: "version", type: "string" }
    ],
    MultiChainAccountUpdate: [
      { name: "updates", type: "AccountUpdate[]" },
      { name: "nonce", type: "uint256" }
    ],
    AccountUpdate: [
      { name: "domain", type: "EIP712ChainDomain" },
      { name: "operation", type: "uint8" },
      { name: "signerData", type: "bytes" },
      { name: "threshold", type: "uint256" }
    ],
    EIP712ChainDomain: [
      { name: "chainId", type: "uint256" },
      { name: "verifyingContract", type: "address" }
    ]
  },
  primaryType: "MultiChainAccountUpdate",
  domain: {
    name: "MultiChainMultisig",
    version: "1"
  },
  message: {
    updates: [
      {
        domain: {
          chainId: 1,
          verifyingContract: "0x123321..."
        },
        operation: 0,  // addSigner
        signerData: "0x0102...1f20",
        threshold: 3
      },
      {
        domain: {
          chainId: 137,
          verifyingContract: "0x123321..."
        },
        operation: 0,  // addSigner
        signerData: "0x0102...1f20",
        threshold: 3
      },
      {
        domain: {
          chainId: 42161,
          verifyingContract: "0x123321..."
        },
        operation: 0,  // addSigner
        signerData: "0x0102...1f20",
        threshold: 3
      }
    ],
    nonce: 42
  }
}

For a multisig wallet deployed at the same address on Ethereum, Polygon, and Arbitrum, a single signature can authorize adding a new signer and updating the threshold to 3 on all three chains.

Cross-chain social recovery example

This example shows guardians performing recovery after a user loses access to an account.

javascript
{
  types: {
    EIP712Domain: [
      { name: "name", type: "string" },
      { name: "version", type: "string" }
    ],
    MultiChainRecovery: [
      { name: "recoveries", type: "ChainRecovery[]" },
      { name: "nonce", type: "uint256" }
    ],
    ChainRecovery: [
      { name: "domain", type: "EIP712ChainDomain" },
      { name: "newOwner", type: "address" }
    ],
    EIP712ChainDomain: [
      { name: "chainId", type: "uint256" },
      { name: "verifyingContract", type: "address" }
    ]
  },
  primaryType: "MultiChainRecovery",
  domain: {
    name: "CrossChainSocialRecovery",
    version: "1"
  },
  message: {
    recoveries: [
      {
        domain: {
          chainId: 1,
          verifyingContract: "0x123321..."  // Ethereumのリカバリモジュール
        },
        newOwner: "0x9999999999999999999999999999999999999999"
      },
      {
        domain: {
          chainId: 137,
          verifyingContract: "0x321321..."  // Polygonのリカバリモジュール
        },
        newOwner: "0x9999999999999999999999999999999999999999"
      },
      {
        domain: {
          chainId: 42161,
          verifyingContract: "0x432432..."  // Arbitrumのリカバリモジュール
        },
        newOwner: "0x9999999999999999999999999999999999999999"
      }
    ],
    nonce: 1
  }
}

A guardian can authorize recovery on all three chains with one signature. Three guardians each sign (a 3-of-5 threshold). Once enough signatures are collected, recovery with a delay is scheduled in each chain's recovery module. During the delay, unauthorized recovery can be detected and canceled.

References

Conclusion

This article covered ERC7964, a cross-chain EIP712 signing scheme for authorizing operations across multiple chains with a single signature.