Vodka is a library build for Aiken development. It offers
- Cocktail - Validating utils in writing on-chain code in aiken
- Mocktail - Unit test utils for easy building mock value for unit test
Simply run
aiken add sidan-lab/vodka --version 0.1.8
or putting the below in you aiken.toml
[[dependencies]]
name = "sidan-lab/vodka"
version = "0.1.8"
source = "github"
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.8 | ^v1.1.9 | v2.2.0 |
0.1.6 | ^v1.1.5 | v2.1.0 |
0.0.1-beta | v1.0.29-alpha | v1.9.0 |
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 can be imported from cocktail
and are grouped with a naming convention of vodka_<type>
.
use cocktail.{<the_util_fn>}
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>} |
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();
All CIP supporting utility can be imported under cip
use cip.{cip68_100}
let reference_token_name = cip68_100(asset_name)
Please refer to the hosted documentation.