ADK-TS 7 min read

Autonomous AI Agents on Blockchain with ADK-TS & NEAR

Build secure, autonomous blockchain AI agents using ADK-TS and NEAR Shade Agents. Enable smart contracts, DeFi, and oracles to act without human input.

ADK-TS and NEAR Shade Agent

Most blockchain applications today require constant human intervention. Smart contracts sit idle until someone triggers them. DeFi protocols need manual rebalancing. Oracle feeds depend on centralised operators pushing data.

But what if your blockchain applications could think and act on their own?

The ADK-TS 脳 NEAR Shade Agent template makes this vision a reality. It combines the intelligence of modern AI with the autonomy that blockchain technology promises, creating agents that can monitor markets, analyse data, make decisions, and execute transactions without any human involvement.

What Makes This Template Different

Unlike typical blockchain integrations that bolt AI onto existing infrastructure, this template was designed from the ground up for true autonomy. The agents you build don't just respond to requests鈥攖hey actively monitor conditions, reason about complex scenarios, and take action when needed.

The template demonstrates this through a practical example: an AI agent that monitors Ethereum market sentiment by analyzing Reddit headlines, fetches real-time price data from CoinGecko, and autonomously signs transactions to update an on-chain oracle contract with no humans required.

How ADK-TS Works with NEAR Shade Agents

The magic happens when we combine two technologies that were practically made for each other: ADK-TS provides the intelligence, whilst NEAR Shade Agents handle the blockchain execution.

ADK-TS x NEAR Shade Agent AI Template Architecture

ADK-TS Framework: Building Intelligent AI Agents

ADK-TS (Agent Development Kit for TypeScript) brings genuine AI capabilities to blockchain development. Rather than simple chatbots or API wrappers, ADK-TS lets you build agents that can reason about complex scenarios, coordinate with other agents, and maintain memory across interactions.

const { runner } = await AgentBuilder
  .create("crypto-oracle-agent")
  .withModel("gemini-2.5-flash")
  .withDescription("Autonomous crypto market analyst")
  .withInstruction("Monitor ETH price and sentiment, update oracle")
  .asParallel([priceAgent, sentimentAgent])
  .build();

What makes ADK-TS special is its multi-agent orchestration. Instead of building one massive AI system that tries to do everything, you create specialised agents that excel in specific areas. One agent might focus on market analysis, whilst another handles transaction logic鈥攖hey work together seamlessly.

NEAR Shade Agent: Secure Blockchain Transaction Execution

Here's where things get interesting. NEAR Shade Agents solve the biggest challenge in AI-blockchain integration: how can an AI system sign transactions without compromising security?

The answer lies in Account Abstraction and Trusted Execution Environments (TEEs). Each agent gets its own NEAR account, complete with private keys stored securely in trusted hardware called Trusted Execution Environments (TEEs). Through NEAR's Chain Signatures technology, these agents can sign transactions not just on NEAR, but on any blockchain鈥擡thereum, Bitcoin, you name it.

This means AI agents can finally operate independently across multiple blockchains, making decisions and executing transactions without any human intervention.

Trusted Execution Environment(TEE) Security for Production AI Agents

The entire architecture is designed with production-grade security from the ground up. The Trusted Execution Environments provide hardware-level protection for agent private keys, meaning they're safe even from the hosting infrastructure itself. This goes beyond software security to hardware-guaranteed protection with cryptographic proof.

The decentralised architecture means there are no single points of failure. Agents run across distributed TEE networks, making the entire system censorship-resistant and highly available. Everything is open source and auditable, allowing you to verify exactly how your agent operates while keeping its operations secure.

Building an Ethereum Price Oracle AI Agent

The template includes a fully functional Oracle agent that demonstrates the complete autonomous pipeline:

Agent Execution Flow: Oracle Update Process

1. Creating Multi-Agent Systems

The system uses multiple specialised agents working in parallel:

// Price Agent (src/agents/eth-price-agent/)
export const getEthPriceAgent = () => {
  return new LlmAgent({
    name: "eth_price_agent",
    description: "Provides the current Ethereum (ETH) price",
    instruction: "When asked about ethereum, provide its price.",
    model: env.LLM_MODEL,
    tools: [ethPriceTool],
  });
};

// Sentiment Agent (src/agents/eth-sentiment-agent/)
export const getEthSentimentAgent = () => {
  return new LlmAgent({
    name: "eth_sentiment_agent",
    description: "Provides Ethereum sentiment based on latest headlines",
    instruction:
      "Analyse headlines and respond with 'positive', 'negative', or 'neutral'",
    model: env.LLM_MODEL,
    tools: [ethHeadlinesTool],
    outputKey: "sentiment",
  });
};

