> ## Documentation Index
> Fetch the complete documentation index at: https://docs.molpha.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Verify on Starknet

> Verify the same signed payload in a Cairo contract — no re-signing.

The Starknet Verifier is a faithful Cairo port of the EVM pipeline: a payload signed once by the Molpha node network verifies on both EVM and Starknet unmodified.

## Build the args

`buildStarknetVerifierArgs` maps a gateway `DataUpdateResult` onto the Cairo structs (`feed_id`/`value` as `u256`, `commitment` as `felt252`, `signature`/`signers_bitmap` as `u256`) with no starknet.js runtime dependency.

## Consumer contract

```cairo theme={null}
use verifier::interface::{
    DataUpdate, IVerifierDispatcher, IVerifierDispatcherTrait, SchnorrSignature,
};

fn consume_update(
    verifier: ContractAddress, data_update: DataUpdate, sig: SchnorrSignature,
) {
    let v = IVerifierDispatcher { contract_address: verifier };
    assert(v.verify(data_update, sig), 'molpha: not verified');

    // The payload is authentic. Apply YOUR policy before trusting `value`:
    //  - reject stale rounds (canonical_timestamp too old)
    //  - guard against replay (track last accepted (feed_id, timestamp))
    //  - sanity-bound data_update.value for the feed
}
```

## Integration checklist

* Treat both a **revert** and a **`false` return** as "not verified" — malformed/out-of-policy inputs revert; a well-formed-but-invalid signature returns `false`.
* Enforce timestamp freshness yourself — the contract does not.
* Prevent replay yourself — the same valid payload verifies forever.
* Pin the `registry_version` you expect, if your application requires it.

## Gas

Measured on `snforge 0.61` (10 nodes, `redundancy_buffer=2`, `signatures_required=3`, 5 signers): `verify` costs roughly **24.7M L2 gas**. Cost is not strictly linear in signer count — the selection derivation switches algorithms at `group_size > n/2`.

Full contract reference: [Starknet Verifier](/verifiers/starknet). Deployed address: [Deployments](/verifiers/deployments).
