Skip to content

Simulates a cardano transaction with aiken tx simulate and Koios.

Notifications You must be signed in to change notification settings

logical-mechanism/Tx-Simulation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tx_simulation

The tx_simulation tool facilitates transaction simulation using aiken tx simulate in conjunction with Koios.

The simulation script assumes the contracts are implemented using PlutusV2, relies on reference script UTxOs, and operates under the assumption that within a transaction, only the script UTxOs have datums. tx_simulation currently supports the mainnet and pre-production environments. Support for the preview environment is not implemented at this time.

The tx simulation script was tested with Python 3.10.12, Aiken v1.1.0, and Ubuntu 22.04.2 LTS.

Requirements

It is highly suggested that Aiken is installed and on path.

Install Aiken

A precompile version of Aiken may be used with the from_file or from_cbor functions.

Development

It is highly suggested to work on tx_simulation inside a virtual environment.

# Create a Python virtual environment
python3 -m venv venv

# Activate the virtual environment
source venv/bin/activate

# Install required Python packages
pip install -r requirements.txt

Use

The tx_simulation script can simulate a transaction from a transaction file or from pure cbor.

import tx_simulation

# can be used on a tx.draft file
execution_units = tx_simulation.from_file('path/to/tx.draft')

# can be used directory on the tx cbor
execution_units = tx_simulation.from_cbor(tx_cbor)

It will either return a list of dictionaries of the execution units or a list with an empty dict if it fails. An output example is shown below.

Success example:

[{
    "mem": 443656, 
    "cpu": 171399581
}]

Failure example:

[{}]

Testing

Inside the tests folder are pytest tests for tx_simulation. The tests can be ran with the command below.

pytest

About

Simulates a cardano transaction with aiken tx simulate and Koios.

Resources

Stars

Watchers

Forks

Packages

No packages published