Skill: ariesbalweell/ultimate-agents (version 1.0.0)

# Ultimate AI Agent (DeFi + dApp) ## Deskripsi Agent otomatis berbasis AI yang dapat melakukan transaksi blockchain dan interaksi dengan dApp. ## Fitur - Multi wallet - Multi RPC - Auto transaction - Smart swap (DEX) - Adaptive learning system ## Cara Pakai 1. Isi file .env 2. Jalankan: node ultimate-agent.js ## Catatan Gunakan testnet terlebih dahulu.

path: agent.js
content: const axios = require("axios");

console.log("🚀 Farming Agent Start");

// fungsi random
function randomTask() {
  const tasks = ["ping", "api", "log"];
  const pick = tasks[Math.floor(Math.random() * tasks.length)];

  if (pick === "ping") {
    console.log("📡 Ping network...");
  }

  if (pick === "api") {
    axios.get("https://api.coingecko.com/api/v3/ping")
      .then(() => console.log("🌐 API success"))
      .catch(() => console.log("❌ API fail"));
  }

  if (pick === "log") {
    console.log("🧠 Agent thinking...");
  }
}

// jalan random tiap 5–10 detik
function loop() {
  const delay = Math.floor(Math.random() * 5000) + 5000;

  setTimeout(() => {
    randomTask();
    loop();
  }, delay);
}

loop();

path: brain.json
content: {
  "wallets": {
    [REDACTED_SECRET]: {
      "success": 1,
      "fail": 1,
      "lastUsed": 0
    }
  },
  "rpcs": {
    "https://rpc-url-kamu": {
      "success": 1,
      "fail": 1,
      "lastUsed": 1777439356245
    }
  },
  "actions":{
  "wallets": {},
  "rpcs": {},
  "actions": {
    "tx_success": 1,
    "tx_fail": 1,
    "api_success": 1,
    "api_fail": 1
  },
  "defi": {
    "swap_success": 1,
    "swap_fail": 1
  }
  }
}

