# zkFP Inference

zkFP inference represents running inference on an AI or ML model in Vanna's decentralized filestore in an optimistic fashion with no proof directly generated to secure inference. However, the staking contract allows for the inference consumer to post a stake and submit a challenge to the inference within a challenge period. If challenged, the node that ran the inference generates a [ZK-SNARK](https://z.cash/learn/what-are-zk-snarks/) that acts as a fraud proof and will be validated by the nodes on the Vanna Network. On successful challenges, the inference node is slashed; on unsuccessful challenges, the challenger's stake is lost. The proof will be available on the data availability layer, which can be queried through our inference transaction explorer.

In order to run zkFP inference, you need to implement the ArbInference interface for inferCallZK.

**model** - The IPFS CID for the model

**input** - The input parameters to the inference request

{% code overflow="wrap" %}

```solidity
function inferCallZKFP(bytes memory model, bytes memory input) external returns (bytes memory);
```

{% endcode %}

Below is an example of a minimal smart contract that runs zkFP inference:

{% code title="ArbInference.sol" %}

```solidity
pragma solidity >=0.4.21 <0.9.0;

/// @title Infer Call
/// @notice This contract is used to run on-chain inference.
/// This custom contract will set on 0x000000000000000000000000000000000000011a since we set it in precompile.go.
interface ArbInference {
    function inferCall(bytes memory model, bytes memory input) external returns (bytes memory);
    function inferCallZK(bytes memory model, bytes memory input) external returns (bytes memory);
    function inferCallZKFP(bytes memory model, bytes memory input) external returns (bytes memory);
}
```

{% endcode %}

{% code title="zkFPInference.sol" %}

```solidity
pragma solidity ^0.8.18;

import "contracts/ArbInference.sol";

contract zkFPInference {
    string value;

    function zkfpInfer(
        string calldata modelName,
        string calldata inputData
    ) public {
        value = string(abi.encodePacked(ArbInference(address(0x11a)).inferCallZKFP(abi.encodePacked(modelName), abi.encodePacked(inputData))));
    }
    
    function getValue() public view returns (string memory) {
        return value;
    }
}
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vannalabs.ai/vanna-network/inference-modes/zkfp-inference.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
