Skip to content

Latest commit

 

History

History
92 lines (66 loc) · 3.53 KB

README.md

File metadata and controls

92 lines (66 loc) · 3.53 KB

Clean, Build IntegrationTest

Aiken Java Binding

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:

Current Limitations

  • The current version doesn't work for a transaction with reference inputs. Issue

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.

Supported Operating Systems / Archs

  • Apple MacOS (Intel and Apple Silicon)
  • Linux (x86_64) (Ubuntu 20.04 or compatible ...)
  • Windows 64bits (x86_64)

For another platform, please create a PR / request here

Dependencies

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}'

Other dependencies

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>

How to use ?

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);

Any questions, ideas or issues?

If this project helps you reduce time to develop on Cardano or if you just want to support this project, you can delegate to our pool:

BLOXB

Support this project