2. AI Tools for Real-Time Data Collection and Analysis

The agents use sophisticated tools to gather real-world data:

// Price tool fetches from CoinGecko API
export const ethPriceTool = createTool({
  name: "get_eth_price",
  description: "Fetches the current Ethereum (ETH) price in USD",
  fn: async (_, context) => {
    const response = await fetch(
      "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd"
    );
    const data = await response.json();
    context.state.set("price", data.ethereum.usd);
    return `Current Ethereum price: $${data.ethereum.usd} USD`;
  },
});

// Sentiment tool analyses Reddit headlines
export const ethHeadlinesTool = createTool({
  name: "get_eth_headlines",
  description: "Get latest Ethereum-related news headlines from Reddit",
  fn: async (_, context) => {
    const parser = new Parser();
    const feed = await parser.parseURL(
      "https://www.reddit.com/r/ethereum/.rss"
    );
    const headlines = feed.items.map(item => item.title).slice(0, 10);
    context.state.set("headlines", headlines.join("\\\\n"));
    return headlines;
  },
});

3. Autonomous Transaction Signing and Blockchain Execution

The magic happens when the agent autonomously signs and broadcasts transactions:

// Agent gathers data
const { sessionService, runner, session } = await getRootAgent();
const response = await runner.ask("Give ethereum's price and sentiment");

// Extract intelligence from agent state
const { price, sentiment } = currentSession.state;

// Prepare blockchain transaction
const { transaction, hashesToSign } = await getMarketDataPayload(
  price,
  sentiment,
  contractId
);

// Agent autonomously signs transaction
const signRes = await requestSignature({
  path: "ethereum-1",
  payload: uint8ArrayToHex(hashesToSign[0]),
});

// Broadcast to blockchain
const txHash = await Evm.broadcastTx(signedTransaction);

Blockchain AI Agents vs Traditional Web3 Applications

Current Web3 applications have significant limitations that prevent mainstream adoption and truly decentralised operations.

Current Web3 Limitations

Most blockchain applications today require constant babysitting. Smart contracts are reactive rather than proactive鈥攖hey wait for external triggers instead of monitoring conditions and acting independently.

DeFi protocols require manual rebalancing due to changing market conditions. Oracle feeds depend on centralised operators to push data updates. Users must understand complex wallet interfaces, gas fees, and transaction signing just to interact with basic features.

ADK-TS 脳 NEAR Shade Agent Solution

This template changes the game by enabling truly autonomous blockchain operations. AI agents can continuously monitor market conditions, analyze complex data from multiple sources, make intelligent decisions based on changing circumstances, and execute transactions across various blockchains without human involvement. The user experience transforms from technical complexity to natural language interactions.

Building Your First Autonomous Agent

Getting started is surprisingly straightforward. You can have a fully functional autonomous agent running in minutes, not hours.

# Create new project with the NEAR Shade Agent template
npx @iqai/adk-cli new --template shade-agent my-shade-agent
cd my-autonomous-agent
pnpm install

The template comes with everything configured, but you'll want to add your own credentials.

Copy the example environment file and fill in your details:

cp .env.development.local.example .env.development.local

You'll need your NEAR account details, a Google API key for the Gemini LLM, and a Phala Cloud API key. The template documentation explains where to get each of these.

For production deployment, it's a single command:

pnpm dlx @neardefi/shade-agent-cli

This builds your project, creates a Docker image, deploys it to Phala Cloud's TEE network, and gives you a live URL to interact with your agent's endpoints. Your agent is now running autonomously in a secure, decentralised environment.

REST API Endpoints for AI Agent Management

Once your agent is running, you can interact with it through clean REST APIs. The template provides three key endpoints that give you complete visibility into your agent's operations:

You can test these endpoints directly:

curl <https://your-agent.phala.network/api/transaction>

This isn't just a demonstration鈥攊t's a fully functional autonomous system that could handle real-world oracle operations.

AI Agent Use Cases Beyond Price Oracles

This template is just the beginning. The ADK-TS 脳 NEAR Shade Agent architecture enables:

DeFi AI Applications

Gaming & NFT AI Integrations

Blockchain Infrastructure Automation

Enterprise Blockchain AI Solutions

The Future of Autonomous Blockchain AI Agents

The ADK-TS 脳 NEAR Shade Agent template represents the first step towards a truly autonomous Web3 ecosystem. As AI continues to advance and blockchain infrastructure matures, we envision:

Start Building AI Blockchain Agents Today

The autonomous Web3 future is here, and it's easier to build than ever before.

To try the template, run the following command:

npx @iqai/adk-cli new --template shade-agent my-shade-agent

Resources

Read next