core-agentkit
v0.1.3
Published
Framework-agnostic toolkit for building AI agents that interact with Core blockchain.
Maintainers
Readme
Core AgentKit
A framework-agnostic toolkit for building AI agents that interact with Core blockchain. Core AgentKit provides a comprehensive set of tools and building blocks for developers to create agents that can perform blockchain operations on the Core network.
Installation
# Core AgentKit
npm install core-agentkit
# Framework Extensions (optional)
npm install core-agentkit-langchain # LangChain integration
npm install core-agentkit-vercel-ai-sdk # Vercel AI SDK integrationQuick Start
- 🔗 Framework Agnostic: Works with any AI framework (LangChain, OpenAI, Vercel AI SDK, etc.)
- ⚡ Core Blockchain Native: Built specifically for Core's dual consensus mechanism
- 🪙 Bitcoin Staking: Support for Bitcoin staking operations on Core
- 💰 Token Operations: Transfer, swap, and manage CORE and ERC-20 tokens
- 🔒 Secure: Built with TypeScript and comprehensive input validation
- 📦 Modular: Use individual actions or the complete toolkit
- �️ Extensible: Add custom action providers for any functionality
Architecture
Core AgentKit follows a modular architecture pattern:
- Central AgentKit Class: Manages wallet providers and action providers
- Wallet Providers: Handle blockchain connections and wallet management
- Action Providers: Contain blockchain-specific actions and operations
- Framework Extensions: Adapters for popular AI frameworks
🚀 Quick Start
Installation
npm install core-agentkitBasic Usage
import {
AgentKit,
CoreWalletProvider,
coreActionProvider,
} from "core-agentkit";
// Create wallet provider
const walletProvider = new CoreWalletProvider(
process.env.PRIVATE_KEY!,
"core-testnet"
);
// Create AgentKit instance
const agentKit = AgentKit.from(walletProvider, [coreActionProvider()]);
// Get available actions
const actions = agentKit.getActions();
console.log(
"Available actions:",
actions.map((a) => a.name)
);
// Use specific actions
const balanceAction = agentKit.getAction("get_balance");
const result = await balanceAction.invoke({});
console.log("Balance:", result);Framework Integration
LangChain
import { getLangChainTools } from "core-agentkit-langchain";
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
const tools = await getLangChainTools(agentKit);
const model = new ChatOpenAI({ temperature: 0 });
const agent = createReactAgent({ llm: model, tools });
const result = await agent.invoke({
messages: [{ role: "user", content: "Check my CORE balance" }],
});Vercel AI SDK
import { getVercelAITools } from "core-agentkit-vercel-ai-sdk";
import { openai } from "@ai-sdk/openai";
import { generateText } from "ai";
const tools = getVercelAITools(agentKit);
const result = await generateText({
model: openai("gpt-4"),
prompt: "Transfer 1 CORE to 0x742d35Cc6634C0532925a3b8D9C0a0e7c5f2e2B3",
tools,
});🛠️ Features
- 🔗 Framework Agnostic: Works with any AI framework (LangChain, OpenAI, Vercel AI SDK, etc.)
- ⚡ Core Blockchain Native: Built specifically for Core's dual consensus mechanism
- 🪙 Bitcoin Staking: Support for Bitcoin staking operations on Core
- 💰 Token Operations: Transfer, swap, and manage CORE and ERC-20 tokens
- 🏗️ Extensible Architecture: Add custom action providers for any functionality
- �️ Type Safe: Full TypeScript support with comprehensive type definitions
Core Blockchain Actions
| Action | Description | Example Usage |
| ------------------- | ------------------------------- | -------------------------------- |
| get_balance | Check CORE token balance | Get balance for an address |
| transfer | Transfer CORE tokens | Send CORE to another address |
| get_token_balance | Check ERC-20 token balance | Get token balance for an address |
| transfer_token | Transfer ERC-20 tokens | Send tokens to another address |
| stake | Stake CORE tokens to validators | Stake CORE with a validator |
| unstake | Unstake CORE tokens | Unstake CORE from a validator |
Framework Integrations
- LangChain Integration: Convert AgentKit actions to LangChain tools
- Vercel AI SDK Integration: Use actions with Vercel AI SDK
- Framework Agnostic: Use with any AI framework or library
- Extensible Actions: Add custom action providers
Core Network Support
- Mainnet: Chain ID 1116, RPC: https://rpc.coredao.org
- Testnet: Chain ID 1114, RPC: https://rpc.test2.btcs.network
- EVM Compatibility: Full Ethereum tooling support
- Gas Optimization: Smart gas price estimation
📖 Core Blockchain Overview
Core blockchain is a Bitcoin-aligned EVM blockchain that serves as Bitcoin's complementary smart contract platform:
Key Features
- 🔐 Native Bitcoin Staking: Stake Bitcoin directly using CLTV timelocks
- ⚡ Dual Staking: Combine Bitcoin + CORE staking for enhanced yields
- 🔗 EVM Compatible: Deploy Ethereum dApps without modification
- 🏛️ Satoshi Plus Consensus: Combines Bitcoin mining with validator staking
- 🌉 Cross-Chain Bridge: LayerZero-powered bridging to major chains
Bitcoin Staking
Core's unique Self-Custodial Bitcoin Staking allows Bitcoin holders to:
- Earn Yield: Stake Bitcoin to earn CORE token rewards
- Maintain Custody: Bitcoin never leaves the Bitcoin network
- CLTV Timelocks: Use Bitcoin-native time-bound mechanisms
- Validator Delegation: Choose Core validators to delegate to
- Dual Staking: Stake both Bitcoin and CORE for higher yields
Dual Staking Benefits
| CORE:BTC Ratio | Yield Multiplier | Example APY | | -------------- | ---------------- | ----------- | | 0:1 | 1x | 5% | | 100:1 | 1.5x | 7.5% | | 200:1 | 2x | 10% | | 500:1 | 3x | 15% |
🔧 Configuration
Environment Variables
Create a .env file in your project root:
# Core Network Configuration
CORE_RPC_URL=https://rpc.coredao.org
CORE_TESTNET_RPC_URL=https://rpc.test2.btcs.network
# Private Key (for transactions)
PRIVATE_KEY=your_private_key_here
# OpenAI API Key
OPENAI_API_KEY=your_openai_api_key_here
# Gas Configuration
DEFAULT_GAS_LIMIT=21000
DEFAULT_GAS_PRICE=20000000000AgentKit Configuration
import {
AgentKit,
CoreWalletProvider,
coreActionProvider,
} from "core-agentkit";
// Create wallet provider with configuration
const walletProvider = new CoreWalletProvider(
process.env.PRIVATE_KEY!, // Your private key
"core-mainnet", // or "core-testnet"
{
rpcUrl: "https://rpc.coredao.org", // Custom RPC if needed
gasPrice: "20000000000", // Custom gas price
gasLimit: 21000, // Custom gas limit
}
);
// Create AgentKit with default actions
const agentKit = AgentKit.from(walletProvider);
// Or create with custom action providers
const customAgentKit = AgentKit.from(walletProvider, [
coreActionProvider(),
// Add your custom action providers here
]);📚 Examples
Check Balance
const balanceAction = agentKit.getAction("get_balance");
const result = await balanceAction.handler({
address: "0x742d35Cc6634C0532925a3b8D81C3f83C7A84C5e",
});
console.log(`Balance: ${result.balance} CORE`);Transfer Tokens
const transferAction = agentKit.getAction("transfer");
const result = await transferAction.handler({
to: "0x742d35Cc6634C0532925a3b8D81C3f83C7A84C5e",
amount: "1.5",
});
console.log(`Transaction hash: ${result.transactionHash}`);Stake CORE Tokens
const stakeAction = agentKit.getAction("stake");
const result = await stakeAction.handler({
validatorAddress: "0x1234567890123456789012345678901234567890",
amount: "10",
});
console.log(`Staking transaction: ${result.transactionHash}`);Get Token Balance
const tokenBalanceAction = agentKit.getAction("get_token_balance");
const result = await tokenBalanceAction.handler({
address: "0x742d35Cc6634C0532925a3b8D81C3f83C7A84C5e",
tokenAddress: "0xA0b86a33E6417Faf8b2D3d5A7b33f1F9B8e8e8e8", // USDT
});
console.log(`Token balance: ${result.balance}`);Framework Integration Examples
LangChain Integration
import { getLangChainTools } from "core-agentkit-langchain";
import { ChatOpenAI } from "@langchain/openai";
import { createReactAgent } from "@langchain/langgraph/prebuilt";
const tools = await getLangChainTools(agentKit);
const model = new ChatOpenAI({ temperature: 0 });
const agent = createReactAgent({ llm: model, tools });
const result = await agent.invoke({
messages: [{ role: "user", content: "Check my CORE balance" }],
});Vercel AI SDK Integration
import { getVercelAITools } from "core-agentkit-vercel-ai-sdk";
import { openai } from "ai";
const tools = await getVercelAITools(agentKit);
const result = await openai.chat.completions.create({
model: "gpt-4",
messages: [{ role: "user", content: "Transfer 1 CORE to 0x123..." }],
tools,
});🏗️ Custom Action Providers
Extend AgentKit with custom action providers:
import { ActionProvider, Action } from "core-agentkit";
// Define a custom action
const customAction: Action = {
name: "custom_action",
description: "Performs a custom operation",
parameters: {
type: "object",
properties: {
param: {
type: "string",
description: "A parameter for the custom action",
},
},
required: ["param"],
},
handler: async (params) => {
// Your custom logic here
return { result: `Custom action executed with: ${params.param}` };
},
};
// Create a custom action provider
const customActionProvider = (): ActionProvider => ({
name: "custom",
description: "Custom action provider",
actions: [customAction],
});
// Use with AgentKit
const agentKit = AgentKit.from(walletProvider, [
coreActionProvider(),
customActionProvider(),
]);🌐 Network Information
Mainnet
- Chain ID: 1116
- RPC URL: https://rpc.coredao.org
- Explorer: https://scan.coredao.org
- Bridge: https://bridge.coredao.org
- Staking: https://stake.coredao.org
Testnet
- Chain ID: 1114
- RPC URL: https://rpc.test2.btcs.network
- Explorer: https://scan.test2.btcs.network
- Faucet: https://scan.test2.btcs.network/faucet
- Staking: https://stake.test2.btcs.network
🔐 Security Considerations
- Private Keys: Never commit private keys to version control
- Environment Variables: Use
.envfiles for sensitive data - Testnet First: Always test on Core Testnet before mainnet
- Gas Limits: Monitor gas usage for complex operations
- Slippage: Set appropriate slippage for DEX operations
Development Setup
# Clone the repository
git clone https://github.com/core-dao/core-agentkit.git
cd core-agentkit
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Run examples
npm run examples📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Built with ❤️ for the Core DAO community
