IFdcVerification
Interface for verifying Flare Data Connector (FDC) attestation requests.
Sourced from IFdcVerification.sol on GitHub.
Overview
The IFdcVerification interface provides methods to verify different types of attestations from the Flare Data Connector. Smart contracts can use these verification functions to validate proofs provided by the FDC, ensuring the authenticity and integrity of the external data being used.
Verification Functions
Each verification function takes a proof structure specific to the attestation type and returns a boolean indicating whether the proof is valid.
verifyAddressValidity
Verifies a proof for an address validity attestation.
function verifyAddressValidity(
struct IAddressValidity.Proof _proof
) external view returns (
bool _proved
);
Parameters
_proof: The address validity proof structure containing the merkle proof and response data
Returns
_proved: Boolean indicating if the proof is valid
verifyBalanceDecreasingTransaction
Verifies a proof for a balance decreasing transaction attestation.
function verifyBalanceDecreasingTransaction(
struct IBalanceDecreasingTransaction.Proof _proof
) external view returns (
bool _proved
);
Parameters
_proof: The balance decreasing transaction proof structure
Returns
_proved: Boolean indicating if the proof is valid
verifyConfirmedBlockHeightExists
Verifies a proof that a specified block height exists and is confirmed.
function verifyConfirmedBlockHeightExists(
struct IConfirmedBlockHeightExists.Proof _proof
) external view returns (
bool _proved
);
Parameters
_proof: The confirmed block height existence proof structure
Returns
_proved: Boolean indicating if the proof is valid
verifyEVMTransaction
Verifies a proof for an Ethereum Virtual Machine transaction.
function verifyEVMTransaction(
struct IEVMTransaction.Proof _proof
) external view returns (
bool _proved
);
Parameters
_proof: The EVM transaction proof structure
Returns
_proved: Boolean indicating if the proof is valid
verifyPayment
Verifies a proof for a payment transaction.
function verifyPayment(
struct IPayment.Proof _proof
) external view returns (
bool _proved
);
Parameters
_proof: The payment proof structure
Returns
_proved: Boolean indicating if the proof is valid
verifyReferencedPaymentNonexistence
Verifies a proof that a specific payment with reference did not occur within a given timeframe.
function verifyReferencedPaymentNonexistence(
struct IReferencedPaymentNonexistence.Proof _proof
) external view returns (
bool _proved
);
Parameters
_proof: The referenced payment nonexistence proof structure
Returns
_proved: Boolean indicating if the proof is valid
verifyWeb2Json
Verifies a proof for a Web2Json attestation (FDC-fetched HTTP response post-processed through JQ).
function verifyWeb2Json(
struct IWeb2Json.Proof _proof
) external view returns (
bool _proved
);
Parameters
_proof: The Web2Json proof structure
Returns
_proved: Boolean indicating if the proof is valid
Metadata accessors
fdcProtocolId
Returns the FDC protocol id used as the protocolId argument when querying IRelay.isFinalized(protocolId, votingRoundId).
Read this at runtime instead of hard-coding a literal — the value can change between network releases.
function fdcProtocolId() external view returns (uint8 _fdcProtocolId);
relay
Returns the IRelay contract address bound to this IFdcVerification deployment.
function relay() external view returns (IRelay);
Usage Example
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.25;
import {ContractRegistry} from "@flarenetwork/flare-periphery-contracts/coston2/ContractRegistry.sol";
import {IFdcVerification} from "@flarenetwork/flare-periphery-contracts/coston2/IFdcVerification.sol";
import {IAddressValidity} from "@flarenetwork/flare-periphery-contracts/coston2/IAddressValidity.sol";
interface IAddressRegistry {
function registerAddress(
IAddressValidity.Proof memory _transaction
) external;
}
contract AddressRegistry is IAddressRegistry {
string[] public verifiedAddresses;
function registerAddress(
IAddressValidity.Proof memory _transaction
) public {
// 1. FDC Logic
// Check that this AddressValidity has indeed been confirmed by the FDC
require(
isAddressValidityProofValid(_transaction),
"Invalid transaction proof"
);
// 2. Business logic
string memory provedAddress = _transaction.data.requestBody.addressStr;
verifiedAddresses.push(provedAddress);
}
function isAddressValidityProofValid(
IAddressValidity.Proof memory transaction
) public view returns (bool) {
// Use the library to get the verifier contract and verify that this transaction was proved by the FDC
IFdcVerification fdc = ContractRegistry.getFdcVerification();
return fdc.verifyAddressValidity(transaction);
}
}