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 State Connector system, 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
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 state connector
IFdcVerification fdc = ContractRegistry.getFdcVerification();
return fdc.verifyAddressValidity(transaction);
}
}