Skip to content

Provide utility function for aiken onchain validation and testing utility

License

Notifications You must be signed in to change notification settings

sidan-lab/vodka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Aiken Vodka - Library for Aiken Development

Licence Continuous Integration Twitter/X


Vodka is a library build for Aiken development. It offers

  1. Cocktail - Validating utils in writing on-chain code in aiken
  2. Mocktail - Unit test utils for easy building mock value for unit test

Version

Vodka is now upgraded to support latest PlutusV3 with latest version, if you want to use the old version compatible for legacy aiken version, please refer to below's table

Vodka Aiken Compiler aiken-lang/stdlib
0.1.1-beta ^v1.1.0 v2
0.0.1-beta v1.0.29-alpha v1.9.0

Vodka is pure and simple

For your transaction.

let Transaction { inputs, outputs, extra_signatories, .. } = context.transaction

Locating inputs & outputs:

when (inputs_at(inputs, target_address), outputs_at(outputs, target_address)) is {
  ([only_input], [only_output]) -> ...
  _ -> False
}

Checking signature with:

key_signed(extra_signatories, key_hash_required)

All onchain utility functions are grouped with a naming convention of vodka_<type>:

Type Naming Convention
Address vodka_address.{<the_util_fn>}
Value vodka_value.{<the_util_fn>}
transaction.extra_signatories vodka_extra_signatories.{<the_util_fn>}
transaction.inputs vodka_inputs.{<the_util_fn>}
transaction.mints vodka_mints.{<the_util_fn>}
transaction.outputs vodka_outputs.{<the_util_fn>}
transaction.redeemers vodka_redeemers.{<the_util_fn>}
transaction.validity_range vodka_validity_range.{<the_util_fn>}
ByteArray and Int conversion & utils vodka_converter.{<the_util_fn>}

Taste it before vodka cocktail, mocktail can be mixed, blended and Mesh

Building unit testing in vodka, easily indicating how you should build in whisky and Mesh.

You can taste if your transaction can pass your aiken contract validation:

# Mock transaction
let mock_tx: Transaction = mocktail_tx()
    ...
    |> required_signer_hash(is_key_provided, mock_pub_key_hex(1))
    |> complete()

Then move it to blend a whisky:

let mut tx = MeshTxBuilder::new_core()
tx.spending_plutus_script_v2()
  ...
  .required_signer_hash(key_hash)
  .complete(None)

Or Mesh:

const txBuilder = new MeshTxBuilder();
await txBuilder
  ...
  .requiredSignerHash(keyHash)
  .complete();

Start mixing

Simply run

aiken add sidan-lab/vodka --version 0.1.1-beta

or putting the below in you aiken.toml

[[dependencies]]
name = "sidan-lab/vodka"
version = "0.1.1-beta"
source = "github"

Documentation

Please refer to the hosted documentation.

Alt