1.2.14 • Published 4 months ago

cardano-agent-kit v1.2.14

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
4 months ago

Cardano Agent Kit šŸ› ļø

A TypeScript SDK for interacting with the Cardano blockchain, include integration with Vercel AI, Langchain, Eliza...

npm version License: Apache 2.0


šŸš€ Features

āœ… Create & Restore Cardano Wallets

āœ… Get Wallet Balance (ADA + Native Assets)

āœ… Send ADA (Lovelace) Transactions

āœ… Sign & Submit Transactions

āœ… Stake & Delegate ADA to Stake Pools

āœ… Mint & Burn Tokens / NFTs

āœ… Fetch Transaction History

āœ… AI-powered Blockchain Tools (Vercel AI & Langchain integration)

āœ… Dynamic Toolset Creation for AI Models

āœ… Exported Actions (e.g., create wallet, send ADA, burn assets)

āœ… Support for Blockfrost, Koios, Maestro, and U5C Providers


šŸ“¦ Installation

Install via npm:

npm install cardano-agent-kit

or via yarn:

yarn add cardano-agent-kit

šŸ›  Usage Example

1ļøāƒ£ Import the SDK

import { CardanoToolKit } from 'cardano-agent-kit';

2ļøāƒ£ Initialize Wallet

const API_KEY = 'your_blockfrost_api_key';
const TEST_MNEMONIC = [
    'churn',
    'analyst',
    'debate',
    'million',
    'tattoo',
    'enlist',
    'crystal',
    'slide',
    'gallery',
    'airport',
    'squeeze',
    'live',
    'dinosaur',
    'rough',
    'first',
    'south',
    'cave',
    'clerk',
    'divorce',
    'attend',
    'topic',
    'idea',
    'finger',
    'verify',
];

const toolkit = new CardanoToolKit('blockfrost', API_KEY, 'testnet', TEST_MNEMONIC);

3ļøāƒ£ Get Wallet Address

const address = await toolkit.getAddress();
console.log('Wallet Address:', address);

4ļøāƒ£ Check Wallet Balance

const balance = await toolkit.getBalance();
console.log('Wallet Balance:', balance);

5ļøāƒ£ Send ADA (Lovelace)

const recipient = 'addr_test1qz...';
const txHash = await toolkit.sendLovelace(recipient, '1000000'); // 1 ADA
console.log('āœ… Transaction Sent! TX Hash:', txHash);

6ļøāƒ£ Delegate to a Stake Pool

const stakePoolId = 'pool1a7h89sr6ymj9g2a9tm6e6dddghl64tp39pj78f6cah5ewgd4px0';
const stakingTxHash = await toolkit.registerAndStakeADA(stakePoolId);
console.log('āœ… Staking TX Hash:', stakingTxHash);

🧠 AI-Powered Dynamic Tools

Cardano Agent Kit supports AI-powered blockchain tools using Vercel AI SDK and Langchain.

⚔ Create AI-powered Vercel Tools

import { CardanoToolKit, createVercelCardanoTools } from 'cardano-agent-kit';

const toolkit = new CardanoToolKit('blockfrost', API_KEY, 'testnet', TEST_MNEMONIC);
const aiTools = createVercelCardanoTools(toolkit);

šŸ¤– Create AI-powered Langchain Tools

import { CardanoToolKit, createLangchainCardanoTools } from 'cardano-agent-kit';

const toolkit = new CardanoToolKit('blockfrost', API_KEY, 'testnet', TEST_MNEMONIC);
const aiTools = createLangchainCardanoTools(toolkit);

šŸ”€ Create Dynamic Toolsets

Cardano Agent Kit allows dynamic creation of AI tools for blockchain interactions.

Create AI-powered tools dynamically for Vercel AI

import { CardanoToolKit, createVercelAITools } from 'cardano-agent-kit';
import { getAddress, sendLovelace, getBalance, createWallet, mintAsset, burnAsset, sendAsset } from 'cardano-agent-kit';

const toolkit = new CardanoToolKit('blockfrost', API_KEY, 'testnet', TEST_MNEMONIC);
const aiTools = createVercelAITools(toolkit, [
    sendAsset,
    mintAsset,
    burnAsset,
    getAddress,
    sendLovelace,
    getBalance,
    createWallet,
]);

