Deploy an agent in Monad testnet

Agent Setup Guide

This guide walks you through setting up, configuring, and running the TypeScript yield-compounding agent that interacts with your deployed YieldOptimizer contract on Monad testnet.

1. Prerequisites

  • Node.js v20+ and npm v10+

  • A funded Monad testnet wallet (get MON from faucet)

  • The deployed YieldOptimizer contract address deployed using Remix/Hardhat.

  • Access to a Monad testnet RPC endpoint

  • Your MCP Bearer token

2. Project Setup

npm init -y
npm install ethers dotenv ts-node

3. Prepare the TypeScript Script

  • Save the provided TypeScript code as bot.ts in your project directory.

  • If you have the ABI as a JSON file, you can import it; otherwise, use the inline ABI array as shown in the code.

4. Configure Environment Variables

Create a .env file in your project root:

MONAD_RPC=https://testnet-rpc.monad.xyz
PRIVATE_KEY=0x<your-private-key>
YIELD_OPTIMIZER_ADDR=0x<deployed-contract-address>
MCP_TOKEN=<your-mcp-bearer-token>

Replace the values with your actual testnet RPC, private key, deployed contract address, and MCP token.

5. Run the Agent

If you’re using TypeScript, install ts-node if you haven't already:

npm install -g ts-node

Then run:

ts-node bot.ts

7. What to Expect

  • The script will deposit MON into the YieldOptimizer contract, mint aprMON, and deploy a trading agent via the Kuru Router.

  • It will repeat this process in a loop (e.g., every hour).

  • Console output will show transaction hashes and deployed agent addresses.

8. Troubleshooting

Issue
Solution

INSUFFICIENT_FUNDS

Top up your wallet at faucet

chainId mismatch

Ensure your RPC is for Monad testnet (chainId 10143)

Contract call fails

Double-check contract addresses and ABI signatures

MCP tool call fails

Ensure your MCP_TOKEN is valid and passed in headers

TypeScript/ABI errors

Ensure ABI matches deployed contract and is up-to-date

Last updated