πŸ“„Work Record Smart Contract

This contract stores all the Services or Jobs of a Freelance Experience of the user .

Structure

struct WorkRecord {
    uint256 workRecordId;
    uint256 experienceId;
    address user;
    string consumer;
    address consumerAddress;
    address platformAddress;
    string title;
    string description;
    string[] tags;
    uint256 startDate;
    uint256 endDate;
    string status;
    uint256 price;
    uint256 hoursWorked;
    uint16 calification;
    bool consumerValidation;
    string consumerComments;
    Skill[] skills;
    string moreInfoLinks;
}
struct Skill {
    string skill;
    uint8 level;    
}

Example

{
  "workRecordId": 1,
  "experienceId": 1,
  "user": "0xd8da6bf26964af9d7eed9e03e53415d37aa96045",
  "consumer": "",
  "consumerAddress": "0xea83c649dd49a6ec44c9e2943eb673a8fbb7bab6",
  "platformAddress": "0xaa9d8b1f9a2f9b0f9b2b0f9b0f9b0f9b0f9b0f9b",
  "title": "Web App",
  "description": "Web App for General Store",
  "tags": [
    "web",
    "app"
  ],
  "startDate": 1704078000,
  "endDate": 1717124400,
  "status": "Complete",
  "price": 12345,
  "hoursWorked": 100,
  "calification": 430,
  "consumerValidation": true,
  "consumerComments": "Great job!",
  "skills": [
    {
      "skill": "e-commerce",
      "level": 7
    },
    {
      "skill": "French",
      "level": 5
    }
  ],
  "moreInfoLink": "ipfs://ipfs.io/XXXXXXX"    
}

Field Semantics

  • workRecordId: Work Record Identificator. This value is assigned correlatively by the Smart Contract.

  • experienceId: Experience Identificator. The Experience must be freelancer.

  • user: Address of the user. Owner of the record.

  • consumer: Name of the consumer of the service. It's just descriptive, this Work Record cannot be verified if this field is used. Must be empty if a Consumer Address is provided.

  • consumerAddress: Address of the consumer of the service. Must be provided by the consumer itself. The owner of this address can verify the Work Record. Could be empty if the consumer have no address (consumer field is used instead).

  • platformAddress: Address of the platform that mediate in the service. Must be provided by the platform itself. If the service is done using a platform like Upwork or Fiverr, it's unlikely that the consumer could validate this service. But, in this case, is the platform itself who validate it.

  • title: Title of the service.

  • description: Describe the service/job with more details.

  • tags: Keywords that match with this service. They are just descriptive. It would be used to search and classificate the services.

  • startDate: Date when the Work Record began. Store as Unix Timestamp (Seconds since Jan-01-1970). Mandatory field. Must be greater than the Experience startDate.

  • endDate: Date when the Work Record ended. Store as Unix Timestamp (Seconds since Jan-01-1970). Could be 0 if the Work Record has not ended yet. Must be greater than startDate.

  • status: current Work Record Status (Pending - Completed - Cancelled).

  • price: Amount charged in USD. Store as cents (1 USD = 100).

  • hoursWorked: Amount of hours used to complete the service.

  • calification: Consumer calification for the service. Store in basis points (1 = 100). Must be between 0 and 500 (0 - 5). Must be provided only when an endDate is provided.

  • consumerValidation: If a consumerAddress is provided, the owner of it can validate the Work Record.

  • consumerComments: Consumer comments about the service. Must be provided only when an endDate is provided.

  • skills: Skills used for this Work Record.

  • moreInfoLink: Link to an optional metadata. Typically this link will point to a JSON with different fields for any kind of metadata (Photos, Videos, Informative Fields, etc).

Functions

addWorkRecord: Adds a new Work Record.

updateWorkRecord: Updates an existing Work Record.

endWorkRecord: Ends an existing Work Record.

deleteWorkRecord: Deletes an existing Work Record.

updateWorkRecordValidation: Validates an existing Work Record.

cancelWorkRecord: Cancels an existing Work Record.

Validation Rules

The are several rules that a Work Record must follow to ensure a consistent state. This apply to addWorkRecord, updateWorkRecord and endWorkRecord operation.

  • User address must match Experience user address.

  • Experience must be freelance.

  • Must specify either a consumer name or a consumer address (one or another, not both).

  • User address must be different from consumer address and platform address.

  • Title must not be empty.

  • Description must not be empty.

  • StartDate must not be empty.

  • Work Record dates must be within the Experience dates.

  • EndDate must be greater than startDate.

  • Calification must not be greater than 500.

Last updated