A template for quickly getting started with developing Rust applications that leverage FHE for smart contract development.
Continuous Integration is already set up to test both your Rust and Solidity code, as well as ensure formatting and that your Rust bindings match the Solidity build artifacts.
The project is structured as a mixed Rust workspace with a Foundry project under
contracts/ and typesafe auto-generated bindings to the contracts under
bindings/.
├── Cargo.toml
├── app // <-- Your Rust application logic
├── contracts // <- The smart contracts + tests using Foundry
├── bindings // <-- Generated bindings to the smart contracts' ABIs (like Typechain)
First, you'll need cargo; if you don't have it, the easiest way is to install via rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shThen you can install our foundry fork:
cargo install --git https://github.com/Sunscreen-tech/foundry --locked --profile local forge cast anvilFor more info on foundry, see the official docs.
Given the repository contains both Solidity and Rust code, there's 2 different workflows.
Forge uses submodules to manage dependencies. Initialize the dependencies:
forge installIf you are in the root directory of the project, run:
forge test --root ./contractsIf you are in in contracts/:
forge testcargo test
Rust bindings to the contracts can be generated via forge bind, which requires
first building your contracts:
forge build --root ./contracts
forge bind --bindings-path ./bindings --root ./contracts --crate-name bindings
Any follow-on calls to forge bind will check that the generated bindings match
the ones under the build files. If you want to re-generate your bindings, pass
the --overwrite flag to your forge bind command.