A comprehensive template for creating AI agents using the Bitte Protocol with Next.js. This boilerplate demonstrates best practices for building blockchain-enabled AI agents with pre-configured tools and endpoints.
- π€ Complete AI Agent Setup - Pre-configured agent manifest with OpenAPI specification
- π Blockchain Integration - Built-in support for NEAR and EVM transactions
- π οΈ Ready-to-Use Tools:
- Blockchain information retrieval
- NEAR & EVM transaction generation with wallet integration
- Ethereum message signing (eth_sign, personal_sign, typed data)
- User account & EVM address retrieval
- Twitter share intent generation
- Coin flip functionality
- β‘ Next.js 15 with App Router and TypeScript
- π¨ Modern Development Stack - Tailwind CSS, ESLint, TypeScript
- π One-Command Development - Integrated with
make-agent
for seamless development - π Production Ready - Built-in deployment scripts and Vercel integration
- Node.js 18+ and pnpm
- A Bitte wallet account
- Git
git clone https://github.com/BitteProtocol/agent-next-boilerplate.git
cd agent-next-boilerplate
pnpm install
Create a .env.local
file:
# Required: Get your API key from https://key.bitte.ai
BITTE_API_KEY='your-api-key'
# Required: Your NEAR account ID (e.g., yourname.near)
ACCOUNT_ID='your-account.near'
# Optional: For local development
NEXT_PUBLIC_HOST='localhost'
PORT=3000
pnpm run dev
This command will:
- Start your Next.js application on
http://localhost:3000
- Launch
make-agent
development mode - Prompt you to sign a message in your Bitte wallet to authenticate
- Open your agent in the Bitte playground for testing
- Enable hot reload for seamless development
# Build without deployment
pnpm run build
# Build and deploy to production
pnpm run build:deploy
The boilerplate includes six fully functional tools that demonstrate different agent capabilities:
- Purpose: Returns a randomized list of 3 blockchain networks
- Implementation: Static list with random selection
- Use Case: Demonstrating simple data retrieval and randomization
- Purpose: Creates NEAR transaction payloads for token transfers
- Parameters:
receiverId
(NEAR account),amount
(NEAR tokens) - Implementation: Converts amounts to yoctoNEAR (10^24) for precision
- Integration: Works with Bitte's
generate-transaction
tool for wallet execution
- Purpose: Creates EVM transaction payloads for ETH transfers
- Parameters:
to
(recipient address),amount
(ETH amount) - Implementation: Uses viem for proper ETH amount parsing
- Integration: Works with Bitte's
generate-evm-tx
tool for wallet execution
- Purpose: Creates various Ethereum signature requests
- Methods:
eth_sign
,personal_sign
,eth_signTypedData
,eth_signTypedData_v4
- Parameters:
evmAddress
,chainId
,method
,message
- Implementation: Supports both simple messages and typed data structures
- Purpose: Returns user's NEAR account ID and EVM address
- Context-Aware: Automatically populated by Bitte's context system
- Use Case: Accessing authenticated user information within agent flows
- Purpose: Generates Twitter share intent URLs
- Parameters:
text
(required),url
,hashtags
,via
- Implementation: Proper URL encoding for all parameters
- Use Case: Social sharing and engagement features
- Purpose: Simple randomization tool returning "heads" or "tails"
- Implementation: Cryptographically random using Math.random()
- Use Case: Demonstrating simple random functionality
The agent is configured through the AI plugin manifest at /api/ai-plugin/route.ts
. This endpoint returns an OpenAPI specification that defines:
{
name: "Blockchain Assistant",
description: "An assistant that answers with blockchain information...",
instructions: "You create near and evm transactions, give blockchain information...",
tools: [
{ type: "generate-transaction" }, // NEAR transactions
{ type: "generate-evm-tx" }, // EVM transactions
{ type: "sign-message" } // Message signing
],
categories: ["DeFi", "DAO", "Social"],
chainIds: [1, 8453] // Ethereum Mainnet, Base
}
- Tool Integration: The agent uses Bitte's built-in tools (
generate-transaction
,generate-evm-tx
,sign-message
) to execute blockchain operations - Two-Step Process: Your endpoints generate transaction payloads, then Bitte's tools execute them in the user's wallet
- Chain Support: Currently configured for Ethereum Mainnet (1) and Base (8453)
- Deployment URL: Automatically detected from Vercel or environment variables
Variable | Required | Description | Example |
---|---|---|---|
BITTE_API_KEY |
β | Your Bitte API key from key.bitte.ai | bitte_key_... |
ACCOUNT_ID |
β | Your blockchain account ID | walletaddresss |
NEXT_PUBLIC_HOST |
β | Development host | localhost |
PORT |
β | Development port | 3000 |
NEXT_PUBLIC_BASE_URL |
β | Base URL for assets | https://yourdomain.com |
# Development with hot reload and make-agent
pnpm run dev
# Next.js development only (without make-agent)
pnpm run dev:agent
# Production build (local)
pnpm run build
# Build and deploy to production
pnpm run build:deploy
# Linting
pnpm run lint
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard:
BITTE_API_KEY
ACCOUNT_ID
- Deploy! The build process automatically runs
make-agent deploy
# Build and deploy manually
pnpm run build:deploy
To add your own tools to the agent:
// src/app/api/tools/my-tool/route.ts
import { NextResponse } from 'next/server';
export async function GET(request: Request) {
const { searchParams } = new URL(request.url);
const param = searchParams.get('param');
// Your tool logic here
return NextResponse.json({ result: 'success' });
}
Update /api/ai-plugin/route.ts
:
paths: {
// ... existing paths
"/api/tools/my-tool": {
get: {
summary: "My custom tool",
description: "Description of what your tool does",
operationId: "my-tool",
parameters: [
{
name: "param",
in: "query",
required: true,
schema: { type: "string" }
}
],
responses: {
"200": {
description: "Successful response",
content: {
"application/json": {
schema: {
type: "object",
properties: {
result: { type: "string" }
}
}
}
}
}
}
}
}
}
Modify the instructions
field in the agent configuration to include guidance on when and how to use your new tool.
- @bitte-ai/agent-sdk - Core SDK for Bitte integration
- make-agent - Development and deployment tooling
- viem - TypeScript Ethereum library for transaction handling
- Next.js 15 - React framework with App Router
- vercel-url - Automatic deployment URL detection
- π Bitte Protocol Documentation
- π¬ Join our Telegram - Get help and connect with other developers
- π Report Issues
- π Next.js Documentation
- π OpenAPI Specification
agent-next-boilerplate/
βββ src/app/
β βββ api/
β β βββ ai-plugin/route.ts # Agent manifest endpoint
β β βββ tools/ # Tool endpoints
β β βββ get-blockchains/
β β βββ create-near-transaction/
β β βββ create-evm-transaction/
β β βββ eth-sign-request/
β β βββ get-user/
β β βββ twitter/
β β βββ coinflip/
β βββ config.ts # Environment configuration
β βββ layout.tsx # Root layout
β βββ page.tsx # Home page
βββ public/ # Static assets
βββ package.json # Dependencies and scripts
βββ README.md # This file
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
MIT License - see LICENSE file for details.
Built with β€οΈ using Bitte Protocol