Skip to content

Latest commit

 

History

History
73 lines (55 loc) · 2.05 KB

File metadata and controls

73 lines (55 loc) · 2.05 KB

PropertyAsset Smart Contract

This is a smart contract for a property asset management system.

PropertyAsset Smart Contract CRUD Operations

Create Asset

CreateAsset(ctx, propertyId, name, quantity, price, image)

Creates a new asset in the ledger with the specified properties. Each asset is assigned a unique UUID.

  • Parameters:
    • propertyId: The ID of the property this asset belongs to
    • name: Name of the asset
    • quantity: Number of items in stock
    • price: Price per unit
    • image: Image filename/URL for the asset
  • Returns: JSON string of the created asset

Read Asset

ReadAsset(ctx, id)

Retrieves an asset from the ledger by its ID.

  • Parameters:
    • id: Unique identifier of the asset
  • Returns: JSON string of the requested asset
  • Throws: Error if asset doesn't exist

Update Asset

UpdateAsset(ctx, id, propertyId, name, quantity, price, image)

Updates an existing asset in the ledger with new values.

  • Parameters:
    • id: Unique identifier of the asset to update
    • propertyId: The ID of the property this asset belongs to
    • name: Updated name of the asset
    • quantity: Updated quantity
    • price: Updated price
    • image: Updated image filename/URL
  • Returns: JSON string of the updated asset
  • Throws: Error if asset doesn't exist

Delete Asset

DeleteAsset(ctx, id)

Removes an asset from the ledger.

  • Parameters:
    • id: Unique identifier of the asset to delete
  • Throws: Error if asset doesn't exist

PropertyAsset Smart Contract Query Operations

Get All Assets

GetAllAssets(ctx, propertyId?)

Retrieves all assets from the ledger with optional filtering by property ID.

  • Parameters:
    • propertyId (optional): Filter assets by property ID
  • Returns: JSON string array of assets
  • Behavior:
    • If propertyId is provided: Returns only assets belonging to that property
    • If propertyId is not provided: Returns all assets in the ledger
  • Example response:

Kaleido deployment

zip

zip -r chaincode-javascript.zip . -x "node_modules/*"

then import the zip file to the Kaleido app