Repository avatar
AI Tools
v2.46.0
active

cardano-tools

io.github.wutzebaer/cardano-tools

Cardano mainnet data: staking check, stake pools, governance votes, tokens and transactions.

Documentation

Cardano Tools is a Next.js dApp: every transaction is built in the browser and signed by the user's CIP-30 wallet. Chain data comes from cardano-db-sync-api.

Besides the pages the server does a few things of its own:

  • /api/tx/<hash>/confirmed tells a page whether its transaction is on-chain.
  • /api/stats counts page views and transactions sent from the site, without cookies. The counts are kept in stats.json in ALERTS_DIR and are served to Prometheus inside the server's network only.
  • /api/sync-status feeds the banner that says when the chain data is catching up or being rebuilt. It asks Prometheus and the Pushgateway of the pool.
  • /api/mcp is an MCP server for AI agents (Streamable HTTP, stateless, app/mcp): staking check, pools, governance, tokens and transactions for free, with a limit per IP. The staking rewards report of a year is paid per call in ADA with x402 (@x402/mcp, @x402/cardano, scheme exact). The agent hands over a signed, unsent payment; the server checks it, makes the report and only then sends the payment, so a failed report costs nothing. The pool's own x402 facilitator at X402_FACILITATOR_URL checks and sends the payments. Transactions that paid for a report are kept in mcp-payments.json in ALERTS_DIR, so one payment buys one report. Without MCP_PAY_TO and X402_FACILITATOR_URL the paid tool is not offered. /mcp/test (not linked) pays for one report with a browser wallet, for an end-to-end test. The server is listed in the official MCP Registry as io.github.wutzebaer/cardano-tools; after a release set the version in server.json and run mcp-publisher login github and mcp-publisher publish.
  • /pool-post/<kind>/<epoch> draws the pictures for the posts about the pool.
  • The Telegram alert bot (app/alerts): with TELEGRAM_BOT_TOKEN set, the server process polls the bot for subscriptions and checks the subscribed stake addresses once an hour, by the rules of the staking check, and their timelocks every minute. Subscriptions (chat id, stake address, alerts already sent) are kept in alerts.json in ALERTS_DIR, /data by default, which should be a volume. With TELEGRAM_POOL_CHAT_ID set it also posts the plan and the result of every epoch and each block of the pool to that chat. Run only one instance with the token.

Pages

RouteWhat it does
/Start page: every tool in short, the staking check and the pool behind the site
/wrappedCardano Wrapped: the year of an address in one shareable picture (rewards, transactions, pool, vote), without balances
/checkStaking check of any address: pool status and fees, governance vote, rewards, with a shareable page per address
/votesOpen and recent governance actions in plain words, with the votes of an address's DRep and pool (/governance/ is taken by the static rationale files)
/browseLatest tokens, search by policy id, fingerprint or $handle, token details with policy lock status
/myTokens of the connected wallet or any address
/mintMint CIP-68 NFTs and fungible tokens, one or many per transaction, with additional files and a JSON editor for the metadata
/dropNFT drops: tokens that are minted by a contract when they are bought (contracts/drop). A drop is created on the mint page, /drop lists the own ones and /drop/<policy id> sells one
/burnBurn tokens of own policies, including their CIP-68 reference NFT
/timelockLock ADA and tokens at a native script until a date and take them back afterwards
/closeEmpty a wallet into a new address, tokens included, in as many transactions as it takes, optionally deregistering the stake key
/rewardsDistribute ADA and tokens to the delegators of a pool
/statementWallet statement with fiat values and CSV export
/taxStaking rewards per epoch with their value on the payout day, totals per year, CSV and print view
/guidesShort guides to common questions (withdrawing rewards, taxes, minting), each leading to its tool
/poolThe Cardano Tools pool [TOOLS] and delegation
/koiosDocumentation of the public Koios API the pool serves, with every endpoint to try (public/specs/koios.yaml, written by scripts/koios-spec.sh)
/mcpThe MCP server for AI agents: address, how to add it to Claude, ChatGPT, Cursor and VS Code, its tools and prices
/legalImprint, privacy and terms

