clarity-deployment
Skill2 starsChanged 31 days agoMITView on GitHub
Deploy Clarity contracts to testnet or mainnet: Clarinet deployment plans, scripted releases, initialization calls, nonces and post-deploy checks. Use to deploy, publish or initialize contracts.
In this repository24 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- clarity-apisSkill
- clarity-assetsSkill
- clarity-auditorSkill
- clarity-bitcoin-proofsSkill
- clarity-ecosystemSkill
- clarity-environmentsSkill
- clarity-epochsSkill
- clarity-fuzzingSkill
- clarity-governanceSkill
- clarity-optimizerSkill
- clarity-oraclesSkill
- clarity-protocolsSkill
- clarity-scholarSkill
- clarity-securitySkill
- clarity-sip-complianceSkill
- clarity-stakingSkill
- clarity-startSkill
- clarity-system-integrationSkill
- clarity-testingSkill
- clarity-upgradesSkill
- clarity-walletsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 10 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
Use protocols for verified addresses/interfaces and ecosystem for composition.
- Distinctive: line 15
Do not redeploy external production protocols as if they were your dependencies to control.
- Very specific: line 33
Verify: /v2/contracts/source, /v2/contracts/interface, read-only calls for initialized state, roles and balances (verify the release).
- Very specific: line 56
Use --mainnet only for the intended mainnet release.
- Distinctive: line 76
Check deployer identities, exact Clarity versions, dependency remaps, contract names, fees, nonces and initialization calls.
- Distinctive: line 101
Read references/scripts-and-builders.md for a fragment that signs, checkpoints and broadcasts one call step in that order, and when …
- Distinctive: line 109
Read references/scripts-and-builders.md when preparing an unsigned deployment for review: a fragment that pins the Clarity version and …
- Very specific: line 126
Avoid distributing ordered setup across side-effecting constants: keep dependent effects in one explicit begin/initializer and assert the …
- Distinctive: line 138
Prefer small atomic top-level setup when appropriate.
- Distinctive: line 148
Add only the target's required steps (governance, registries, assets/oracles, seed liquidity, integration permissions) and set members, …
- Distinctive: line 151
Read the protocol registry and its freshness rules (live verification once evidence is 30 days old).
- Distinctive: line 153
Read references/examples.md when adapting ExecutorDAO, Zest or Granite deployments or looking for an initialization pattern.
- Very specific: line 160
Verify native asset identity and spendable funds, pool/token order, share beneficiaries, integration approvals and pause/cap/fee settings.
- Distinctive: line 161
Remove temporary setup authority only through the intended transition and verify the final controller can act.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Clarity Deployment
A release is complete only when it covers immutable source, deployment identity, dependency order, initialization, governance and operational verification.
- Use protocols for verified addresses/interfaces and ecosystem for composition; return here for deployment and initialization. For an adapter release, resolve external interfaces there and prepare the adapter's own deployment graph here.
- Do not redeploy external production protocols as if they were your dependencies to control. Resolve their deployed principals and required integration permissions.
Key distinctions
- Publishing contracts is not complete protocol initialization. Unfinished initialization is not a complete release.
- A Clarinet deployment plan can include contract calls and is sufficient for straightforward publication and fixed initialization. Recommend a resumable script for anything more complex: state-dependent setup, external verification, multisig signatures, governance waits, checkpointed retries or transaction postconditions constructed in code. A script can supplement the plan with wiring calls or handle the whole release.
- A submitted transaction or nonce advance does not prove success. Reverted deployments can leave a name available for different code.
- Review test setup before reuse: signer thresholds, emergency paths, mock assets and oracle feeds must match the intended deployment.
- Multiple transactions in one block, or one plan batch, are not an atomic deployment bundle. If the protocol requires atomic initialization, implement one authenticated transaction or proposal and prove its budget fits.
Release
For "deploy these N contracts":
clarinet check, then the test suite with coverage; state the line-coverage figure (coverage report).clarinet deployments generate --testnet --medium-cost; hand-edit the plan to add initializationcontract-callsteps;clarinet deployments check.- Review the plan: deployer, order, contract names, Clarity versions, fees.
- Apply straightforward publication and initialization with
clarinet deployments apply --testnet -d --no-dashboard(-dapplies the reviewed file as is). For more complex releases or postconditions constructed in code, recommend a resumable script for wiring calls or the whole release; follow the release script rules. - Verify:
/v2/contracts/source,/v2/contracts/interface, read-only calls for initialized state, roles and balances (verify the release). - Repeat for mainnet with the same sources and plan content; save principals, txids and hashes.
- Preparing a mainnet plan without the production key: The scaffold's
settings/Mainnet.tomlholds a placeholder mnemonic, soclarinet deployments generate --mainnet --medium-costfails ("invalid word count"). For a reviewable plan, generate it with a throwaway mnemonic that is never funded (for example the public devnet one), set everyexpected-senderto the real deployer address, put the placeholder back insettings/Mainnet.toml, and commit the plan, plus the release steps file and script if used. Every role principal (admin, keeper, guardian, treasury) is a literal address from the release configuration; never use a devnet or throwaway account for a role, because their keys are public. At release, regenerate with the real (encrypted) mnemonic, check that the diff shows only your added steps and fees, answernto keep the reviewed plan, and apply it with-d. - Establish network, deployer/signer mechanism, Clarity/epoch support, contract names, source revisions and intended final authority first.
- Separate prepare, sign, broadcast, confirm and verify stages. Prepare a concrete release artifact before external writes; act within the user's existing deployment authorization.
- Rehearse the exact graph and initialization through public calls with the project's tests (Clarigen by default, see testing) and an appropriate devnet/pinned simulation; reuse the reviewed plan content and source hashes from the testnet rehearsal and regenerate only network-specific fields.
- Maintain one authored logic set; use explicit environment bindings for mock tests and reviewed production artifacts. Do not deploy a manually maintained testing copy.
Clarinet plans
clarinet check
clarinet deployments generate --testnet --medium-cost # --low-cost|--medium-cost|--high-cost|--manual-cost is required; the first three query the network for fees
clarinet deployments check
# Review deployments/default.testnet-plan.yaml; hand-edit it to add initialization contract-call steps.
# This broadcasts. -d applies exactly the reviewed file and skips the Y/n prompt:
clarinet deployments apply --testnet --use-on-disk-deployment-plan --no-dashboard- Without
-d,applyrecomputes the plan from the manifest. If it differs from the file you reviewed, it prints a diff and asksOverwrite? [Y/n](Enter means yes), thenContinue [Y/n]?(Enter means yes).-coverwrites with the recomputed plan without asking.generatealso asks before replacing a changed existing plan, so hand-edit only after the lastgenerate. --no-dashboardprints status lines instead of the terminal UI (use it in CI and agent shells).-p path/to/plan.yamlapplies a custom plan; it cannot be combined with--testnet/--mainnet.- The deployer comes from
settings/Testnet.tomlorsettings/Mainnet.toml([accounts.deployer], gitignored byclarinet new). Runclarinet deployments encrypt(prompts for mnemonic and password,--strengthbasic|medium|high|extreme) and paste the printedencrypted_mnemonic_<strength> = "..."line instead of a plaintextmnemonic. - Use
--mainnetonly for the intended mainnet release. - Step types:
contract-publish,contract-call,requirement-publish(remapped dependency) andemulated-*(simnet only). Plan layout (from Clarinet'scounterexample) with onecontract-callstep:parametersare evaluated as Clarity expressions (literals as shown), andcostis its fee in micro-STX:
# fragment: one contract-call step in a plan batch
plan:
batches:
- id: 1
transactions:
- transaction-type: contract-call
contract-id: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.vault
expected-sender: ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM
method: initialize
parameters:
- u1000000
- "'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.treasury"
cost: 5960- Each batch is broadcast, then Clarinet waits for its inclusion before starting the next; neither batching nor order makes the group atomic. Plan transactions carry no postconditions (
Allowmode), so send any step that moves assets from a script. - Check deployer identities, exact Clarity versions, dependency remaps, contract names, fees, nonces and initialization calls.
Source: Clarinet CLI.
Release script rules
A script for wiring calls (or a whole release) with a single-signature deployer and @stacks/transactions 7.6.0 follows these rules. Node 22.18+ runs a .ts script directly.
- Ordered steps: Keep the project's existing release format if it has one. Otherwise list steps in dependency order: traits first, then contracts, then wiring calls (owner handoffs, strategy registration, roles, caps), then the hand-over of setup authority. For example, a deploy step
{ "id", "deploy": name, "source": path relative to the steps file, "fee" }and a call step{ "id", "call": contract, "function", "args": [...], "fee", "verify": [{ "contract", "function", "args", "expect" }] }. Arguments and expected values are Clarity literals as in plans,{deployer}is replaced by the deployer address, and every fee is a reviewed micro-STX amount. - Role principals (admin, keeper, guardian, treasury) are literals from the release configuration, never devnet or test accounts, whose mnemonics are public.
- Dry run without a key: With only the deployer address the script reads the chain and prints what it would send, with source sha256 hashes.
- Checkpoint every step in a release record next to the steps file (for example
release.<network>.json), written atomically (temporary file, then rename). It is the release record: txids and signed transactions, no keys. Commit it after the release; never commit the deployer key or an env file holding it. Never log the key; for mainnet prefer a signer service or wallet flow over environment keys. - Save the signed transaction and txid before broadcasting: A lost response or a pending transaction is resolved by waiting on that txid; never re-sign a step that has a saved txid. A polling timeout is unknown status, never permission to re-sign.
- Explicit nonces: After resumed steps are confirmed, read
next_nonceonce fromGET /extended/v3/principals/{deployer}/nonces(it counts mempool transactions) and increment it per broadcast step. Stop if that read fails ormempool.last_nonceis not null: a new nonce after a pending transaction can let both run. NotfetchNonce: 7.6.0 reads the deprecated v1 route and on any error silently falls back to/v2/accounts, whose nonce ignores pending transactions. - Retries only where the request was not processed: 429 for every request, plus 500/502/503/504 for reads (GETs and
call-read). Honorretry-after, otherwise back off exponentially, and bound the attempts. Never retry a broadcast on a 5xx. - Stop on any non-success status:
broadcastTransactionreturns{ txid }on acceptance and{ error, reason, txid }on rejection (for exampleBadNonce, fee too low): remove that step's checkpoint entry (this transaction used no nonce), fix the cause and rerun. PollGET /extended/v3/transactions/0x{txid}:successwith ablockis done;abort_by_response,abort_by_post_conditionorproblematic_skipped(nonce used, payload not run) stops the run and the entry keeps the txid, so a rerun stops again without resending. A 404 means not indexed yet, dropped or replaced. If it lasts, read the v3 nonces, then the txid again: iflast_confirmed_nonceormempool.last_noncehas reached the step's nonce, another transaction used it or is pending at or after it, so stop; otherwise rebroadcast the saved bytes, a few times at most (same txid, so it still runs at most once). Delete the entry only once you have decided to send a new transaction; to replace a pending one, re-sign at its nonce with a higher fee. - Read-only checks after every step that describe its whole effect, for example
get-ownerreturning(some '{deployer}.vault). If they already hold before a call step (for example after a lost checkpoint), record the step instead of sending it. A read on a contract that does not exist yet (NoSuchContract) counts as not holding. - Refuse a deployed name with different source: Before a deploy step, fetch
/v2/contracts/source/{address}/{name}?proof=0: same sha256 means record it as already deployed; different source means stop, because contract names cannot be reused. This also lets you publish with the Clarinet plan (same deployer) and run the script for the wiring only; omit deploy steps for sources Clarinet rewrote. - Never publish
#[env(simnet)]code: Clarinet strips it before publishing, but a script sends the file as is. Refuse such a source, or publish it with the plan. PostConditionMode.Denywith exact postconditions for steps that move assets. An empty list makes any step that moves an asset, the deployer's or a contract's (including top-level code during a deploy), abort on chain; add exact conditions for steps that seed liquidity or fund contracts.- Mainnet guard: Nothing is broadcast on mainnet unless an explicit confirmation (for example
CONFIRM_MAINNET) equals the deployer address. - Validate
clarityVersion(1-6 at this baseline) and pass it to the deploy builder. - API bases: devnet
http://localhost:3999, testnethttps://api.testnet.hiro.so, mainnethttps://api.hiro.so. Rehearse on devnet (key from the# secret_key:comment of the deployer insettings/Devnet.toml), then testnet, then mainnet. - Steps are separate transactions and the sequence is not atomic: anyone can call a public function between your steps. Wiring that must happen right after deployment belongs in the deploying contract's top-level code or behind an owner check, with the deployer as the initial owner.
- Single-signature deployer only. For a multisig or governed deployer, or governed initialization that waits on signers or a timelock (persist the proposal ID), use governance.
- Read references/scripts-and-builders.md for a fragment that signs, checkpoints and broadcasts one call step in that order, and when extending the script for multisig, sponsorship or governance waits (extended releases).
Transaction builders
@stacks/transactions7.6.0:ClarityVersion.Clarity5exists from 7.4.0 andClarity6from 7.5.0 (7.3.1 stops at Clarity4). Keep one deduped copy (npm ls @stacks/transactions,overridesif needed).makeContractDeployandmakeUnsignedContractDeploypin Clarity 4 whenclarityVersionis omitted; pass the intended version. Epoch 4.1 (unscheduled) will reject any deploy that pins a Clarity version, so keep the version a release-config input and re-check it before a post-4.1 release.- Set fee and nonce explicitly instead of relying on mutable automatic defaults during signing.
- Preparing unsigned transactions needs no private key:
publicKey, source file and contract name come from the release configuration. Signing and broadcasting are later steps of the user's release; never log private keys or commit credentials. - Read references/scripts-and-builders.md when preparing an unsigned deployment for review: a fragment that pins the Clarity version and writes the serialized transaction and source hash.
- Native multisig:
publicKeys,numSignatures, the selected signing mode and the verified address instead ofpublicKey. Nonces are per originating principal, including native multisig; account for sponsor authorization separately. - Build initialization calls with
makeUnsignedContractCalland exact serialized arguments from the verified ABI or generated clients; supply postconditions for any initialization funding. - Preserve exact source bytes and principal substitutions. Do not blindly replace addresses inside signed domains or authorization checks.
- For browser or Ledger signing, read wallet compatibility: inspect serialized payload/version, transaction size and device/app support. Check historical payload workarounds before reuse: changing the payload requires new signatures and can change the deployed language.
Source: transaction builders.
Deployment-time execution
- Top-level expressions and constant initializers execute once at deployment.
define-constantcan call local or deployed functions, including side effects;define-data-varevaluates its initial value at deployment. Constants remain fixed when external state later changes. - Function definitions register bodies; those bodies execute only when called. A later call loads the deployed contract; it does not repeat the top-level expressions.
- At top level
tx-senderandcontract-callerare the deployer; trace subsequent cross-contract calls and context changes from the deployer normally, and include deployment-time outflows in postconditions.
Definition dependencies determine order
- Clarity dependency-sorts top-level definitions: forward references work, cycles fail analysis, and textual order does not fix the order of stateful initializers. Function placement alone does not schedule execution. Cross-contract dependencies must already exist on the target network.
- Avoid distributing ordered setup across side-effecting constants: keep dependent effects in one explicit
begin/initializer and assert the resulting state.
Failures must actually abort
- A top-level
(err ...)does not abort deployment, and a constant may retain anerrresponse while deployment succeeds. Wrap mandatory setup calls inunwrap-panicand verify initialized state (a lost dead-share mint reopens share inflation). - A runtime failure (for example
unwrap-panicon a mandatory response) aborts deployment and rolls back its nested effects; test both contract absence and dependency state. - Distinguish failed publication from successful publication with incomplete setup. Verify initialized state, not only the deployment transaction status.
Keep recurring costs in view
- Deployment-only code stays in the immutable source and is charged on later loads. Source-size guidance explains runtime/read-byte charges, formatting and measured examples.
- Large setup is valid when it fits resource limits. Check serialized transaction size, analysis, runtime, reads/writes and memory separately.
- Prefer small atomic top-level setup when appropriate. For bulky registries or orchestration, prefer bounded authenticated initialization calls from a script or setup/proposal contract; guard initialization authority, allowed progress and finalization, and block normal operations until setup completes.
- Separate transactions lose atomicity, and calls made from a setup contract see it as
contract-caller, not the deployer.
Sources: definition sorter, top-level evaluator, constant initializer, initialization transaction.
Initialization
- Derive the graph from deployment-time calls, trait/static dependencies, initialization functions and the approved release configuration. Publish required traits/dependencies before contracts that reference them. A principal literal passed as a trait argument is also a dependency, even without
contract-call?; a principal used only as data is not. - For a dependency cycle, use authenticated one-time post-deployment bindings; test initialization and rebinding refusal.
- Regenerate the simnet deployment plan after dependency-graph changes; a preserved old plan can keep an invalid order.
- Add only the target's required steps (governance, registries, assets/oracles, seed liquidity, integration permissions) and set members, thresholds, timelocks, feeds and funding explicitly; review any value copied from local tests.
- Calling
contract.getImpl()only constructs a Clarigen call object. Userov/rovOkin tests or a real read-only client in scripts to execute verification. A local test helper does not establish a production signing/broadcast workflow. - Confirm every dependency's successful canonical deployment before dependent steps; resume by checking chain state, not by re-signing. Re-check when a reorg invalidates a dependency or confirmation; do not roll back committed independent transactions by deleting checkpoints.
- Read the protocol registry and its freshness rules (live verification once evidence is 30 days old). Verify live addresses/ABIs, mutable roles, traits and remaps before signing; capture source/configuration hashes.
- For upgrades, use upgrade architecture and its release plan rules; prepare timelocked activation, preserve state/custody/pending claims, and verify old-role retirement. Publishing replacement code does not activate or migrate it.
- Read references/examples.md when adapting ExecutorDAO, Zest or Granite deployments or looking for an initialization pattern; their choices are examples, not default dependencies or authority settings.
Verify the release
- Require a successful canonical receipt for each step:
GET /extended/v3/transactions/0x{txid}withstatus: "success"and ablock, and for a deploy the intendedsmart_contract.contract_idandsmart_contract.clarity_version. v3 returns the canonical mined record or a pending one and has nocanonicalflag; a reorg can return it to pending or move it to another block, so re-read it before you report. API acceptance is not execution success. - Capture the deployed source and ABI and compare hashes. Clarinet strips
#[env(simnet)]code before publishing and, on devnet and testnet, rewrites mainnet boot, sBTC and requirement contract IDs; the two may differ only by those changes. - Confirm registry-selected implementations, admin/owner/executor, multisig membership/threshold, timelocks and emergency roles.
- Verify native asset identity and spendable funds, pool/token order, share beneficiaries, integration approvals and pause/cap/fee settings. Assert initial reserves/minimum shares; use null-principal shares for a permanent supply floor.
- Remove temporary setup authority only through the intended transition and verify the final controller can act.
- Report network, source revision, deployed principals, transaction IDs, state/config checks and pending governance/timelock actions.
- System addresses, API evidence, versions: use only as needed.
Reference baseline
Examples use Clarity 4+ syntax unless marked, checked on epoch 4.0. Source links in this skill use these pins; links into sibling skills use their owner's SKILL.md.
stacks-core: ccf31dc69c.executor-dao: 4676718828.stacks-core-targeted: 01a60adcb6.granite: 2d44a2df94.stacks-blockchain-api: ee0c0ac5be.stacks-js-release: 6101c99efe.zest-v2: f2fce52672.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