Create AI-powered tools dynamically for Langchain

import { CardanoToolKit, createLangchainTools } from 'cardano-agent-kit';
import { getAddress, sendLovelace, getBalance, createWallet, mintAsset, burnAsset, sendAsset } from 'cardano-agent-kit';

const toolkit = new CardanoToolKit('blockfrost', API_KEY, 'testnet', TEST_MNEMONIC);
const aiTools = createLangchainTools(toolkit, [
    sendAsset,
    mintAsset,
    burnAsset,
    getAddress,
    sendLovelace,
    getBalance,
    createWallet,
]);

šŸ”¬ API Reference

Wallet Functions

FunctionDescription
createWallet()Creates a new wallet and returns its mnemonic.
getMnemonic()Returns the wallet mnemonic (if available).
getPrivateKey()Returns the Bech32 private key (if available).
getAddress()Fetches the primary wallet address.
getBalance()Fetches all assets in the wallet (ADA + tokens).
sendLovelace(address, amount)Sends ADA to a recipient.
signAndSendTx(txHex)Signs and submits a transaction.

Staking Functions

FunctionDescription
registerAndStakeADA(poolId)Registers a stake address and delegates to a stake pool.

Asset Functions

FunctionDescription
mintAsset(name, quantity, recipient, metadata, label)Mints a new Cardano token/NFT.
burnAsset(assetUnit, quantity)Burns a specific amount of an asset.
sendAsset(recipient, assetUnit, quantity)Transfers a Cardano asset (NFT or token).

Transaction Functions

FunctionDescription
getTransactionHistory()Retrieves the transaction history with details on senders, recipients, and amounts.

AI-Powered Tools

FunctionDescription
createVercelCardanoTools(toolkit)Creates AI-powered Cardano tools using Vercel AI SDK.
createLangchainCardanoTools(toolkit)Creates AI-powered Cardano tools using Langchain.
createVercelAITools(toolkit, toolsList)Dynamically generates AI-powered blockchain tools for Vercel AI.
createLangchainTools(toolkit, toolsList)Dynamically generates AI-powered blockchain tools for Langchain.

šŸ›  Development

Run Tests

npm test

šŸ“œ License

This project is licensed under the MIT License. See the LICENSE file for details.


šŸ¤ Contributing

šŸ’” Contributions are welcome!

  • Open an issue
  • Submit a pull request

🌟 Support

If you find this project useful, please ⭐ star the repository and share it with the Cardano community!


āœ… What's New?

1ļøāƒ£ AI-powered Blockchain Interactions (Vercel AI & Langchain tools)

2ļøāƒ£ Dynamic Toolset Creation for AI Models

3ļøāƒ£ Enhanced Transaction History Functionality

4ļøāƒ£ Comprehensive API Documentation & Examples

1.2.0

4 months ago

1.2.8

4 months ago

1.2.6

4 months ago

1.2.5

4 months ago

1.2.4

4 months ago

1.2.3

4 months ago

1.2.2

4 months ago

1.2.1

4 months ago

1.2.12

4 months ago

1.2.10

4 months ago

1.2.11

4 months ago

1.2.14

4 months ago

1.1.12

4 months ago

1.1.11

4 months ago

1.1.10

4 months ago

1.1.16

4 months ago

1.1.15

4 months ago

1.1.14

4 months ago

1.1.13

4 months ago

1.2.9

4 months ago

1.1.1

4 months ago

1.0.19

4 months ago

1.1.0

4 months ago

1.0.18

4 months ago

1.0.17

4 months ago

1.1.9

4 months ago

1.1.8

4 months ago

1.1.7

4 months ago

1.1.6

4 months ago

1.1.5

4 months ago

1.1.4

4 months ago

1.1.3

4 months ago

1.1.2

4 months ago

1.0.20

4 months ago

1.0.16

4 months ago

1.0.11

4 months ago

1.0.15

4 months ago

1.0.14

4 months ago

1.0.13

4 months ago

1.0.12

4 months ago

1.0.9

4 months ago

1.0.8

4 months ago

1.0.7

4 months ago

1.0.6

4 months ago

1.0.5

4 months ago

1.0.4

4 months ago

1.0.10

4 months ago

1.0.3

5 months ago

1.0.2

5 months ago

1.0.1

5 months ago

1.0.0

5 months ago