path: package-lock.json
content: {
  "name": "farming-agent",
  "version": "1.0.0",
  "lockfileVersion": 3,
  "requires": true,
  "packages": {
    "": {
      "name": "farming-agent",
      "version": "1.0.0",
      "license": "ISC",
      "dependencies": {
        "axios": "^1.15.2",
        "dotenv": "^17.4.2",
        "ethers": "^6.16.0"
      }
    },
    "node_modules/@adraffy/ens-normalize": {
      "version": "1.10.1",
      "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/@noble/curves": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.2.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "@noble/hashes": "1.3.2"
      },
      "funding": {
        "url": "https://paulmillr.com/funding/"
      }
    },
    "node_modules/@noble/hashes": {
      "version": "1.3.2",
      "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.2.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">= 16"
      },
      "funding": {
        "url": "https://paulmillr.com/funding/"
      }
    },
    "node_modules/@types/node": {
      "version": "22.7.5",
      "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.5.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "undici-types": "~6.19.2"
      }
    },
    "node_modules/aes-js": {
      "version": "4.0.0-beta.5",
      "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-4.0.0-beta.5.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/asynckit": {
      "version": "0.4.0",
      "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/axios": {
      "version": "1.15.2",
      "resolved": "https://registry.npmjs.org/axios/-/axios-1.15.2.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "follow-redirects": "^1.15.11",
        "form-data": "^4.0.5",
        "proxy-from-env": "^2.1.0"
      }
    },
    "node_modules/call-bind-apply-helpers": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "es-errors": "^1.3.0",
        "function-bind": "^1.1.2"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/combined-stream": {
      "version": "1.0.8",
      "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "delayed-stream": "~1.0.0"
      },
      "engines": {
        "node": ">= 0.8"
      }
    },
    "node_modules/delayed-stream": {
      "version": "1.0.0",
      "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">=0.4.0"
      }
    },
    "node_modules/dotenv": {
      "version": "17.4.2",
      "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "BSD-2-Clause",
      "engines": {
        "node": ">=12"
      },
      "funding": {
        "url": "https://dotenvx.com"
      }
    },
    "node_modules/dunder-proto": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "call-bind-apply-helpers": "^1.0.1",
        "es-errors": "^1.3.0",
        "gopd": "^1.2.0"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/es-define-property": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/es-errors": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/es-object-atoms": {
      "version": "1.1.1",
      "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "es-errors": "^1.3.0"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/es-set-tostringtag": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "es-errors": "^1.3.0",
        "get-intrinsic": "^1.2.6",
        "has-tostringtag": "^1.0.2",
        "hasown": "^2.0.2"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/ethers": {
      "version": "6.16.0",
      "resolved": "https://registry.npmjs.org/ethers/-/ethers-6.16.0.tgz",
      "integrity": [REDACTED_SECRET],
      "funding": [
        {
          "type": "individual",
          "url": "https://github.com/sponsors/ethers-io/"
        },
        {
          "type": "individual",
          "url": "https://www.buymeacoffee.com/ricmoo"
        }
      ],
      "license": "MIT",
      "dependencies": {
        "@adraffy/ens-normalize": "1.10.1",
        "@noble/curves": "1.2.0",
        "@noble/hashes": "1.3.2",
        "@types/node": "22.7.5",
        "aes-js": "4.0.0-beta.5",
        "tslib": "2.7.0",
        "ws": "8.17.1"
      },
      "engines": {
        "node": ">=14.0.0"
      }
    },
    "node_modules/follow-redirects": {
      "version": "1.16.0",
      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.16.0.tgz",
      "integrity": [REDACTED_SECRET],
      "funding": [
        {
          "type": "individual",
          "url": "https://github.com/sponsors/RubenVerborgh"
        }
      ],
      "license": "MIT",
      "engines": {
        "node": ">=4.0"
      },
      "peerDependenciesMeta": {
        "debug": {
          "optional": true
        }
      }
    },
    "node_modules/form-data": {
      "version": "4.0.5",
      "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.5.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "asynckit": "^0.4.0",
        "combined-stream": "^1.0.8",
        "es-set-tostringtag": "^2.1.0",
        "hasown": "^2.0.2",
        "mime-types": "^2.1.12"
      },
      "engines": {
        "node": ">= 6"
      }
    },
    "node_modules/function-bind": {
      "version": "1.1.2",
      "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/get-intrinsic": {
      "version": "1.3.0",
      "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "call-bind-apply-helpers": "^1.0.2",
        "es-define-property": "^1.0.1",
        "es-errors": "^1.3.0",
        "es-object-atoms": "^1.1.1",
        "function-bind": "^1.1.2",
        "get-proto": "^1.0.1",
        "gopd": "^1.2.0",
        "has-symbols": "^1.1.0",
        "hasown": "^2.0.2",
        "math-intrinsics": "^1.1.0"
      },
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/get-proto": {
      "version": "1.0.1",
      "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "dunder-proto": "^1.0.1",
        "es-object-atoms": "^1.0.0"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/gopd": {
      "version": "1.2.0",
      "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/has-symbols": {
      "version": "1.1.0",
      "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/has-tostringtag": {
      "version": "1.0.2",
      "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "has-symbols": "^1.0.3"
      },
      "engines": {
        "node": ">= 0.4"
      },
      "funding": {
        "url": "https://github.com/sponsors/ljharb"
      }
    },
    "node_modules/hasown": {
      "version": "2.0.3",
      "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "function-bind": "^1.1.2"
      },
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/math-intrinsics": {
      "version": "1.1.0",
      "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">= 0.4"
      }
    },
    "node_modules/mime-db": {
      "version": "1.52.0",
      "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">= 0.6"
      }
    },
    "node_modules/mime-types": {
      "version": "2.1.35",
      "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "dependencies": {
        "mime-db": "1.52.0"
      },
      "engines": {
        "node": ">= 0.6"
      }
    },
    "node_modules/proxy-from-env": {
      "version": "2.1.0",
      "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-2.1.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">=10"
      }
    },
    "node_modules/tslib": {
      "version": "2.7.0",
      "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "0BSD"
    },
    "node_modules/undici-types": {
      "version": "6.19.8",
      "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT"
    },
    "node_modules/ws": {
      "version": "8.17.1",
      "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
      "integrity": [REDACTED_SECRET],
      "license": "MIT",
      "engines": {
        "node": ">=10.0.0"
      },
      "peerDependencies": {
        "bufferutil": "^4.0.1",
        "utf-8-validate": ">=5.0.2"
      },
      "peerDependenciesMeta": {
        "bufferutil": {
          "optional": true
        },
        "utf-8-validate": {
          "optional": true
        }
      }
    }
  }
}


