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/onchain-allocate.py

View on GitHub
#!/usr/bin/env python3
"""链上 allocate stake 到 agent+subnet(V2)
V2 签名: allocate(address staker, address agent, uint256 subnetId, uint256 amount)
staker 参数现在是显式的(第一个参数)。调用者必须是 staker 或 delegate。
"""
from awp_lib import *


def main() -> None:
    parser = base_parser("On-chain allocate stake to agent+subnet (V2)")
    parser.add_argument("--agent", required=True, help="代理地址")
    parser.add_argument("--subnet", required=True, help="子网 ID")
    parser.add_argument("--amount", required=True, help="AWP 数量(人类可读)")
    args = parser.parse_args()

    token: str = args.token
    agent: str = args.agent
    subnet: str = args.subnet
    amount: str = args.amount

    # 验证输入
    validate_address(agent, "agent")
    validate_positive_number(amount, "amount")
    subnet_id: int = validate_positive_int(subnet, "subnet")

    # 预检:获取钱包地址
    wallet_addr = get_wallet_address()

    # 获取合约注册表
    registry = get_registry()
    awp_registry = require_contract(registry, "awpRegistry")

    # 检查未分配余额
    balance = api_get(f"staking/user/{wallet_addr}/balance")
    if not isinstance(balance, dict):
        die("Could not fetch balance — check address")
    unallocated = balance.get("unallocated")
    if unallocated is None or unallocated == "null":
        die("Could not fetch balance — check address")

    amount_wei = to_wei(amount)
    unallocated_int = int(unallocated)
    # 注意:API 数据可能有延迟(约几秒),链上状态可能已变更。
    # 此检查用于提前捕获明显错误,最终以链上校验为准。
    if amount_wei > unallocated_int:
        die(f"Insufficient unallocated balance: have {unallocated_int / 10**18} AWP, need {amount} AWP")

    # allocate(address,address,uint256,uint256) selector = 0xd035a9a7
    # 参数: staker (self), agent, subnetId, amount
    calldata = encode_calldata(
        "0xd035a9a7",
        pad_address(wallet_addr),
        pad_address(agent),
        pad_uint256(subnet_id),
        pad_uint256(amount_wei),
    )

    step("allocate", staker=wallet_addr, agent=agent, subnet=subnet_id, amount=f"{amount} AWP")
    result = wallet_send(token, awp_registry, calldata)
    print(result)


if __name__ == "__main__":
    main()
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