Perishable Goods

Author: Accord Project

perishable-goods@0.16.0 Contract ^0.26.0 d1dd2790cc19c36016806556d32747258419c230714996c628034f9acc2fe8bf

This clause specifies penalties if the transport conditions (temperature and humidity) for a package are breached.

Download Archive Download Compiled Archive Open in Template Playground Open in VSCode Web

Perishable Goods

This clause specifies penalties if the transport conditions (temperature and humidity) for a package are breached.

Template Text

On receipt of the shipment "SHIP_001" the importer "DAN" pays the grower "PETER" 1.5 USD per KG. The shipment must contain between 3000 and 3500 KG of "Grade I, Size 4, Zutano Mexican Avocados".

Shipping containers used must be temperature and humidity controlled, and sensor readings must be logged at least 1 per hours.

Shipments that arrive after 07/02/2018 are to be considered spoiled and must be arranged to be returned to or disposed of by grower at cost to grower.

Temperature readings for the shipment must be between 2 and 13.

Humidity readings for the shipment must be between 70 and 90.

Shipments that have a temperature or humidity reading outside the agreed range have a price penalty applied calculated using the Formula for Breach Penalty Calculation below. The breach penalty factor to be used is 0.2.

Formula for Breach Penalty Calculation: penalty = number of shipment units x difference between sensor reading and agreed range x breach penalty factor

On receipt of the shipment "SHIP_001" the importer "DAN" pays the grower "PETER" 1.5 USD per KG. The shipment must contain between 3000 and 3500 KG of "Grade I, Size 4, Zutano Mexican Avocados".

Shipping containers used must be temperature and humidity controlled, and sensor readings must be logged at least 1 per hours.

Shipments that arrive after 07/02/2018 are to be considered spoiled and must be arranged to be returned to or disposed of by grower at cost to grower.

Temperature readings for the shipment must be between 2 and 13.

Humidity readings for the shipment must be between 70 and 90.

Shipments that have a temperature or humidity reading outside the agreed range have a price penalty applied calculated using the Formula for Breach Penalty Calculation below. The breach penalty factor to be used is 0.2.

Formula for Breach Penalty Calculation:
   penalty = number of shipment units x difference between sensor reading and agreed range x breach penalty factor
On receipt of the shipment {{shipmentId}} the importer {{importer}} pays the grower {{grower}} {{unitPrice}} {{currencyCode}} per {{unit}}. The shipment must contain between {{minUnits}} and {{maxUnits}} {{unit}} of {{product}}.

Shipping containers used must be temperature and humidity controlled, and sensor readings must be logged at least {{sensorReadingFrequency}} per {{duration}}.

Shipments that arrive after {{dueDate}} are to be considered spoiled and must be arranged to be returned to or disposed of by grower at cost to grower.

Temperature readings for the shipment must be between {{minTemperature}} and {{maxTemperature}}.

Humidity readings for the shipment must be between {{minHumidity}} and {{maxHumidity}}.

Shipments that have a temperature or humidity reading outside the agreed range have a price penalty applied calculated using the Formula for Breach Penalty Calculation below. The breach penalty factor to be used is {{penaltyFactor}}.

Formula for Breach Penalty Calculation:
   penalty = number of shipment units x difference between sensor reading and agreed range x breach penalty factor
{
  "$class": "org.accordproject.perishablegoods@0.1.0.TemplateModel",
  "grower": "resource:org.accordproject.party.Party#PETER",
  "importer": "resource:org.accordproject.party.Party#DAN",
  "shipment": "resource:org.accordproject.perishablegoods.Shipment#SHIP_001",
  "dueDate": "2018-07-02T00:00:00.000+01:00",
  "unitPrice": {
    "$class": "org.accordproject.money.MonetaryAmount",
    "doubleValue": 1.5,
    "currencyCode": "USD"
  },
  "unit": "KG",
  "minUnits": 3000,
  "maxUnits": 3500,
  "product": "Grade I, Size 4, Zutano Mexican Avocados",
  "sensorReadingFrequency": 1,
  "duration": "hours",
  "minTemperature": 2,
  "maxTemperature": 13,
  "minHumidity": 70,
  "maxHumidity": 90,
  "penaltyFactor": 0.2,
  "$identifier": "46467b65-22e0-40cc-900a-0f75dcc366f4",
  "clauseId": "46467b65-22e0-40cc-900a-0f75dcc366f4"
}

