Guide deployment of Clarity contracts to testnet or mainnet with pre-flight checks and safety prompts. Use when the user wants to deploy contracts to a live network.
Install
npx skillscat add kenny-stacks/stacks-claude-plugin/deploy-contract Install via the SkillsCat registry.
Deploy Contract Skill
This skill guides safe deployment of Clarity contracts to Stacks testnet or mainnet.
When to Use
- User wants to deploy contracts to testnet
- User wants to deploy contracts to mainnet
- User asks about deployment process
- After development is complete and user is ready to go live
Instructions
Step 1: Pre-Flight Checks
Run these checks before any deployment:
1.1 Contract Compilation:
clarinet checkIf this fails, stop and help fix errors first.
1.2 Test Suite:
npm run test 2>&1 | tail -20If tests fail, strongly recommend fixing before deployment.
1.3 Test Coverage (Recommended):
npm run test:coverage 2>&1 | grep -A 5 "Coverage summary" || echo "No coverage script found"Tell the user:
"Pre-flight check results:
- Contracts compile: [PASS/FAIL]
- Tests pass: [PASS/FAIL]
- Coverage: [X%] (recommend 90%+ for production)
[If any fail]: I recommend fixing these issues before deploying.
[If all pass]: Ready for deployment. Which network?"
Step 2: Network Selection
Ask the user:
"Which network would you like to deploy to?
Testnet (Recommended for first deployment)
- Free STX from faucet
- Safe for testing
- Contracts can be redeployed with fresh accounts
Mainnet
- Real STX required
- Contracts are permanent and immutable
- Requires extra safety checks
Which would you prefer?"
Step 3A: Testnet Deployment
Generate deployment plan:
clarinet deployments generate --testnetThis creates deployments/default.testnet-plan.yaml.
Show the deployment plan:
cat deployments/default.testnet-plan.yamlExplain what will be deployed and estimated costs.
Check STX balance:
Tell the user:
"Before deploying, ensure your testnet account has STX for transaction fees.
Get free testnet STX:
- Visit the Stacks Testnet Faucet: https://explorer.hiro.so/sandbox/faucet?chain=testnet
- Enter your testnet address
- Request STX (may take a few minutes)
Do you have sufficient testnet STX? Let me know when ready to deploy."
Apply deployment:
clarinet deployments apply -p deployments/default.testnet-plan.yamlPost-deployment:
Show the deployed contract addresses and explorer links:
"Deployment complete!
Your contracts are now live on testnet:
contract-name: [address]
Explorer: https://explorer.hiro.so/txid/[txid]?chain=testnet
Next steps:
- Test your contracts on testnet thoroughly
- Check transactions in the explorer
- When ready for mainnet, run this skill again and select mainnet"
Step 3B: Mainnet Deployment
IMPORTANT: Extra safety for mainnet
3B.1 Require testnet deployment first:
Ask:
"Have you successfully deployed and tested these contracts on testnet?
Mainnet deployment is permanent. I strongly recommend:
- Deploy to testnet first
- Thoroughly test all functionality
- Have contracts reviewed for security
If you haven't deployed to testnet yet, would you like to do that first?"
If user hasn't tested on testnet, encourage them to do so first.
3B.2 Security Checklist:
Present this checklist to the user:
"Mainnet Deployment Security Checklist
Please confirm each item:
- Testnet Testing: Contracts thoroughly tested on testnet
- Security Review: Contracts audited for common vulnerabilities
- Re-entrancy protection
- Integer overflow/underflow
- Access control verified
- Post-conditions used in frontend
- Sufficient STX: Account has enough STX for deployment fees
- Key Security: Deployment keys are securely backed up
- Hardware Wallet: Consider using hardware wallet for mainnet deployments
For professional security review, consider:
- Formal audit from security firms
- Community review on Discord/Forum
- Running
/stacks:expert-advicefor best practices check
Type 'confirmed' when you've reviewed this checklist, or ask questions about any item."
3B.3 Generate mainnet plan:
clarinet deployments generate --mainnetShow deployment plan and cost estimate:
cat deployments/default.mainnet-plan.yaml3B.4 Final confirmation:
"FINAL CONFIRMATION
You are about to deploy to MAINNET. This action:
- Costs real STX
- Is permanent and irreversible
- Makes contracts publicly accessible
Contracts to deploy:
[List contracts from plan]
Estimated cost: [X STX]
Type 'deploy to mainnet' to proceed, or 'cancel' to abort."
3B.5 Apply mainnet deployment:
Only proceed if user explicitly confirms.
clarinet deployments apply -p deployments/default.mainnet-plan.yamlFor priority deployment (higher fees, faster confirmation):
clarinet deployments apply -p deployments/default.mainnet-plan.yaml --high-costPost-deployment:
"Mainnet deployment complete!
Your contracts are now live:
contract-name: [address]
Explorer: https://explorer.hiro.so/txid/[txid]?chain=mainnet
IMPORTANT REMINDERS:
- Contracts are now immutable - any bugs are permanent
- Monitor transactions in the explorer
- Keep deployment keys secure
- Consider using a multisig for admin functions
Congratulations on your mainnet launch!"
Step 4: Troubleshooting
Error: Insufficient balance
"Your account doesn't have enough STX for deployment fees.
For testnet: Get free STX at https://explorer.hiro.so/sandbox/faucet?chain=testnet
For mainnet: Transfer STX from an exchange or wallet"
Error: Contract already exists
"A contract with this name already exists at this address.
Options:
- Use a different contract name
- Deploy from a different account
- For testnet: Create a fresh account"
Error: Transaction timeout
"The transaction is taking longer than expected.
Check status: https://explorer.hiro.so/txid/[txid]?chain=[network]
The transaction may still succeed. Wait and check the explorer before retrying."
Error: Nonce mismatch
"There's a nonce mismatch, likely from a pending transaction.
Wait for pending transactions to confirm, then retry deployment."
Notes
- Testnet and mainnet deployments use different accounts
- Contract names must be unique per account
- Deployment plans can be customized in the YAML file
- Use
--high-costflag for priority mainnet deployments - Always verify contracts compile (
clarinet check) before deployment