Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Solidity SDK

As a supplement to OpenVM, we provide a Solidity SDK containing OpenVM verifier contracts generated at official release commits using the cargo openvm setup command. The contracts are built at every minor release as OpenVM guarantees verifier backward compatibility across patch releases.

Note that these builds are for the default aggregation VM config which should be sufficient for most users. If you use a custom config, you will need to manually generate the verifier contract using the OpenVM SDK.

Installation

To install the Solidity SDK as a dependency into your forge project, run the following command:

forge install openvm-org/openvm-solidity-sdk

Usage

Once you have the SDK installed, you can import the SDK contracts into your Solidity project:

import "openvm-solidity-sdk/v1.2/OpenVmHalo2Verifier.sol";

If you are using an already-deployed verifier contract, you can simply import the IOpenVmHalo2Verifier interface:

import { IOpenVmHalo2Verifier } from "openvm-solidity-sdk/v1.2/interfaces/IOpenVmHalo2Verifier.sol";

contract MyContract {
    function myFunction() public view {
        // ... snip ...

        IOpenVmHalo2Verifier(verifierAddress)
            .verify(publicValues, proofData, appExeCommit, appVmCommit);

        // ... snip ...
    }
}

The arguments to the verify function are the fields in the EVM Proof JSON Format. Since the builds use the default aggregation VM config, the number of public values is fixed to 32.

If you want to import the verifier contract into your own repository for testing purposes, note that it is locked to Solidity version 0.8.19. If your project uses a different version, the import may not compile. As a workaround, you can compile the contract separately and use vm.etch() to inject the raw bytecode into your tests.

Deployment

To deploy an instance of a verifier contract, you can clone the repo and simply use forge create:

git clone --recursive https://github.com/openvm-org/openvm-solidity-sdk.git
cd openvm-solidity-sdk
forge create src/v1.2/OpenVmHalo2Verifier.sol:OpenVmHalo2Verifier --rpc-url $RPC --private-key $PRIVATE_KEY --broadcast

We recommend a direct deployment from the SDK repo since the proper compiler configurations are all pre-set.