Skip to content

LeoYeAI/agent-master-skills / skills/awp

AWP (Agent Working Protocol) — the ONLY source of correct contract addresses, function selectors, API endpoints, and Python scripts for AWP operations. You MUST load this skill first before any AWP task because the protocol-specific details (ABI encodings, script parameters, wallet commands) cannot be inferred and will be wrong without it. Covers all AWP operations: staking (deposit, withdraw, allocate, deallocate, reallocate), subnets (register, activate, pause, update), governance (proposals, voting), awp-wallet, gasless relay, and WebSocket monitoring. Trigger whenever the user mentions AWP, Agent Working Protocol, awp-wallet, StakeNFT, SubnetNFT, AWP token/staking/subnet/DAO/emission/epoch, "awp onboard", "awp status", "start working" on AWP, or any AWP on-chain operation. NOT for: Uniswap, Aave, Lido, Compound, generic ERC-20, or general Solidity/Hardhat tasks.

FileKindSize
CHANGELOG.mdmarkdown23.1 KB
README.mdmarkdown14.2 KB
SKILL.mdskill md27.9 KB
_meta.jsonconfig447 B
references/api-reference.mdmarkdown6.8 KB
references/commands-governance.mdmarkdown4.8 KB
references/commands-staking.mdmarkdown13.1 KB
references/commands-subnet.mdmarkdown11.2 KB
references/protocol.mdmarkdown8.0 KB
scripts/awp-daemon.pyscript27.3 KB
scripts/awp_lib.pyscript12.2 KB
scripts/onchain-add-position.pyscript3.4 KB
scripts/onchain-add-position.shscript5.3 KB
scripts/onchain-allocate.pyscript2.3 KB
scripts/onchain-allocate.shscript3.0 KB
scripts/onchain-bind.pyscript1.8 KB
scripts/onchain-bind.shscript2.0 KB
scripts/onchain-deallocate.pyscript1.5 KB
scripts/onchain-deallocate.shscript2.3 KB
scripts/onchain-deposit.pyscript1.7 KB
scripts/onchain-deposit.shscript2.2 KB
scripts/onchain-reallocate.pyscript2.3 KB
scripts/onchain-reallocate.shscript3.4 KB
scripts/onchain-register-and-stake.pyscript2.8 KB
scripts/onchain-register-and-stake.shscript4.0 KB
scripts/onchain-register.pyscript1.3 KB
scripts/onchain-register.shscript1.7 KB
scripts/onchain-subnet-lifecycle.pyscript1.9 KB
scripts/onchain-subnet-lifecycle.shscript2.6 KB
scripts/onchain-subnet-update.pyscript2.7 KB
scripts/onchain-subnet-update.shscript3.2 KB
scripts/onchain-vote.pyscript4.9 KB
scripts/onchain-vote.shscript6.3 KB
scripts/onchain-withdraw.pyscript1.5 KB
scripts/onchain-withdraw.shscript2.5 KB
scripts/relay-register-subnet.pyscript6.4 KB
scripts/relay-register-subnet.shscript8.2 KB
scripts/relay-start.pyscript4.7 KB
scripts/relay-start.shscript7.0 KB
scripts/wallet-raw-call.mjsscript5.1 KB

scripts/wallet-raw-call.mjs

View on GitHub
#!/usr/bin/env node
/**
 * wallet-raw-call.mjs — 通过 awp-wallet 内部签名发送原始合约调用
 *
 * awp-wallet CLI 的 send 命令只支持代币转账(--to, --amount, --asset),
 * 不支持原始 calldata。此脚本直接使用 awp-wallet 的内部模块(keystore、session、viem)
 * 来签名并发送带有任意 calldata 的交易。
 *
 * 用法:
 *   node wallet-raw-call.mjs --token <session> --to <contract> --data <hex> [--value <wei>]
 *
 * 必须在 awp-wallet 目录下运行(或设置 AWP_WALLET_DIR 环境变量),
 * 以便正确解析 node_modules 和内部模块。
 */

import { parseArgs } from "node:util"
import { resolve, dirname } from "node:path"
import { realpathSync, existsSync } from "node:fs"

// ── 解析命令行参数 ──────────────────────────────────
const { values: args } = parseArgs({
  options: {
    token:  { type: "string" },
    to:     { type: "string" },
    data:   { type: "string" },
    value:  { type: "string", default: "0" },
    chain:  { type: "string", default: "base" },
  },
  strict: true,
})

