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) | |
|---|---|---|
| Setup | Install and start it once | Nothing to install. Blockfrost needs a free project id; Koios doesn’t |
| Test ada | Funded accounts, plus a top-up command | A faucet |
| Block time | 1 second by default | About 20 seconds on average |
| Epoch length | 600 slots by default, and you can change it | 1 day on Preview, 5 days on Preprod |
| Who sees it | Only you | Everyone, permanently |
| Start over | Reset whenever you like | Not 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.
Start a devnet
Section titled “Start a devnet”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.
curl --proto '=https' --tlsv1.2 -LsSf https://devkit.yaci.xyz/install.sh | bashdevkit startThis 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 --startYaci Viewer opens at http://localhost:5173.
The native CLI, for macOS 15+ or Linux. You don’t need Docker.
brew install bloxbean/tap/yaci-devkityaci-devkit up --enable-yaci-store --interactiveYaci Viewer isn’t included with this setup. To add it, run these in another terminal:
npm install -g @bloxbean/yaci-vieweryaci-viewerIt opens at http://localhost:3000.
In another terminal, check that the devnet’s API is answering:
curl http://localhost:8080/api/v1/epochs/latestUse the Yaci CLI prompt
Section titled “Use the Yaci CLI prompt”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 addressdevnet:default> utxos <address> # list an address's UTxOsdevnet:default> info # show the devnet's settingsdevnet:default> reset # delete all data and restartThe command reference lists the rest. For a test pipeline that doesn’t need a prompt, leave out --interactive and fund accounts over HTTP.
See your transactions in Yaci Viewer
Section titled “See your transactions in Yaci Viewer”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.
Connect from Java
Section titled “Connect from Java”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");Fund an account
Section titled “Fund an account”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> 100Tests can do the same over HTTP:
curl -X POST http://localhost:10000/local-cluster/api/addresses/topup \ -H "Content-Type: application/json" \ -d '{"address": "<address>", "adaAmount": 100}'Send a transaction
Section titled “Send a transaction”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.
Move to a public network
Section titled “Move to a public network”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 BlockfrostBackendService 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 isTIMEOUTand 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.
Going further
Section titled “Going further”- Staking and governance. The staking lifecycle spans several epochs, which takes minutes on a devnet instead of days. The
--epoch-lengthoption ofcreate-nodemakes them shorter. - Starting over.
resetat 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.