Deployment & Operations

Deploying the Contract

The Verifier contract must inherit VerifierBase and implement the IVerifier interface:

contract MyVerifier is VerifierBase {
    address public immutable SPEC;

    constructor(address specAddress) VerifierBase("MyVerifier", "1") {
        require(specAddress != address(0), "spec cannot be zero");
        SPEC = specAddress;
    }

    function spec() external view override returns (address) { return SPEC; }
    function description() external pure override returns (string memory) { return "..."; }
}

owner() and signer() are separate roles in the current VerifierBase design: owner() is the cold key for registration and contract management, while signer() is the hot key used to sign quotes and submit verification results.


Registering on the Platform

Signer → get_nonce(contract_address)
Signer signs "SyncTx: <nonce>" with private key
Signer → register_verifier(contract_address, signature, chain_id)

# Platform validation:
# 1. Recover address from signature
# 2. Call signer() on-chain to confirm the recovered address == contract signer
# 3. Read owner() and spec().name() / version() / description() on-chain
# 4. Write to database → return auth_token (bound to contract_address)
  • Each contract address is registered independently; the same signer can register multiple Verifiers
  • The token is used for authentication when the off-chain service communicates with the platform

Off-Chain Service

The off-chain service needs to handle two types of messages pushed by the platform:

request_sign — Quote Request

Triggered when a Trader requests a quote from the Verifier. Upon receipt, decide whether to accept and return an EIP-712 signature as a commitment:

The following is pseudocode, not actual implementation code.

def handle_request_sign(msg):
    params = msg["params"]
    deadline = msg["deadline"]

    # Decision: whether to accept this verification task
    if not should_accept(params):
        return {"accepted": False}

    # Price and generate EIP-712 signature
    fee = calculate_fee(params)
    sig = sign_eip712(verifier_address, params, fee, deadline)

    return {"accepted": True, "fee": fee, "sig": sig}

notify_verify — Verification Notification

After a Trader initiates requestVerification on-chain, the platform notifies the Verifier to execute verification:

The following is pseudocode, not actual implementation code.

def handle_notify_verify(msg):
    deal_contract = msg["dealContract"]
    deal_index = msg["dealIndex"]
    verification_index = msg["verificationIndex"]

    # Read verification params from chain (never trust off-chain data)
    params = contract.verificationParams(deal_index, verification_index)

    # Execute verification off-chain
    result, reason = verify(params["specParams"])

    # Submit result on-chain
    contract.reportResult(
        deal_contract, deal_index, verification_index,
        result, reason, params["fee"]
    )
    # result > 0 → Verification passed
    # result < 0 → Verification failed
    # result = 0 → Inconclusive, enters Settling