|
1 | | -## Foundry |
| 1 | +# OpenVM Solidity SDK |
2 | 2 |
|
3 | | -**Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.** |
| 3 | +This repo houses OpenVM verifier contracts generated on official release commits of the [openvm](https://github.com/openvm-org/openvm) repo with the default VM config using the `cargo-openvm` cli tool. Advanced VM configurations may require their own generations. |
4 | 4 |
|
5 | | -Foundry consists of: |
| 5 | +## Installation |
6 | 6 |
|
7 | | -- **Forge**: Ethereum testing framework (like Truffle, Hardhat and DappTools). |
8 | | -- **Cast**: Swiss army knife for interacting with EVM smart contracts, sending transactions and getting chain data. |
9 | | -- **Anvil**: Local Ethereum node, akin to Ganache, Hardhat Network. |
10 | | -- **Chisel**: Fast, utilitarian, and verbose solidity REPL. |
| 7 | +To install `openvm-solidity-sdk` as a dependency in your forge project, run the following: |
11 | 8 |
|
12 | | -## Documentation |
13 | | - |
14 | | -https://book.getfoundry.sh/ |
15 | | - |
16 | | -## Usage |
17 | | - |
18 | | -### Build |
19 | | - |
20 | | -```shell |
21 | | -$ forge build |
22 | | -``` |
23 | | - |
24 | | -### Test |
25 | | - |
26 | | -```shell |
27 | | -$ forge test |
| 9 | +```bash |
| 10 | +forge install openvm-org/openvm-solidity-sdk |
28 | 11 | ``` |
29 | 12 |
|
30 | | -### Format |
31 | | - |
32 | | -```shell |
33 | | -$ forge fmt |
34 | | -``` |
35 | | - |
36 | | -### Gas Snapshots |
| 13 | +## Usage |
37 | 14 |
|
38 | | -```shell |
39 | | -$ forge snapshot |
40 | | -``` |
| 15 | +If you are using a deployed instance of the verifier contract, then you can import the interfaces in your contract directly. |
41 | 16 |
|
42 | | -### Anvil |
| 17 | +```solidity |
| 18 | +import { IOpenVmHalo2Verifier } from "openvm-solidity-sdk/v1.1.1/interfaces/IOpenVmHalo2Verifier.sol"; |
43 | 19 |
|
44 | | -```shell |
45 | | -$ anvil |
| 20 | +contract MyContract { |
| 21 | + function myFunction(bytes calldata publicValues, bytes calldata proofData, bytes32 appExeCommit, bytes32 appVmCommit) public view { |
| 22 | + IOpenVmHalo2Verifier(verifierAddress).verify(publicValues, proofData, appExeCommit, appVmCommit); |
| 23 | + } |
| 24 | +} |
46 | 25 | ``` |
47 | 26 |
|
48 | | -### Deploy |
| 27 | +If you want to deploy your own instance of the verifier contract, you can use `forge create`: |
49 | 28 |
|
50 | | -```shell |
51 | | -$ forge script script/Counter.s.sol:CounterScript --rpc-url <your_rpc_url> --private-key <your_private_key> |
| 29 | +```bash |
| 30 | +forge create src/v1.1.1/OpenVmHalo2Verifier.sol:OpenVmHalo2Verifier --rpc-url $RPC --private-key $PRIVATE_KEY --broadcast |
52 | 31 | ``` |
53 | 32 |
|
54 | | -### Cast |
55 | | - |
56 | | -```shell |
57 | | -$ cast <subcommand> |
58 | | -``` |
| 33 | +If you want to import the verifier into your own repo for testing purposes, it might be a bit trickier. The verifier contracts are locked to version `0.8.19` of solc, so if you are using a different version, the import will not be compilable. If you are using a different version, as a workaround, you can compile the contract and `vm.etch()` the raw bytecode into your tests. |
59 | 34 |
|
60 | | -### Help |
| 35 | +## Audits |
61 | 36 |
|
62 | | -```shell |
63 | | -$ forge --help |
64 | | -$ anvil --help |
65 | | -$ cast --help |
66 | | -``` |
| 37 | +You can find the audit reports for these contracts in the [OpenVM repo](https://github.com/openvm-org/openvm/tree/main/audits). |
0 commit comments