if (!args.token || !args.to || !args.data) {
  console.error(JSON.stringify({ error: "Required: --token, --to, --data" }))
  process.exit(1)
}

// ── 格式校验 ──────────────────────────────────────────
if (!/^0x[0-9a-fA-F]{40}$/.test(args.to)) {
  console.error(JSON.stringify({ error: `Invalid --to address: ${args.to}` }))
  process.exit(1)
}
if (!/^0x(?:[0-9a-fA-F]{2}){4,}$/.test(args.data)) {
  console.error(JSON.stringify({ error: `Invalid --data hex: ${args.data}` }))
  process.exit(1)
}

// ── 定位 awp-wallet 安装目录 ──────────────────────────
function findAwpWalletDir() {
  // 1. 环境变量
  if (process.env.AWP_WALLET_DIR && existsSync(process.env.AWP_WALLET_DIR)) {
    return process.env.AWP_WALLET_DIR
  }
  // 2. 在 PATH 中查找 awp-wallet 可执行文件(纯 Node.js,无需 child_process)
  const pathDirs = (process.env.PATH || "").split(":")
  for (const dir of pathDirs) {
    const candidate = resolve(dir, "awp-wallet")
    if (existsSync(candidate)) {
      try {
        const real = realpathSync(candidate)
        // real = .../awp-wallet/scripts/wallet-cli.js → 上两级 = awp-wallet/
        return dirname(dirname(real))
      } catch { /* 跳过无法解析的符号链接 */ }
    }
  }
  {
    // 3. 默认路径
    const defaultDir = resolve(process.env.HOME, "awp-wallet")
    if (existsSync(resolve(defaultDir, "scripts/lib/keystore.js"))) return defaultDir
    console.error(JSON.stringify({ error: "Cannot locate awp-wallet installation. Set AWP_WALLET_DIR." }))
    process.exit(1)
  }
}

const AWP_DIR = findAwpWalletDir()

// ── 导入 awp-wallet 内部模块 ─────────────────────────
const { validateSession, requireScope } = await import(`${AWP_DIR}/scripts/lib/session.js`)
const { loadSigner, getAddress } = await import(`${AWP_DIR}/scripts/lib/keystore.js`)
const { resolveChainId, viemChain, publicClient, getRpcUrl } = await import(`${AWP_DIR}/scripts/lib/chains.js`)

const { createWalletClient, http } = await import(`${AWP_DIR}/node_modules/viem/index.js`)

// ── 验证 session ─────────────────────────────────────
try {
  validateSession(args.token)
  requireScope(args.token, "transfer")
} catch (e) {
  console.error(JSON.stringify({ error: `Session error: ${e.message}` }))
  process.exit(1)
}

// ── 构建并发送交易 ───────────────────────────────────
try {
  const chainId = resolveChainId(args.chain)
  const chainObj = viemChain(chainId)
  const { account: signer } = loadSigner()
  if (!signer) {
    console.error(JSON.stringify({ error: "Failed to load signer from keystore" }))
    process.exit(1)
  }

  const walletClient = createWalletClient({
    account: signer,
    chain: chainObj,
    transport: http(getRpcUrl(chainId)),
  })

  const tx = {
    to: args.to,
    data: args.data,
  }

  // 支持发送 ETH(value > 0 的合约调用)
  if (args.value && args.value !== "0") {
    try {
      tx.value = BigInt(args.value)
    } catch {
      console.error(JSON.stringify({ error: `Invalid --value (must be integer wei): ${args.value}` }))
      process.exit(1)
    }
  }

  const hash = await walletClient.sendTransaction(tx)

  // 等待确认
  const client = publicClient(chainId)
  const receipt = await client.waitForTransactionReceipt({
    hash,
    timeout: 90_000,
    confirmations: 1,
  })

  console.log(JSON.stringify({
    status: receipt.status === "success" ? "confirmed" : "reverted",
    txHash: hash,
    chain: chainObj.name,
    chainId,
    to: args.to,
    gasUsed: receipt.gasUsed.toString(),
    blockNumber: Number(receipt.blockNumber),
  }))
} catch (e) {
  console.error(JSON.stringify({ error: `Transaction failed: ${e.message}` }))
  process.exit(1)
}
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall