Skip to content

NachoLLMJS/bnkr-open-source

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BNKR — AI Agents Trading Memes on BNB Chain

Autonomous AI agents that live on-chain, hold their own wallets, chat with users, and trade meme tokens on four.meme — all running serverless on Vercel.


What is this?

BNKR lets you deploy AI agents that:

  • Chat with users in natural language (powered by OpenAI / dGrid)
  • Search the web in real time for crypto news and token info (via Tavily)
  • Launch meme tokens on four.meme autonomously
  • Buy and sell tokens on BNB Chain using their own encrypted wallets
  • Trade perpetuals on Aster DEX
  • Remember past interactions via Membase on-chain memory

Each agent has its own identity: name, avatar, personality, and a wallet whose private key is encrypted with AES-256-CBC and stored in Firestore — never exposed in plaintext.


Architecture

┌─────────────────────────────────────────────────┐
│                  Frontend (index.html)           │
│         Live2D mascot · chat UI · dashboard      │
└───────────────────┬─────────────────────────────┘
                    │ REST
┌───────────────────▼─────────────────────────────┐
│              Vercel Serverless API               │
│                                                  │
│  agent-chat.js        → AI chat + web search     │
│  agent-launch-token.js → launch token on 4.meme  │
│  agent-trade.js        → buy / sell tokens       │
│  agent-trade-perps.js  → Aster perp trades       │
│  agent-memory.js       → Membase read/write      │
│  store-agent-key.js    → encrypt & store wallet  │
└──────┬──────────────────────┬────────────────────┘
       │                      │
┌──────▼──────┐     ┌─────────▼──────────┐
│  Firebase   │     │    BNB Chain RPC    │
│  Firestore  │     │  four.meme · Aster  │
│(agent store)│     │  PancakeSwap DEX    │
└─────────────┘     └────────────────────┘

API Endpoints

Endpoint Description
POST /api/agent-chat Chat with agent, triggers web search if needed
POST /api/agent-launch-token Agent launches a new meme token on four.meme
POST /api/agent-trade Agent buys or sells a token on BSC
POST /api/agent-trade-perps Agent opens/closes a perp position on Aster
POST /api/agent-memory Read or write agent memory via Membase
POST /api/store-agent-key Encrypt and store a new agent wallet
POST /api/membase-init Initialize Membase identity for an agent

Tech Stack

  • Runtime: Node.js (Vercel serverless functions)
  • Blockchain: ethers.js v6 · BNB Chain mainnet
  • AI: OpenAI SDK (gpt-4o-mini) · dGrid AI Gateway fallback
  • Web search: Tavily API (multi-key rotation)
  • Storage: Firebase Firestore (REST API, no SDK)
  • Security: AES-256-CBC wallet encryption per agent
  • Memory: Membase on-chain agent memory
  • DEX: four.meme · PancakeSwap · Aster perps

Setup

1. Clone and install

git clone https://github.com/NachoStackJs/bnkr-open-source.git
cd bnkr-open-source
npm install

2. Configure environment

Copy .env.example to .env and fill in your values:

cp .env.example .env
Variable Description
OPENAI_API_KEY OpenAI API key
TAVILY_KEYS Comma-separated Tavily search keys
DGRID_API_KEY dGrid gateway key (OpenAI-compatible, optional)
FIREBASE_API_KEY Firebase project API key
FIREBASE_PROJECT_ID Firebase project ID
AGENT_KEY_SECRET Random secret used to derive AES encryption keys
MEMBASE_ACCOUNT Your wallet address for Membase identity
MEMBASE_SECRET_KEY Private key for Membase signing

3. Run locally

npm start
# or with Vercel CLI:
vercel dev

4. Deploy

vercel --prod

Set all environment variables in the Vercel dashboard before deploying.


How agent wallets work

Agent private keys are never stored in plaintext. When a new agent is registered:

  1. The private key is encrypted with AES-256-CBC using a key derived from AGENT_KEY_SECRET + agentAddress
  2. The encrypted key and IV are stored in Firestore
  3. At trade time, the server decrypts on the fly, signs the transaction, and discards the plaintext

Project structure

api/
  agent-chat.js          # AI chat with web search
  agent-launch-token.js  # Token launch on four.meme
  agent-trade.js         # Buy / sell on BSC
  agent-trade-perps.js   # Aster perpetuals
  agent-memory.js        # Membase read/write
  store-agent-key.js     # Wallet encryption + storage
  membase-init.js        # Membase identity init
  fourmeme.js            # four.meme API helpers
  chat.js                # Simple chat proxy
functions/               # Firebase Cloud Functions
index.html               # Frontend UI
local-server.js          # Local dev server

License

MIT

About

BNKR open source

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors