An open API service indexing awesome lists of open source software.

https://github.com/sidan-lab/vodka

Provide utility function for aiken onchain validation and testing utility
https://github.com/sidan-lab/vodka

Last synced: 6 months ago
JSON representation

Provide utility function for aiken onchain validation and testing utility

Awesome Lists containing this project

README

        





Aiken Vodka - Library for Aiken Development

[![Licence](https://img.shields.io/github/license/sidan-lab/vodka)](https://github.com/sidan-lab/vodka/blob/main/LICENSE)
[![Continuous Integration](https://github.com/sidan-lab/vodka/actions/workflows/build_docs.yml/badge.svg?branch=main)](https://github.com/sidan-lab/vodka/actions/workflows/build_docs.yml)
[![Twitter/X](https://img.shields.io/badge/Follow%20us-@sidan__lab-blue?logo=x)](https://x.com/sidan_lab)



Vodka is a library build for [Aiken](https://aiken-lang.org/) development. It offers

1. [Cocktail](https://sidan-lab.github.io/vodka/cocktail.html) - Validating utils in writing on-chain code in aiken
2. [Mocktail](https://sidan-lab.github.io/vodka/mocktail.html) - 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.6 | ^v1.1.5 | v2.1.0 |
| 0.0.1-beta | v1.0.29-alpha | v1.9.0 |

## Vodka is pure and simple

For your transaction.

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

Locating inputs & outputs:

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

Checking signature with:

```rs
key_signed(extra_signatories, key_hash_required)
```

## Imports and function groups

All onchain utility functions can be imported from `cocktail` and are grouped with a naming convention of `vodka_`.

```ak
use cocktail.{}
```

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

## 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](https://whisky.sidan.io/) and [Mesh](https://meshjs.dev/).

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

```rs
# 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:

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

```

Or Mesh:

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

## Start mixing

Simply run

```sh
aiken add sidan-lab/vodka --version 0.1.6
```

or putting the below in you `aiken.toml`

```toml
[[dependencies]]
name = "sidan-lab/vodka"
version = "0.1.6"
source = "github"
```

## Documentation

Please refer to the [hosted documentation](https://sidan-lab.github.io/vodka/).

![Alt](https://repobeats.axiom.co/api/embed/54410212b620c3299be792bde8965a3371348895.svg "Repobeats analytics image")