Skip to content

Commit

Permalink
Write down specification about Plutus contract blueprints.
Browse files Browse the repository at this point in the history
  Including meta-schemas and type definitions for existing "builtins"
  Plutus types.
  • Loading branch information
KtorZ committed May 6, 2023
1 parent eeee891 commit b97beca
Show file tree
Hide file tree
Showing 8 changed files with 1,050 additions and 1 deletion.
422 changes: 422 additions & 0 deletions CIP-0057/README.md

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions CIP-0057/schemas/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Plutus Contract Blueprint - Meta-Schemas

In these folders you'll find meta JSON-schemas for CIP-0057; Meta-schemas are JSON schemas describing how a Plutus Contract Blueprint should be structured. They also define several common data-types that can be referenced when writing your own specification.

Schema | Description
--- | ---
[plutus-blueprint.json](./plutus-blueprint.json) | The meta-schema for the blueprint specification document itself
[plutus-blueprint-argument.json](./plutus-blueprint-argument.json) | The meta-schema for blueprints runtime arguments (i.e datums & redeemers)
[plutus-blueprint-parameter.json](./plutus-blueprint-parameter.json) | The meta-schema for blueprints compile-time parameters
[plutus-data.json](./plutus-data.json) | Definitions of the _Plutus Data Schema_ and the various supported keywords
[plutus-builtin.json](./plutus-builtin.json) | Definitions of the Untyped Plutus Core builtin types
74 changes: 74 additions & 0 deletions CIP-0057/schemas/plutus-blueprint-argument.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://cips.cardano.org/cips/cip57/schemas/plutus-blueprint-argument.json",
"$vocabulary": {
"https://json-schema.org/draft/2020-12/vocab/core": true,
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
"https://json-schema.org/draft/2020-12/vocab/validation": true,
"https://cips.cardano.org/cips/cip57": true
},

"type": "object",
"required": ["schema"],
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"purpose": {
"anyOf": [
{
"$ref": "#/$defs/purpose"
},
{
"type": "object",
"required": ["oneOf"],
"properties": {
"oneOf": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/$defs/purpose"
}
}
}
}
]
},
"schema": {
"anyOf": [
{
"$ref": "plutus-data.json"
},
{
"$ref": "#/$defs/applicator"
}
]
}
},

"$defs": {
"purpose": {
"type": "string",
"enum": ["spend", "mint", "withdraw", "publish"]
},
"applicator": {
"type": "object",
"required": ["oneOf"],
"properties": {
"oneOf": {
"$ref": "#/$defs/schemaArray"
}
}
},
"schemaArray": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#"
}
}
}
}
77 changes: 77 additions & 0 deletions CIP-0057/schemas/plutus-blueprint-parameter.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://cips.cardano.org/cips/cip57/schemas/plutus-blueprint-parameter.json",
"$vocabulary": {
"https://json-schema.org/draft/2020-12/vocab/core": true,
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
"https://json-schema.org/draft/2020-12/vocab/validation": true,
"https://cips.cardano.org/cips/cip57": true
},

"type": "object",
"required": ["schema"],
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"purpose": {
"anyOf": [
{
"$ref": "#/$defs/purpose"
},
{
"type": "object",
"required": ["oneOf"],
"properties": {
"oneOf": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#/$defs/purpose"
}
}
}
}
]
},
"schema": {
"anyOf": [
{
"$ref": "plutus-data.json"
},
{
"$ref": "plutus-builtin.json"
},
{
"$ref": "#/$defs/applicator"
}
]
}
},

"$defs": {
"purpose": {
"type": "string",
"enum": ["spend", "mint", "withdraw", "publish"]
},
"applicator": {
"type": "object",
"required": ["oneOf"],
"properties": {
"oneOf": {
"$ref": "#/$defs/schemaArray"
}
}
},
"schemaArray": {
"type": "array",
"minItems": 1,
"items": {
"$ref": "#"
}
}
}
}
105 changes: 105 additions & 0 deletions CIP-0057/schemas/plutus-blueprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://cips.cardano.org/cips/cip57/schemas/plutus-blueprint.json",
"$vocabulary": {
"https://json-schema.org/draft/2020-12/vocab/core": true,
"https://json-schema.org/draft/2020-12/vocab/applicator": true,
"https://json-schema.org/draft/2020-12/vocab/validation": true,
"https://cips.cardano.org/cips/cip57": true
},
"type": "object",
"required": [
"preamble",
"validators"
],
"properties": {
"preamble": {
"$ref": "#/$defs/preamble"
},
"validators": {
"type": "array",
"items": {
"$ref": "#/$defs/validator"
}
},
"definitions": {
"type": "object",
"additionalProperties": true
}
},
"$defs": {
"preamble": {
"type": "object",
"additionalProperties": false,
"required": [
"title",
"version",
"plutusVersion"
],
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"version": {
"type": "string"
},
"plutusVersion": {
"type": "string",
"enum": [ "v1", "v2" ]
},
"license": {
"type": "string"
}
}
},
"validator": {
"type": "object",
"required": [
"title",
"redeemer"
],
"properties": {
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"compiledCode": {
"$ref": "#/$defs/compiledCode"
},
"hash": {
"$ref": "#/$defs/hashDigest"
},
"datum": {
"$ref": "plutus-blueprint-argument.json"
},
"redeemer": {
"$ref": "plutus-blueprint-argument.json"
},
"parameters": {
"type": "array",
"items": {
"$ref": "plutus-blueprint-parameter.json"
}
}
}
},
"compiledCode": {
"type": "string",
"contentEncoding": "base16",
"description": "A cbor-serialised flat-encoded Plutus script",
"example": "01450100002601"
},
"hashDigest": {
"type": "string",
"contentEncoding": "base16",
"description": "Blake2b-224 hash digest of the serialised Plutus script, with language tag prefix.",
"minLength": 56,
"maxLength": 56
}
}
}
Loading

0 comments on commit b97beca

Please sign in to comment.