zerot
    Preparing search index...

    Function smartContract

    • A helper function to automatically infer contract conditions based on common operation patterns. This can be used to quickly set up contracts for typical CRUD operations with varying visibility.

      Parameters

      • options: {
            operation: "create" | "update" | "read" | "delete";
            rateLimit?: number;
            resource: string;
            visibility: "admin" | "public" | "private";
        }

        Configuration options for the smart contract.

        • operation: "create" | "update" | "read" | "delete"

          The type of operation (e.g., "create", "read", "update", "delete").

        • OptionalrateLimit?: number

          Optional. The maximum number of operations allowed per minute.

        • resource: string

          The name of the resource (e.g., "user", "product").

        • visibility: "admin" | "public" | "private"

          The visibility level ("public", "private", "admin").

      Returns ContractOptions

      A ContractOptions object configured with appropriate conditions.

      class ProductService {
      @contract(smartContract({
      operation: "create",
      resource: "product",
      visibility: "admin",
      rateLimit: 10
      }))
      async createProduct(productData: any) {
      // Logic to create a product
      }

      @contract(smartContract({
      operation: "read",
      resource: "product",
      visibility: "public"
      }))
      async getProduct(productId: string) {
      // Logic to get a product
      }
      }