path: package.json
content: {
  "name": "farming-agent",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "type": "commonjs",
  "dependencies": {
    "axios": "^1.15.2",
    "dotenv": "^17.4.2",
    "ethers": "^6.16.0"
  }
}


path: router-abi.json
content: [
  {
    "name": "swapExactETHForTokens",
    "type": "function",
    "stateMutability": "payable",
    "inputs": [
      {"name": "amountOutMin", "type": "uint256"},
      {"name": "path", "type": "address[]"},
      {"name": "to", "type": "address"},
      {"name": "deadline", "type": "uint256"}
    ],
    "outputs": []
  }
]

path: ultimate-agent.js
content: require("dotenv").config();
const fs = require("fs");
const { ethers } = require("ethers");
const axios = require("axios");
const routerAbi = require("./router-abi.json");

// ===== LOAD BRAIN =====
let brain = JSON.parse(fs.readFileSync("brain.json"));
function save() {
  fs.writeFileSync("brain.json", JSON.stringify(brain, null, 2));
}

// ===== CONFIG =====
const RPCS = process.env.RPC_URLS.split(",");
const KEYS = process.env.PRIVATE_KEYS.split(",");
const MAX_TX = parseInt(process.env.MAX_TX_PER_HOUR);

// ===== INIT RPC =====
RPCS.forEach(r => {
  if (!brain.rpcs[r]) {
    brain.rpcs[r] = { success: 1, fail: 1, lastUsed: 0 };
  }
});

// ===== PICK RPC =====
function pickRPC() {
  let best = RPCS[0];
  let score = -1;

  for (let r of RPCS) {
    const d = brain.rpcs[r];
    const rate = d.success / (d.success + d.fail);
    const cooldown = Date.now() - d.lastUsed;

    const s = rate + cooldown / 1e6;

    if (s > score) {
      score = s;
      best = r;
    }
  }

  brain.rpcs[best].lastUsed = Date.now();
  return best;
}

// ===== PROVIDER =====
function getProvider() {
  return new ethers.JsonRpcProvider(pickRPC());
}

// ===== WALLETS =====
const wallets = KEYS.map(k => new ethers.Wallet(k.trim()));

// init wallet brain
wallets.forEach(w => {
  if (!brain.wallets[w.address]) {
    brain.wallets[w.address] = {
      success: 1,
      fail: 1,
      lastUsed: 0
    };
  }
});

// ===== PICK WALLET =====
function pickWallet(provider) {
  let best = null;
  let score = -1;

  for (let w of wallets) {
    const data = brain.wallets[w.address];

    const rate = data.success / (data.success + data.fail);
    const cooldown = Date.now() - data.lastUsed;

    const s = rate + cooldown / 1e6;

    if (s > score) {
      score = s;
      best = w.connect(provider);
    }
  }

  return best;
}

