Expand description
§Hyli Contract SDK
This crate provides helper tools for writing smart contracts that run inside a Rust-based zkVM, such as Risc0 or SP1.
§Building a contract on Hyli
To write a contract for Hyli:
- Create a library crate that defines a struct implementing the
ZkContracttrait. - Build a corresponding zkVM binary that runs your contract logic.
See crate::guest for details on how to configure and run your contract inside the zkVM.
You can use our app scaffold to get started:
§Contract interoperability
If your contract needs to exchange data with others, refer to StructuredBlobData.
More documentation about this will follow.
Modules§
- caller
- guest
- The
guestmodule provides theGuestEnvtrait that defines a common interface for the guests accross different zkvm. It providesRisc0EnvandSP1Envstructs that implement theGuestEnvtrait for both zkvm. - hyli_
model_ utils - secp256k1
- utils
- verifiers
Macros§
Structs§
- Blob
- A Blob is a binary-serialized action that the contract has to parse An action is often written as an enum representing the call of a specific contract function.
- Blob
Data - Blob
Hash - Blob
Index - Block
Height - Calldata
- This struct is passed from the application backend to the contract as an input. It contains the data that the contract will use to run the blob’s action on its state.
- Consensus
Proposal Hash - Contract
Name - Delete
Contract Action - Used as a blob action to delete a contract.
- Drop
EndOf Reader - Struct used to be able to deserialize a StructuredBlobData
without knowing the concrete type of
Actionwarning: this will drop the end of the reader, thus, you can’t deserialize a structure that contains aStructuredBlobData<DropEndOfReader>Unless this struct is at the end of your data structure. It’s not meant to be used outside the sdk internal logic. - Hyli
Output - This struct has to be the zkvm committed output. It will be used by hyli node to verify & settle the blob transaction.
- Identity
- An identity is a string that identifies the person that sent the BlobTransaction
- Indexed
Blobs - Blob of the transactions the contract uses to validate its transition
- Lane
Bytes Size - LaneId
- Onchain
Effect Hash - Program
Id - Proof
- Proof
Data - Proof
Data Hash - Proof
Metadata - Register
Contract Action - Used as a blob action to register a contract.
- Register
Contract Effect - Used by the Hyli node to recognize contract registration. Simply output this struct in your HyliOutput registered_contracts. See uuid-tld for examples.
- Rewards
Claim - State
Commitment - State commitment of the contract.
- Structured
Blob - Structured
Blob Data - This struct allows to define cross-contract calls (aka contract composition).
A contract
Acan “call” an other contractBby being it’s “caller”: - TxContext
- TxHash
- Update
Contract Program IdAction - Update
Contract Timeout Window Action - Validator
Public Key - Verifier
Enums§
- Onchain
Effect - Enum for various side-effects blobs can have on the chain. This is implemented as an enum for easier forward compatibility.
- Staking
Action - Enum representing the actions that can be performed by the Staking contract.
- Timeout
Window
Constants§
Traits§
- Contract
Action - Data
Sized - Full
State Revert - Hashed
- Transactional
ZkContract - ZkContract
- This trait is used to define the contract’s entrypoint. By using it and the execute function, you let the sdk generate for you the HyliOutput struct with correct fields.