Crate pallet_starknet

source ·
Expand description

A Substrate pallet implementation for Starknet, a decentralized, permissionless, and scalable zk-rollup for general-purpose smart contracts. See the Starknet documentation for more information. The code consists of the following sections:

  1. Config: The trait Config is defined, which is used to configure the pallet by specifying the parameters and types on which it depends. The trait also includes associated types for StateRoot, SystemHash, and TimestampProvider.

  2. Hooks: The Hooks trait is implemented for the pallet, which includes methods to be executed during the block lifecycle: on_finalize, on_initialize, on_runtime_upgrade, and offchain_worker.

  3. Storage: Several storage items are defined, including Pending, CurrentBlock, BlockHash, ContractClassHashes, ContractClasses, Nonces, StorageView, LastKnownEthBlock, and FeeTokenAddress. These storage items are used to store and manage data related to the Starknet pallet.

  4. Genesis Configuration: The GenesisConfig struct is defined, which is used to set up the initial state of the pallet during genesis. The struct includes fields for contracts, contract_classes, storage, fee_token_address, chain_id and _phantom. A GenesisBuild implementation is provided to build the initial state during genesis.

  5. Events: A set of events are defined in the Event enum, including KeepStarknetStrange, StarknetEvent, and FeeTokenAddressChanged. These events are emitted during the execution of various pallet functions.

6.Errors: A set of custom errors are defined in the Error enum, which is used to represent various error conditions during the execution of the pallet.

  1. Dispatchable Functions: The Pallet struct implements several dispatchable functions (ping, invoke, …), which allow users to interact with the pallet and invoke state changes. These functions are annotated with weight and return a DispatchResult.

Re-exports

Modules

  • An adapter for the blockifier state related traits
  • The pallet module in each FRAME pallet hosts the most important items needed to construct this pallet.
  • Simulation, estimations and execution trace logic.
  • Transaction validation logic. Transaction validation logic.
  • The Starknet pallet’s runtime custom types. Starknet pallet custom types.

Macros

Constants