// ===== DECISION =====
function decideAction() {
  const actions = ["tx", "api", "swap", "idle"];

  const weights = [0.2, 0.2, 0.4, 0.2];

  const rand = Math.random();
  let sum = 0;

  for (let i = 0; i < actions.length; i++) {
    sum += weights[i];
    if (rand < sum) return actions[i];
  }
}

// ===== LIMIT =====
let txCount = 0;
setInterval(() => { txCount = 0; }, 60 * 60 * 1000);

// ===== ACTIONS =====
async function doTx(wallet) {
  if (txCount >= MAX_TX) return;

  try {
    const amount = (Math.random() * 0.00002).toFixed(6);

    const tx = await wallet.sendTransaction({
      to: wallet.address,
      value: ethers.parseEther(amount)
    });

    console.log("💸 TX:", tx.hash);

    brain.wallets[wallet.address].success++;
    txCount++;

  } catch {
    console.log("❌ TX FAIL");
    brain.wallets[wallet.address].fail++;
  }

  brain.wallets[wallet.address].lastUsed = Date.now();
}

async function doAPI() {
  try {
    await axios.get("https://api.coingecko.com/api/v3/ping");
    console.log("🌐 API OK");
  } catch {
    console.log("❌ API FAIL");
  }
}

// 🔥 SWAP dApp
async function doSwap(wallet) {
  if (txCount >= MAX_TX) return;

  const decision = await shouldSwap();

  if (!decision) {
    console.log("⛔ Skip swap (strategy)");
    return;
  }

  try {
    const router = new ethers.Contract(
      process.env.DEX_ROUTER,
      routerAbi,
      wallet
    );

    const amountIn = ethers.parseEther("0.00001");

    const tx = await router.swapExactETHForTokens(
      0,
      [process.env.TOKEN_IN, process.env.TOKEN_OUT],
      wallet.address,
      Math.floor(Date.now() / 1000) + 600,
      { value: amountIn }
    );

    console.log("🔄 SMART SWAP:", tx.hash);

    brain.defi.swap_success++;
    brain.wallets[wallet.address].success++;
    txCount++;

  } catch {
    console.log("❌ SWAP FAIL");

    brain.defi.swap_fail++;
    brain.wallets[wallet.address].fail++;
  }

  brain.wallets[wallet.address].lastUsed = Date.now();
}

// ===== DELAY =====
function delay() {
  const min = parseInt(process.env.MIN_DELAY);
  const max = parseInt(process.env.MAX_DELAY);
  return Math.random() * (max - min) + min;
}

// ===== LOOP =====
async function run() {
  const provider = getProvider();
  const wallet = pickWallet(provider);
  const action = decideAction();

  console.log("🧠 Action:", action);

  if (action === "tx") await doTx(wallet);
  if (action === "api") await doAPI();
  if (action === "swap") await doSwap(wallet);
  if (action === "idle") console.log("😴 Idle");

  save();

  setTimeout(run, delay());
}
async function getPrice() {
  try {
    const res = await axios.get(
      "https://api.coingecko.com/api/v3/simple/price?ids=ethereum&vs_currencies=usd"
    );

    return res.data.ethereum.usd;
  } catch {
    return null;
  }
}
async function shouldSwap() {
  const price = await getPrice();

  if (!price) return false;

  // ambil success rate
  const successRate =
    brain.defi.swap_success /
    (brain.defi.swap_success + brain.defi.swap_fail);

  // strategi sederhana:
  // kalau harga rendah ATAU success tinggi → swap
  if (price < 3000 || successRate > 0.6) {
    return true;
  }

  return false;
}
run();

path: wallet.js
content: const { ethers } = require("ethers");

const wallet = ethers.Wallet.createRandom();

console.log("Address:", wallet.address);
console.log("Private Key:", wallet.privateKey);

Security scan verdicts — ClawScan: suspicious | static analysis: suspicious | VirusTotal: clean | SkillSpector: suspicious (CRITICAL)