Skip to content
This repository was archived by the owner on Sep 7, 2023. It is now read-only.
This repository was archived by the owner on Sep 7, 2023. It is now read-only.

Should a contract be able to specify when it is considered completed? #595

@jeromesimeon

Description

@jeromesimeon

Currently, there is no way to execute logic at contract termination (or even to indicate what conditions should be met for termination).

While this could be encoded in the logic of the contract itself (with e.g., a state field indicating that the contract is in TERMINATED state), it might be useful to provide a first-class clause for this.

This could look as follows:

contract MyAgreement over MyVariables {
  clause init() { // initialization?
      set state MyState { ... }
  }

  clause purchase(request:Purchase) : PurchaseResponse {
    ...
  }
  clause payment(request:Payment) : PaymentResponse {
    ...
  }

  clause packageReceived(request:DeliveryRequest) : Response {
     terminate()
  } 

  clause terminate() : TerminatedResponse { // finalize? shutdown? completion?
     enforce state.status = "BREACHED" and isAfter(now(), "01/01/2020");
     return TerminatedResponse{}
  }

  clause terminate() : TerminatedResponse { // finalize? shutdown? completion?
     throw ("You can never");
  }

  clause terminate() : TerminatedResponse { // finalize? shutdown? completion?
     return TerminatedResponse{}
  }

 clause terminate(why:String) : TerminatedResponse { // finalize? shutdown? completion?
     return TerminatedResponse{ message: why }
  }
}

Note that after the terminate clause of the contract has been clause, the contract will not accept requests anymore.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions