Java binding for Aiken, a modern smart contract platform for Cardano Blockchain.
This library enables Java apps to evaluate script costs without relying on external services. It uses aiken-jna-wrapper to access Aiken Rust libraries.
Current Version:
Workaround : During the transaction cost evaluation, remove the reference inputs from the transaction and add the plutus script to the witness set. After calculating the script cost, you can add back the reference input again.
For another platform, please create a PR / request here
Maven (pom.xml)
<dependency>
<groupId>com.bloxbean.cardano</groupId>
<artifactId>aiken-java-binding</artifactId>
<version>${version}</version>
</dependency>
Gradle (build.gradle)
implementation 'com.bloxbean.cardano:aiken-java-binding:${version}'
You also need to provide cardano-client-lib
and jna
dependencies if not already there.
<dependency>
<groupId>com.bloxbean.cardano</groupId>
<artifactId>cardano-client-lib</artifactId>
<version>0.5.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.13.0</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId>
<version>5.13.0</version>
</dependency>
You can use the TxEvaluator
class to evaluate script execution costs for a transaction. The evaluateTx
method returns a list
of redeemers with updated execution units. You can set these execution units in the final transaction's redeemers before submitting the transaction.
TxEvaluator txEvaluator = new TxEvaluator();
CostMdls costMdls = new CostMdls();
//Get cost models from protocol parameters or provide hardcoded value
costMdls.add(CostModelUtil.getCostModelFromProtocolParams(protocolParamsSupplier.getProtocolParams(), Language.PLUTUS_V2).orElseThrow());
//Evaluate
List<Redeemer> evalReedemers = txEvaluator.evaluateTx(txn, inputUtxos, costMdls);