Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Examples Server

The whisky-examples crate provides runnable transaction examples and an HTTP server that exposes them as API endpoints.

Running the Server

cargo run --package whisky-examples

The server starts on http://127.0.0.1:8080 with CORS enabled.

Available Endpoints

EndpointMethodDescription
/send_lovelacePOSTSend ADA to a recipient
/lock_fundPOSTLock funds at a script address with datum
/unlock_fundPOSTUnlock funds from a Plutus script
/mint_tokensPOSTMint tokens with a Plutus minting policy

Example: Send Lovelace

curl -X POST http://127.0.0.1:8080/send_lovelace \
  -H "Content-Type: application/json" \
  -d '{
    "recipientAddress": "addr_test1...",
    "myAddress": "addr_test1...",
    "inputs": [
      {
        "input": {
          "txHash": "abcdef...",
          "outputIndex": 0
        },
        "output": {
          "address": "addr_test1...",
          "amount": [{"unit": "lovelace", "quantity": "10000000"}]
        }
      }
    ]
  }'

Response:

{
  "txHex": "84a400..."
}

Example Functions

The transaction functions are in packages/whisky-examples/src/tx/:

FileFunctionType
send_lovelace.rssend_lovelaceSync
lock_fund.rslock_fundSync
unlock_fund.rsunlock_fundAsync
mint_tokens.rsmint_tokensAsync
delegate_stake.rsdelegate_stakeSync
complex_transaction.rscomplex_transactionAsync
collateral_return.rscollateral_returnAsync

These examples serve as both documentation and testable reference implementations. See the Transaction Builder guide for detailed explanations of each pattern.