Configuration options for the smart contract.
The type of operation (e.g., "create", "read", "update", "delete").
OptionalrateLimit?: numberOptional. The maximum number of operations allowed per minute.
The name of the resource (e.g., "user", "product").
The visibility level ("public", "private", "admin").
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
}
}
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.