Solidity Verifier Example

Publish commitments and wire on-chain verification.

This example shows a lightweight on-chain registry with optional verification calls.

Commitment registry

SOLIDITY
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract FairseqRegistry {
    event BatchCommitted(bytes32 indexed batchHash, bytes32 indexed proofHash);

    function commit(bytes32 batchHash, bytes32 proofHash) external {
        emit BatchCommitted(batchHash, proofHash);
    }
}

Optional verifier interface

SOLIDITY
interface IFairseqVerifier {
    function verify(
        bytes32 proofHash,
        bytes calldata proof
    ) external view returns (bool);
}

Integration example

SOLIDITY
contract FairDEX {
    IFairseqVerifier public verifier;

    modifier onlyFairOrdering(bytes32 proofHash, bytes calldata proof) {
        require(verifier.verify(proofHash, proof), "Unfair ordering");
        _;
    }

    function executeTrades(
        Trade[] calldata trades,
        bytes32 proofHash,
        bytes calldata proof
    ) external onlyFairOrdering(proofHash, proof) {
        // Execute with guaranteed fair ordering
    }
}

Expected outcome

  • Batch commitments are immutable on-chain.
  • Proof bytes remain off-chain for lower gas cost.
Was this page helpful? /
Back to docs