Learn-skills.dev contract
Clarity smart contract deployment and interaction — deploy contracts from source files, call public functions with post conditions, and call read-only functions.
install
source · Clone the upstream repo
git clone https://github.com/NeverSight/learn-skills.dev
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/NeverSight/learn-skills.dev "$T" && mkdir -p ~/.claude/skills && cp -r "$T/data/skills-md/aibtcdev/skills/contract" ~/.claude/skills/neversight-learn-skills-dev-contract && rm -rf "$T"
manifest:
data/skills-md/aibtcdev/skills/contract/SKILL.mdsource content
Contract Skill
Provides Clarity smart contract deployment and interaction on the Stacks blockchain. Deploy contracts from
.clar source files, call public functions (with optional post conditions), and call read-only functions to query on-chain state.
- read — Read-only, no wallet required.
- deploy and call — Write operations that broadcast transactions; require an unlocked wallet.
Usage
bun run contract/contract.ts <subcommand> [options]
Subcommands
deploy
Deploy a Clarity smart contract to the Stacks blockchain. Reads the contract source from a
.clar file and broadcasts a smart_contract transaction.
bun run contract/contract.ts deploy \ --source <path-to-file.clar> \ --name <contract-name> \ [--fee <fee>]
Options:
(required) — Path to the--source
source file to deploy.clar
(required) — Contract name (lowercase, hyphens allowed, max 128 chars)--name
(optional) — Fee preset (--fee
) or micro-STX amount; auto-estimated if omittedlow|medium|high
Output:
{ "success": true, "txid": "abc123...", "contractId": "SP2...deployer.my-contract", "network": "mainnet", "explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet" }
call
Call a public function on a deployed Stacks smart contract. Signs and broadcasts a
contract_call transaction.
bun run contract/contract.ts call \ --contract <contractId> \ --function <functionName> \ --args <json-array> \ [--post-condition-mode <deny|allow>] \ [--post-conditions <json-array>] \ [--fee <fee>]
Options:
(required) — Full contract ID in--contract
formatADDRESS.contract-name
(required) — Public function name to call--function
(optional) — Function arguments as a JSON array (default:--args
). Typed objects use[]
format.{"type":"uint","value":100}
(optional) —--post-condition-mode
(default) blocks unexpected token transfers;deny
permits anyallow
(optional) — Post conditions as a JSON array (see Notes for format)--post-conditions
(optional) — Fee preset (--fee
) or micro-STX amount; auto-estimated if omittedlow|medium|high
Output:
{ "success": true, "txid": "abc123...", "contract": "SP2...deployer.my-contract", "function": "set-value", "args": [42], "network": "mainnet", "explorerUrl": "https://explorer.hiro.so/txid/abc123...?chain=mainnet" }
read
Call a read-only function on a deployed Stacks smart contract. Does not broadcast a transaction; no wallet required.
bun run contract/contract.ts read \ --contract <contractId> \ --function <functionName> \ [--args <json-array>] \ [--sender <address>]
Options:
(required) — Full contract ID in--contract
formatADDRESS.contract-name
(required) — Read-only function name to call--function
(optional) — Function arguments as a JSON array (default:--args
)[]
(optional) — Stacks address to use as the read-only call sender (uses active wallet address if omitted)--sender
Output:
{ "contract": "SP2...deployer.my-contract", "function": "get-value", "okay": true, "result": "(ok u42)", "network": "mainnet" }
Arguments
| Subcommand | Option | Required | Description |
|---|---|---|---|
| | yes | Path to source file |
| | yes | Contract name |
| | no | Fee preset or micro-STX amount |
| | yes | Full contract ID () |
| | yes | Public function name |
| | no | JSON array of function arguments |
| | no | (default) or |
| | no | JSON array of post condition objects |
| | no | Fee preset or micro-STX amount |
| | yes | Full contract ID () |
| | yes | Read-only function name |
| | no | JSON array of function arguments |
| | no | Sender address for the read-only call |
Notes
- Contract names must be unique per deployer address. Deploying a contract that already exists will fail.
- Deployment is irreversible — the contract lives on-chain permanently once confirmed.
- Pre-simulate contract calls on stxer.xyz before deploying or calling to catch Clarity errors and estimate fees without spending STX.
- Post condition format:
for STX;{"type":"stx","principal":"SP2...","conditionCode":"eq","amount":"1000000"}
for fungible tokens;{"type":"ft","principal":"SP2...","asset":"SP2....my-token","assetName":"my-token","conditionCode":"eq","amount":"100"}
for NFTs — NFT conditions are binary (send/not-send), so{"type":"nft","principal":"SP2...","asset":"SP2....my-nft","assetName":"my-nft","tokenId":1}
is not applicable; useconditionCode
to assert the NFT must NOT leave the principal."notSend":true
skips post condition checks entirely — use only when you fully trust the contract logic and have verified the source code.--post-condition-mode allow- Wallet operations require an unlocked wallet (use
first).bun run wallet/wallet.ts unlock --password <password>