Don

Datum Dons

Community Code Review

logo
1use aiken/collection/list
2 use aiken/crypto.{VerificationKeyHash}
3 use aiken/primitive/string
4 use cardano/transaction.{OutputReference, Transaction}
5
6 pub type Datum {
7 owner: VerificationKeyHash,
8 }
9
10 pub type Redeemer {
11 msg: ByteArray,
12 }
13
14 validator hello_world {
15 spend(
16 datum: Option<Datum>,
17 redeemer: Redeemer,
18 _own_ref: OutputReference,
19 self: Transaction,
20 ) {
21 trace @"redeemer": string.from_bytearray(redeemer.msg)
22 expect Some(Datum { owner }) = datum
23 let must_say_hello = redeemer.msg == "Hello, World!"
24 let must_be_signed = list.has(self.extra_signatories, owner)
25 must_say_hello? && must_be_signed?
26 }
27
28 else(_) {
29 fail
30 }
31 }
32
33 test hello_world_example_1() {
34 let datum =
35 Datum { owner: #"00000000000000000000000000000000000000000000000000000000" }
36 let redeemer = Redeemer { msg: "Aiken Rocks!" }
37 let placeholder_utxo = OutputReference { transaction_id: "", output_index: 0 }
38 hello_world.spend(
39 Some(datum),
40 redeemer,
41 placeholder_utxo,
42 transaction.placeholder,
43 )
44 }
45
46 test hello_world_example_2() {
47 let datum =
48 Datum { owner: #"00000000000000000000000000000000000000000000000000000000" }
49 let redeemer = Redeemer { msg: "Hello, World!" }
50 let placeholder_utxo = OutputReference { transaction_id: "", output_index: 0 }
51 hello_world.spend(
52 Some(datum),
53 redeemer,
54 placeholder_utxo,
55 transaction.placeholder,
56 )
57 }
58
59 test hello_world_example_3() {
60 let datum =
61 Datum { owner: #"00000000000000000000000000000000000000000000000000000000" }
62 let redeemer = Redeemer { msg: "Hello, World!" }
63 let placeholder_utxo = OutputReference { transaction_id: "", output_index: 0 }
64 hello_world.spend(
65 Some(datum),
66 redeemer,
67 placeholder_utxo,
68 Transaction { ..transaction.placeholder, extra_signatories: [datum.owner] },
69 )
70 }

Participants

NameRoleGitHub
gZerogZero
Don
unspentTxunspentTx
Capo
NewmanNewman
Capo
logo

Datum Dons

A Gimbalabs project

We started bootlegging Aiken Validators during the prohibition... Back when the Cardano streets were mean and the validators were scarce. Gimbalabs incubated us.

The Dons ran the underground validator circuit, smuggling code through the back channels of the blockchain. "The Capo" - that's what they called us. We were the ones who could read you a hot validator when nobody else could.