Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Important: If you're upgrading snforge to version 0.48.0 or later, please read the 0.48.0 Migration Guide.

declare

#[derive(Drop, Serde, Clone)] enum DeclareResult { Success: ContractClass, AlreadyDeclared: ContractClass, } trait DeclareResultTrait { /// Gets inner `ContractClass` /// `self` - an instance of the struct `DeclareResult` which is obtained by calling `declare` // Returns the `@ContractClass` fn contract_class(self: @DeclareResult) -> @ContractClass; } fn declare(contract: ByteArray) -> Result<DeclareResult, Array<felt252>>

Declares a contract for later deployment.

Returns the DeclareResult that encapsulated possible outcomes in the enum:

  • Success: Contains the successfully declared ContractClass.
  • AlreadyDeclared: Contains ContractClass and signals that the contract has already been declared.

See docs of ContractClass for more info about the resulting struct.