Skip to content

Commit

Permalink
wrote first script/validator (smart contract) and build blueprint
Browse files Browse the repository at this point in the history
  • Loading branch information
wattsmainsanglais committed Mar 28, 2024
1 parent cad8661 commit f372654
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 0 deletions.
69 changes: 69 additions & 0 deletions plutus.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"preamble": {
"title": "aiken-lang/hello-world",
"description": "Aiken contracts for project 'aiken-lang/hello-world'",
"version": "0.0.0",
"plutusVersion": "v2",
"compiler": {
"name": "Aiken",
"version": "v1.0.26-alpha+unknown"
},
"license": "Apache-2.0"
},
"validators": [
{
"title": "hello_world.hello_world",
"datum": {
"title": "datum",
"schema": {
"$ref": "#/definitions/hello_world~1Datum"
}
},
"redeemer": {
"title": "redeemer",
"schema": {
"$ref": "#/definitions/hello_world~1Redeemer"
}
},
"compiledCode": "58e901000032323232323223223225333006323253330083371e6eb8c008c028dd5002a4410d48656c6c6f2c20576f726c642100100114a06644646600200200644a66601c00229404c94ccc030cdc79bae301000200414a226600600600260200026eb0c02cc030c030c030c030c030c030c030c030c024dd5180098049baa002375c600260126ea80188c02c0045261365653330043370e900018029baa001132325333009300b002149858dd7180480098031baa0011653330023370e900018019baa0011323253330073009002149858dd7180380098021baa001165734aae7555cf2ab9f5742ae881",
"hash": "c1fe430f19ac248a8a7ea47db106002c4327e542c3fdc60ad6481103"
}
],
"definitions": {
"ByteArray": {
"dataType": "bytes"
},
"hello_world/Datum": {
"title": "Datum",
"anyOf": [
{
"title": "Datum",
"dataType": "constructor",
"index": 0,
"fields": [
{
"title": "owner",
"$ref": "#/definitions/ByteArray"
}
]
}
]
},
"hello_world/Redeemer": {
"title": "Redeemer",
"anyOf": [
{
"title": "Redeemer",
"dataType": "constructor",
"index": 0,
"fields": [
{
"title": "msg",
"$ref": "#/definitions/ByteArray"
}
]
}
]
}
}
}
27 changes: 27 additions & 0 deletions validators/hello-world.ak
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
use aiken/hash.{Blake2b_224, Hash}
use aiken/list
use aiken/string
use aiken/transaction.{OutputReference, ScriptContext, Spend, TransactionId}
use aiken/transaction/credential.{VerificationKey}


type Datum {
owner: Hash<Blake2b_224, VerificationKey>,
}

type Redeemer {
msg: ByteArray,
}

validator {
fn hello_world(datum: Datum, redeemer: Redeemer, context: ScriptContext) -> Bool {

trace string.from_bytearray(redeemer.msg)

let must_say_hello = redeemer.msg == "Hello, World!"

let must_be_signed = list.has(context.transaction.extra_signatories, datum.owner)

must_say_hello? && must_be_signed?
}
}

0 comments on commit f372654

Please sign in to comment.