Proof‑of‑Contribution Protocol Core
Version: 0.1.0
Status: Draft (Alpha)
This API Reference defines the public interfaces, data structures, and deterministic behaviors of the Proof‑of‑Contribution Protocol Core.
- Applications
- Bots
- Automation pipelines
- Solana programs
- Governance systems
- Reward engines
- Event schema
- Validation API
- Scoring API
- Proof generation API
- Proof verification API
- Error formats
- Versioning rules
- Contribution Event Schema
A Contribution Event is the core input to the protocol.
json { "id": "string", "timestamp": "unix_timestamp", "actor": "publickeyor_identifier", "type": "string", "payload": {}, "metadata": {} }
| Field | Type | Required | Description |
|---|---|---|---|
| id | string | Yes | Unique event identifier |
| timestamp | number | Yes | Unix timestamp |
| actor | string | Yes | Public key or identifier |
| type | string | Yes | Contribution type |
| payload | object | Yes | Type‑specific data |
| metadata | object | No | Optional contextual data |
- Validation API
The Validation API ensures that events are:
- Well‑formed
- Authentic
- Non‑replayed
- Type‑valid
- Payload‑valid
Function: validateEvent(event)
Input
A valid Contribution Event.
Output
json { "event_id": "string", "valid": true, "errors": [], "validator": "core", "version": "0.1.0" }
json { "event_id": "string", "valid": false, "errors": ["missing_field: payload.repo"], "validator": "core", "version": "0.1.0" }
- Scoring API
The Scoring API applies deterministic scoring rules.
Function: scoreEvent(event)
Input
A validated Contribution Event.
Output
json { "event_id": "string", "score": 0, "rulesapplied": ["rulename"], "version": "0.1.0" }
Defined in:
/spec/scoring-rules.md
Rules must be:
- Deterministic
- Pure functions
- Versioned
- Contribution Proof API
The Proof API assembles the final proof object.
Function: generateProof(event, validation, score)
Output
json { "event_id": "string", "score": 0, "validated": true, "signature": null, "version": "0.1.0" }
Optional: Signed Proofs
Integrators may sign proofs using:
- Wallet keys
- Service keys
- PDAs
Signature format is integrator‑defined.
- Proof Verification API
Function: verifyProof(proof)
Output
json { "valid": true, "errors": [], "version": "0.1.0" }
json { "valid": false, "errors": ["invalid_signature"], "version": "0.1.0" }
- Error Format
All errors follow a consistent structure.
Error Object
json { "code": "string", "message": "string", "field": "optional" }
| Code | Meaning |
|---|---|
| missing_field | Required field missing |
| invalid_type | Unsupported contribution type |
| invalid_payload | Payload failed validation |
| timestamp_invalid | Timestamp outside allowed range |
| replay_detected | Event already processed |
| scoring_error | Scoring rule failure |
| signature_invalid | Invalid signature |
| version_mismatch | Protocol version mismatch |
- Versioning Rules
The API follows semantic versioning:
- MAJOR — breaking changes
- MINOR — new features
- PATCH — fixes
All API responses include a version field.
- Determinism Requirements
All API functions must:
- Produce identical output for identical input
- Avoid randomness
- Avoid external API calls
- Avoid floating‑point drift
- Avoid environment‑dependent behavior
-
Example End‑to‑End Flow
-
Validate
ts const validation = validateEvent(event);
- Score
ts const score = scoreEvent(event);
- Generate Proof
ts const proof = generateProof(event, validation, score);
- Verify Proof
ts const verified = verifyProof(proof);
- Status
This API Reference is in Alpha and will evolve as the protocol matures.