Skip to main content

Crate hyli_contract_sdk

Crate hyli_contract_sdk 

Source
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 ZkContract trait.
  • 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 guest module provides the GuestEnv trait that defines a common interface for the guests accross different zkvm. It provides Risc0Env and SP1Env structs that implement the GuestEnv trait for both zkvm.
hyli_model_utils
secp256k1
utils
verifiers

Macros§

error
info

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.
BlobData
BlobHash
BlobIndex
BlockHeight
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.
ConsensusProposalHash
ContractName
DeleteContractAction
Used as a blob action to delete a contract.
DropEndOfReader
Struct used to be able to deserialize a StructuredBlobData without knowing the concrete type of Action warning: this will drop the end of the reader, thus, you can’t deserialize a structure that contains a StructuredBlobData<DropEndOfReader> Unless this struct is at the end of your data structure. It’s not meant to be used outside the sdk internal logic.
HyliOutput
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
IndexedBlobs
Blob of the transactions the contract uses to validate its transition
LaneBytesSize
LaneId
OnchainEffectHash
ProgramId
Proof
ProofData
ProofDataHash
ProofMetadata
RegisterContractAction
Used as a blob action to register a contract.
RegisterContractEffect
Used by the Hyli node to recognize contract registration. Simply output this struct in your HyliOutput registered_contracts. See uuid-tld for examples.
RewardsClaim
StateCommitment
State commitment of the contract.
StructuredBlob
StructuredBlobData
This struct allows to define cross-contract calls (aka contract composition). A contract A can “call” an other contract B by being it’s “caller”:
TxContext
TxHash
UpdateContractProgramIdAction
UpdateContractTimeoutWindowAction
ValidatorPublicKey
Verifier

Enums§

OnchainEffect
Enum for various side-effects blobs can have on the chain. This is implemented as an enum for easier forward compatibility.
StakingAction
Enum representing the actions that can be performed by the Staking contract.
TimeoutWindow

Constants§

HASH_DISPLAY_SIZE
HYLI_TESTNET_CHAIN_ID

Traits§

ContractAction
DataSized
FullStateRevert
Hashed
TransactionalZkContract
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.

Functions§

str_to_u8
to_u8_array

Type Aliases§

BlockHash
LaneSuffix
RunResult