
Onchain Agent
https://github.com/jarrodwatts/onchain-agent- Category
- Crypto
- Rank
- No. 2129Tools index
Previous survey · No. 2088 ·
- Pricing
- Open Source
- Type
- AGENT
- Builder
- jarrodwatts
- GitHub
- 52 stars
- Date
About
Build an onchain AI agent from scratch using OpenAI Assistants and Viem for blockchain capabilities.
What it does
Onchain Agent is a command-line chatbot that turns natural-language requests into actions on Abstract Testnet. It keeps an OpenAI conversation thread, exposes blockchain operations as tools, and uses Viem clients to read balances and contracts or submit wallet-backed transactions. Its toolset also covers ERC20 deployment, token allowances, transaction receipts, and Uniswap V3 pool creation.
Why it's ranked here
The project is a useful, compact reference for connecting conversational tool calls to real blockchain operations. Its strongest idea is the complete loop from terminal input through assistant decisions to Viem execution. The implementation also shows rough edges: tool guidance and registered capabilities disagree, transaction confirmation is inconsistent, and several schemas accept loosely typed contract arguments.
What's good
The tool registry cleanly pairs machine-readable parameter schemas with asynchronous handlers. Address fields use hexadecimal patterns, large integer contract results become strings, and failed assistant runs return readable messages. The agent can inspect verified contract interfaces before interaction, maintain conversation context, deploy an ERC20, check balances, approve allowances, and perform general contract reads and writes.
Tradeoffs
It targets Abstract Testnet and requires both an OpenAI API key and a wallet private key. The prompt tells the assistant to inspect contract bytecode when verification fails, but that capability is disabled in the registry. General contract writes return a transaction hash without waiting for a receipt. ERC20 supply parsing uses basic decimal parsing despite promising natural-language amounts, so examples such as worded quantities are not reliably handled.
How to use it well
Use it as a learning project or testnet prototype for engineers exploring language-directed blockchain operations. Start with read-only balance and contract queries, then use a tightly funded test wallet for writes and verify transaction receipts. It fits terminal experiments and extension work around custom tools. It does not provide a hosted API, graphical interface, production wallet controls, or broad multi-chain support in the supplied code.
Technical notes+
src/index.ts creates a readline CLI, an OpenAI client, an assistant thread, and a repeated chat loop. src/openai/createRun.ts polls queued and in-progress runs once per second, while src/openai/performRun.ts processes required tool actions and selects an assistant message from the thread. src/tools/allTools.ts registers eleven read and write tools, but leaves the bytecode tool commented out even though src/const/prompt.ts instructs the assistant to use it. src/tools/getContractAbi.ts queries the Abstract Testnet explorer and reduces verified ABIs to function signatures. src/tools/deployErc20.ts deploys bytecode from src/const/contractDetails.ts and waits for a receipt. package.json compiles TypeScript before launching the generated Node entry point.
Observed
- License
- ISC
- Primary language
- TypeScript
- Install surface
- npm package dependencies installed with npm install
- Interface
- Interactive command-line chatbot
- Runtime
- Node.js 18 or higher
- Blockchain platform
- Abstract Testnet
- Core dependencies
- OpenAI SDK and Viem
Read from README.md, package.json, src/index.ts, src/const/prompt.ts, src/tools/allTools.ts, src/openai/createRun.ts, src/tools/getBalance.ts, src/openai/performRun.ts, src/tools/deployErc20.ts, src/tools/readContract.ts, src/openai/createThread.ts, src/tools/writeContract.ts, src/tools/getContractAbi.ts, src/const/contractDetails.ts.
What it can do
Build AI agent from scratch
Configuration parameters and requirements → Functional onchain AI agent
Integrate OpenAI Assistant capabilities
OpenAI API credentials and assistant configuration → AI-powered agent with natural language processing
Execute blockchain transactions
Transaction parameters and wallet credentials → Completed onchain transactions
Query blockchain data
Smart contract addresses and query parameters → Blockchain state information and transaction data
Connect to blockchain networks
Network configuration and RPC endpoints → Active blockchain connection
Process natural language blockchain commands
Natural language instructions → Executed blockchain operations
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.