Crate pbc_contract_codegen
source ·Expand description
§Partisia Blockchain SDK Macros
Defines the ABI attribute macros:
state
declares how the contract represents its state.init
declares the code run when the contract is initialized.action
declares an endpoint that the contract can be interacted with by.callback
declares a callback hook.
Additionally defines the zero-knowledge lifetime attribute macros:
zk_on_secret_input
declares an endpoint that the contract can be interacted with to add secret variables.zk_on_variable_inputted
declares an automatic hook for when a variable is confirmed inputted.zk_on_variable_rejected
declares an automatic hook for when a variable is rejected.zk_on_compute_complete
declares an automatic hook for when the zero-knowledge computation is finished.zk_on_variables_opened
declares an automatic hook for when one of the contract’s own secret variables is ready to be read.zk_on_attestation_complete
declares an automatic hook for when the contract have asked nodes to attest a piece of data, and this process have completed.zk_on_external_event
declares an automatic hook for when the contract have subscribed to external events and nodes send events to the contract.
This crate can automatically produce ABI files, and serialization boilerplate for actions. Additionally, the crate will type check the function signatures of the annotated functions, to guarantee that the contract can interact correctly with the blockchain.
When panics occur the state is always rolled back, this is due to the atomicity of the blockchain which defines certain outcomes for actions. The outcomes are specified in each action.
Attribute Macros§
- Public
action
contract annotation - Public callback contract annotation
- Initializer contract annotation
- State contract annotation
- Data-attestation complete zero-knowledge contract annotation
- Computation complete zero-knowledge contract annotation
- External event zero-knowledge contract annotation
- Secret input/action contract annotation
- Secret variable input zero-knowledge contract annotation
- Secret variable rejection zero-knowledge contract annotation
- Secret variable opened zero-knowledge contract annotation