Policies

A new policy is all [sig <wallet payment key>, before <slot>], so the wallet signs for it and nothing secret has to be stored. Policies are found again through the wallet's mints on-chain; until the first mint they are kept in the browser's local storage.

Policies of the previous Cardano Tools had their key generated on the server. They can be imported on the mint page with script and signing key, which then stay in local storage and sign next to the wallet.

Getting Started

npm install
npm run dev

Open http://localhost:3333. The home page lists the tools, the token feed is at /browse.

Configuration in .env:

VariablePurpose
CARDANO_DBSYNC_API_URLBase URL of cardano-db-sync-api, e.g. http://localhost:8080/cardanoDbSyncApi
NEXT_PUBLIC_CARDANO_NETWORKmainnet (default), preprod or preview. Sets slot and epoch arithmetic, the network the wallet has to be on and the explorer links. The API has to serve a db-sync of the same network
IPFS_API_URLIPFS node API used to upload and pin files while minting, e.g. http://localhost:5001
IPFS_UPLOAD_FILES_PER_DAYOptional. Files one visitor may store on IPFS within a day, 25000 if not set
IPFS_UPLOAD_GB_PER_DAYOptional. GB one visitor may store on IPFS within a day, 20 if not set
IPFS_UPLOAD_TOTAL_GB_PER_DAYOptional. GB all visitors together may store on IPFS within a day, 100 if not set
NEXT_PUBLIC_SITE_URLOptional. Public address of the site for links in previews and bot messages, https://cardano-tools.io if not set
ALERTS_DIROptional. Folder for alerts.json, stats.json and mcp-payments.json, /data if not set
MCP_PAY_TOOptional. Address the paid MCP tools are paid to; without it they are not offered
X402_FACILITATOR_URLOptional. x402 facilitator that checks and sends the payments, https://x402.cardano-tools.io live
MCP_REPORT_PRICE_LOVELACEOptional. Price of the rewards report in lovelace; 1000000 (1 ADA, about the smallest output Cardano takes) if not set or lower
TELEGRAM_BOT_TOKENOptional. Token of the Telegram bot; without it the bot does not run
TELEGRAM_POOL_CHAT_IDOptional. Id of the chat the posts about the pool go to; without it nothing is posted
PROMETHEUS_URLOptional. Prometheus that scrapes db-sync, for the sync banner, http://prometheus:9090 if not set
PUSHGATEWAY_URLOptional. Pushgateway with the numbers of the leaderlog job and the rebuild notice, http://prometheus-pushgateway:9091 if not set

Refresh the OpenAPI types after API changes:

npm run update-schema

Checks

npm run lint
npm test        # the logic that needs neither a wallet nor the chain, one file per area in tests/
npm run build

Docker

docker build -t wutzebaer/cardano-tools2 .
docker run -p 3000:3000 -e CARDANO_DBSYNC_API_URL=http://cardano-db-sync-api:8080/cardanoDbSyncApi -e IPFS_API_URL=http://ipfs:5001 wutzebaer/cardano-tools2

The network is compiled in, a testnet image needs --build-arg NEXT_PUBLIC_CARDANO_NETWORK=preview. The build does not need the API.

Releases

Images are tagged with the version from package.json, which the sidebar also shows. scripts/release.sh raises it (patch by default, or minor / major), tags the commit as v1.2.3, then builds and pushes wutzebaer/cardano-tools2:1.2.3.

External services

Besides cardano-db-sync-api the app talks to the wallet, the IPFS node, Kraken's public market data (prices for the wallet statement), the Anvil API (collection names), and with the bot running to Telegram. Signed transactions are submitted by the wallet alone.

No installation packages available.