Template Model

namespace org.accordproject.perishablegoods@0.1.0

import org.accordproject.contract@0.2.0.Clause from https://models.accordproject.org/accordproject/contract@0.2.0.cto
import org.accordproject.runtime@0.2.0.{Request,Response} from https://models.accordproject.org/accordproject/runtime@0.2.0.cto

/**
 * Units of mass
 */
enum UnitOfMass {
  o KG
  o TONNE
  o LB
}

/**
 * A sensor reading (temperature and humidity)
 */
concept SensorReading {
  o Double centigrade
  o Double humidity
}

/**
 * Request: shipment received with unit count and embedded sensor readings
 */
transaction ShipmentReceived extends Request {
  o String shipmentId
  o Integer unitCount
  o SensorReading[] sensorReadings
}

/**
 * Response: price calculation result
 */
transaction PriceCalculation extends Response {
  o Double totalPrice
  o Double penalty
  o String currencyCode
  o Boolean late
}

/**
 * Event emitted when payment is due
 */
event PerishableGoodsPaymentEvent {
  o Double totalPrice
  o String currencyCode
  o String description
}

/**
 * State for the perishable goods contract
 */
concept PerishableGoodsState identified {
  o Boolean payoutMade default=false
  o Double totalPaid default=0.0
}

/**
 * The template model
 */
@template
asset TemplateModel extends Clause {
  o String grower
  o String importer
  o String shipmentId
  o DateTime dueDate
  o Double unitPrice
  o String currencyCode
  o UnitOfMass unit
  o Integer minUnits
  o Integer maxUnits
  o String product
  o Integer sensorReadingFrequency
  o String duration
  o Double minTemperature
  o Double maxTemperature
  o Double minHumidity
  o Double maxHumidity
  o Double penaltyFactor
}

Model Dependencies

Template Logic

Find the full logic for this template on on GitHub.

State Types

Type Sample JSON
org.accordproject.runtime@0.2.0.State
{
    "$class": "org.accordproject.runtime@0.2.0.State",
    "$identifier": "7c9dc8d0-50a4-11f1-a498-6b6dff021a96"
}

Request Types

Type Sample JSON
org.accordproject.perishablegoods@0.1.0.ShipmentReceived
{
    "$class": "org.accordproject.perishablegoods@0.1.0.ShipmentReceived",
    "shipmentId": "Duis nulla pariatur et fugiat.",
    "unitCount": 10082,
    "sensorReadings": [
        {
            "$class": "org.accordproject.perishablegoods@0.1.0.SensorReading",
            "centigrade": 152.364,
            "humidity": 173.568
        }
    ],
    "$timestamp": "2026-05-15T21:24:42.076Z"
}
org.accordproject.runtime@0.2.0.Request
{
    "$class": "org.accordproject.runtime@0.2.0.Request",
    "$timestamp": "2026-05-15T21:24:42.076Z"
}

Response Types

Type Sample JSON
org.accordproject.perishablegoods@0.1.0.PriceCalculation
{
    "$class": "org.accordproject.perishablegoods@0.1.0.PriceCalculation",
    "totalPrice": 55.165,
    "penalty": 112.32,
    "currencyCode": "Enim.",
    "late": false,
    "$timestamp": "2026-05-15T21:24:42.077Z"
}
org.accordproject.runtime@0.2.0.Response
{
    "$class": "org.accordproject.runtime@0.2.0.Response",
    "$timestamp": "2026-05-15T21:24:42.077Z"
}

Events Types

Type Sample JSON

Technical Integration

Please refer to the Accord Project documentation for how to use a template or integrate it within your application.

View the Latest code for this template on GitHub.