Skip to content

spacebudz/stdlib

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aiken Standard Library

The official standard library for the Aiken Cardano smart-contract language.

It extends the language builtins with useful data-types, functions, constants and aliases that make using Aiken a bliss.

use aiken/hash.{Blake2b_224, Hash}
use aiken/list
use aiken/string
use aiken/transaction.{ScriptContext}
use aiken/transaction/credential.{VerificationKey}

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

pub type Redeemer {
  msg: ByteArray,
}

/// A simple validator which replicates a basic public/private signature lock.
///
/// - The key (hash) is set as datum when the funds are sent to the script address.
/// - The spender is expected to provide a signature, and the string 'Hello, World!' as message
/// - The signature is implicitly verified by the ledger, and included as 'extra_signatories'
///
pub fn spend(datum: Datum, redeemer: Redeemer, context: ScriptContext) -> Bool {
  let must_say_hello = string.from_bytearray(redeemer.msg) == "Hello, World!"
  let must_be_signed =
    context.transaction.extra_signatories
    |> list.any(fn(vkh: ByteArray) { vkh == datum.owner })

  must_say_hello && must_be_signed
}

About

The Aiken Standard Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Gleam 100.0%