Skip to content

Test locally with Yaci DevKit

You can run every tutorial on this site in one of two places: a devnet on your own machine, or a public test network. Both use the same code, and only the backend line changes.

Yaci DevKit (local)Preview or Preprod (public)
SetupInstall and start it onceNothing to install. Blockfrost needs a free project id; Koios doesn’t
Test adaFunded accounts, plus a top-up commandA faucet
Block time1 second by defaultAbout 20 seconds on average
Epoch length600 slots by default, and you can change it1 day on Preview, 5 days on Preprod
Who sees itOnly youEveryone, permanently
Start overReset whenever you likeNot possible

Use DevKit while you’re developing, because the feedback is fast and mistakes cost nothing. Before you release, run once on Preview: a public network has real delays that a devnet hides.

Pick the setup that suits your machine. Get started with Yaci DevKit has these and the other options, npm and Zip.

The whole stack in containers, including Yaci Viewer. Docker must be running.

Terminal window
curl --proto '=https' --tlsv1.2 -LsSf https://devkit.yaci.xyz/install.sh | bash
devkit start

This opens the Yaci CLI prompt. Create and start a devnet there. The -o option overwrites any devnet you already have.

yaci-cli:> create-node -o --start

Yaci Viewer opens at http://localhost:5173.

In another terminal, check that the devnet’s API is answering:

Terminal window
curl http://localhost:8080/api/v1/epochs/latest

Both setups leave you at an interactive prompt, devnet:default>, where you can manage the devnet. Keep that terminal open while you work.

devnet:default> topup <address> 100 # send 100 ada to an address
devnet:default> utxos <address> # list an address's UTxOs
devnet:default> info # show the devnet's settings
devnet:default> reset # delete all data and restart

The command reference lists the rest. For a test pipeline that doesn’t need a prompt, leave out --interactive and fund accounts over HTTP.

Yaci Viewer is a block explorer for your devnet, in your browser. Use it to look up the blocks, transactions and addresses that your code creates.

DevKit includes Yaci Store, which serves a Blockfrost-compatible API. So you use the Blockfrost backend with a local URL, and any value for the key:

BackendService backend = new BFBackendService("http://localhost:8080/api/v1/", "dummy-key");

A new devnet has 20 funded addresses, each with 10,000 ada, derived from one well-known mnemonic. Use it to get going right away:

String mnemonic = "test test test test test test test test test test test test "
+ "test test test test test test test test test test test sauce";
Account sender = Account.createFromMnemonic(Networks.testnet(), mnemonic);

To fund any other address, use topup at the Yaci CLI prompt. This sends it 100 ada:

devnet:default> topup <address> 100

Tests can do the same over HTTP:

Terminal window
curl -X POST http://localhost:10000/local-cluster/api/addresses/topup \
-H "Content-Type: application/json" \
-d '{"address": "<address>", "adaAmount": 100}'

This is the transaction from Your first transaction, running on your devnet. You need cardano-client-lib and cardano-client-backend-blockfrost from Installation.

import com.bloxbean.cardano.client.account.Account;
import com.bloxbean.cardano.client.api.model.Amount;
import com.bloxbean.cardano.client.backend.api.BackendService;
import com.bloxbean.cardano.client.backend.blockfrost.service.BFBackendService;
import com.bloxbean.cardano.client.common.model.Networks;
import com.bloxbean.cardano.client.function.helper.SignerProviders;
import com.bloxbean.cardano.client.quicktx.QuickTxBuilder;
import com.bloxbean.cardano.client.quicktx.Tx;
import com.bloxbean.cardano.client.quicktx.TxResult;
public class LocalTransfer {
public static void main(String[] args) {
BackendService backend = new BFBackendService("http://localhost:8080/api/v1/", "dummy-key");
String mnemonic = "test test test test test test test test test test test test "
+ "test test test test test test test test test test test sauce";
Account sender = Account.createFromMnemonic(Networks.testnet(), mnemonic);
Account receiver = new Account(Networks.testnet());
Tx tx = new Tx()
.payToAddress(receiver.baseAddress(), Amount.ada(10))
.from(sender.baseAddress());
TxResult result = new QuickTxBuilder(backend)
.compose(tx)
.withSigner(SignerProviders.signerFrom(sender))
.completeAndWait();
System.out.println(result.getTxStatus() + " " + result.getTxHash());
}
}

It prints CONFIRMED and the transaction hash within a few seconds. Paste the hash into Yaci Viewer to see the transaction.

Change the backend, and use an account you funded from the faucet in place of the devnet mnemonic. The rest of your code stays the same:

// Preview, through Blockfrost
BackendService backend = new BFBackendService(Constants.BLOCKFROST_PREVIEW_URL, "<Blockfrost Project Id>");

Expect two differences:

  • Slower confirmation. Allow minutes rather than seconds, for example with completeAndWait(Duration.ofMinutes(5)). If it times out, the status is TIMEOUT and the transaction may still land.
  • Delays in the backend’s view. A confirmed transaction’s outputs can take a little while to appear in UTxO queries, so a step that spends them straight away may not find them. Retry that query instead of assuming they’re there.
  • Staking and governance. The staking lifecycle spans several epochs, which takes minutes on a devnet instead of days. The --epoch-length option of create-node makes them shorter.
  • Starting over. reset at the Yaci CLI prompt deletes the devnet’s data and restarts it.
  • Rollbacks. DevKit can also simulate rollbacks, which is useful for testing TxFlow.
  • Other commands. See the command reference and the services DevKit can run.

Next, mint and distribute your own tokens.