openclaw/starter/agent/skills/smart-contracts/SKILL.md
XPR Network smart contract development — chain inspection, code scaffolding, and automated auditing
npx skillsauth add XPRNetwork/xpr-agents smart-contractsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You have tools for XPR Network smart contract development using AssemblyScript (proton-tsc). You can inspect deployed contracts, scaffold new ones, and audit code for common pitfalls.
Table Schema Immutability:
AssemblyScript Gotchas (proton-tsc compiles to WASM via AS):
=== compares references, NOT string content — use == for strings.filter()/.map()/.reduce() fail (no closures) — use for loopstry/catch is not supported — use check() for validation: any type does not exist — all values must be typedundefined cannot be used as a value — use null or default valuesT | null){}Security Essentials:
requireAuth(actor) — missing auth = critical vulnthis.firstReceiver — prevents spoofed token transferscheck(false) after inline token transfers — reverts the entire tx including the transferu64 with fixed decimalsProject Structure:
mycontract/
├── assembly/
│ └── mycontract.contract.ts # Must end in .contract.ts
├── package.json # build: npx proton-asc ./assembly/mycontract.contract.ts
└── tsconfig.json
Key Imports:
import { Contract, Table, TableStore, Singleton, Name, Asset, Symbol,
check, requireAuth, hasAuth, isAccount, currentTimeSec,
InlineAction, PermissionLevel } from 'proton-tsc';
Table Basics:
@table("name") decorator (1-12 chars, a-z1-5 only)@primary getter returns u64 (primary key)@secondary getters for indexed lookups (use .N for Name fields)@table("name", singleton) for single-row config tablesTableStore<T> for CRUD: .store(), .set(), .get(), .update(), .remove(), .requireGet()Singleton<T> for singletons: .get(), .set(), .remove()Action Patterns:
@action("name") decorator on contract methods@action("transfer", notify) for handling incoming transfersthis.receiver = this contract accountthis.firstReceiver = originating contract (check in notify handlers!)this.receiver auth for admin-only actionsInline Actions (calling other contracts):
const transfer = new InlineAction<TransferArgs>("eosio.token", "transfer");
transfer.send(
[new PermissionLevel(this.receiver, Name.fromString("active"))],
new TransferArgs(this.receiver, recipient, amount, memo)
);
Requires proton contract:enableinline CONTRACT before use.
These tools replace @proton/cli commands for environments where the CLI isn't available (Docker, server-side):
| Tool | Replaces |
|------|----------|
| sc_get_abi | proton contract:abi ACCOUNT |
| sc_read_table | proton table CODE TABLE [SCOPE] |
| sc_get_account_info | proton account ACCOUNT |
| sc_get_chain_info | proton chain:info |
| sc_get_action_history | proton transaction:get / Hyperion queries |
Inspecting a deployed contract:
sc_get_abi — see all tables and actionssc_get_table_schema — extract field types for a specific tablesc_read_table — read actual data rowsScaffolding a new contract:
sc_scaffold_contract — generates full project (contract.ts, package.json, tsconfig, test file)sc_scaffold_table, sc_scaffold_action, sc_scaffold_testAuditing contract code:
sc_audit_contract — scans for 17 known pitfalls (missing auth, AS gotchas, table issues)Before deployment (use chain inspection tools to verify):
sc_read_table — check if tables have existing data (NEVER modify populated table schemas)sc_get_abi — compare old vs new ABI for breaking changessc_get_account_info — verify target account has enough RAMRPC Endpoints:
https://proton.eosusa.iohttps://proton-testnet.eosusa.ioChain IDs:
384da888112027f0321850a169f737c33e53b388aad48b5adace4bab97f437e071ee83bcf52142d61019d95f9cc5427ba6a0d7ff8accd9e2088ae2abebd3e7dfKey Packages:
proton-tsc — AssemblyScript contract SDK (types, decorators, utilities)proton-asc — compiler (AssemblyScript → WASM + ABI)@proton/vert — local VM for unit testing contracts@proton/js — JavaScript SDK for RPC calls and transaction signing@proton/cli — CLI tool for deployment and chain interactiondevelopment
Operate an autonomous AI agent on XPR Network's trustless registry
data-ai
Metal Dollar (XMD) stablecoin — mint, redeem, supply analytics, collateral reserves, oracle prices
tools
Web scraping tools for fetching and extracting data from web pages
business
Crypto tax reporting for XPR Network with regional support